Skip to content

Move Simple Payments to PayPal Payments package #43413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Simple Payments: Move Simple Payments block to PayPal Payments package.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"payments"
],
"version": "12.5.0",
"textdomain": "jetpack",
"textdomain": "jetpack-paypal-payments",
"category": "monetize",
"icon": "<svg viewBox='0 0 24 24' width='24' height='24' xmlns='http://www.w3.org/2000/svg'><path fill='none' d='M0 0h24v24H0V0z' /><path d='M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z' /></svg>",
"supports": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { PanelBody, TextControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**

Check warning on line 4 in projects/packages/paypal-payments/src/simple-payments/controls.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc block description

Check warning on line 4 in projects/packages/paypal-payments/src/simple-payments/controls.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @return declaration
*
* @param root0

Check warning on line 6 in projects/packages/paypal-payments/src/simple-payments/controls.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0" description

Check failure on line 6 in projects/packages/paypal-payments/src/simple-payments/controls.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0" type
* @param root0.setAttributes

Check warning on line 7 in projects/packages/paypal-payments/src/simple-payments/controls.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0.setAttributes" description

Check failure on line 7 in projects/packages/paypal-payments/src/simple-payments/controls.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0.setAttributes" type
* @param root0.postLinkText

Check warning on line 8 in projects/packages/paypal-payments/src/simple-payments/controls.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0.postLinkText" description

Check failure on line 8 in projects/packages/paypal-payments/src/simple-payments/controls.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0.postLinkText" type
*/
export function PanelControls( { setAttributes, postLinkText } ) {
return (
<PanelBody title={ __( 'Settings', 'jetpack' ) } initialOpen={ false }>
<PanelBody title={ __( 'Settings', 'jetpack-paypal-payments' ) } initialOpen={ false }>
<TextControl
__nextHasNoMarginBottom={ true }
__next40pxDefaultSize
label={ __( 'Purchase link text', 'jetpack' ) }
label={ __( 'Purchase link text', 'jetpack-paypal-payments' ) }
help={ __(
'Enter the text you want to display on a purchase link used as fallback when the PayPal button cannot be used (e.g. emails, AMP, etc.)',
'jetpack'
'jetpack-paypal-payments'
) }
className="jetpack-simple-payments__purchase-link-text"
placeholder={ __( 'Click here to purchase', 'jetpack' ) }
placeholder={ __( 'Click here to purchase', 'jetpack-paypal-payments' ) }
onChange={ newPostLinkText => setAttributes( { postLinkText: newPostLinkText } ) }
value={ postLinkText }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SimplePaymentsEdit extends Component {
setAttributes( {
...( shouldUpdatePostLinkUrl && { postLinkUrl } ),
...( shouldUpdatePostLinkText && {
postLinkText: __( 'Click here to purchase.', 'jetpack' ),
postLinkText: __( 'Click here to purchase.', 'jetpack-paypal-payments' ),
} ),
} );
}
Expand Down Expand Up @@ -94,7 +94,7 @@ class SimplePaymentsEdit extends Component {
setAttributes( {
...( shouldUpdatePostLinkUrl && { postLinkUrl } ),
...( shouldUpdatePostLinkText && {
postLinkText: __( 'Click here to purchase.', 'jetpack' ),
postLinkText: __( 'Click here to purchase.', 'jetpack-paypal-payments' ),
} ),
} );
}
Expand Down Expand Up @@ -196,12 +196,14 @@ class SimplePaymentsEdit extends Component {
apiErrorKey === 'spay_email'
? sprintf(
/* translators: placeholder is an email address. */
__( '%s is not a valid email address.', 'jetpack' ),
__( '%s is not a valid email address.', 'jetpack-paypal-payments' ),
email
)
: null,
fieldPriceError:
apiErrorKey === 'spay_price' ? __( 'Invalid price.', 'jetpack' ) : null,
apiErrorKey === 'spay_price'
? __( 'Invalid price.', 'jetpack-paypal-payments' )
: null,
} );
} )
.finally( () => {
Expand Down Expand Up @@ -248,15 +250,15 @@ class SimplePaymentsEdit extends Component {
this.setState( {
fieldPriceError: __(
'If you’re selling something, you need a price tag. Add yours here.',
'jetpack'
'jetpack-paypal-payments'
),
} );
return false;
}

if ( Number.isNaN( parseFloat( price ) ) ) {
this.setState( {
fieldPriceError: __( 'Invalid price', 'jetpack' ),
fieldPriceError: __( 'Invalid price', 'jetpack-paypal-payments' ),
} );
return false;
}
Expand All @@ -265,7 +267,7 @@ class SimplePaymentsEdit extends Component {
this.setState( {
fieldPriceError: __(
'Your price is negative — enter a positive number so people can pay the right amount.',
'jetpack'
'jetpack-paypal-payments'
),
} );
return false;
Expand All @@ -277,7 +279,7 @@ class SimplePaymentsEdit extends Component {
this.setState( {
fieldPriceError: __(
'We know every penny counts, but prices in this currency can’t contain decimal values.',
'jetpack'
'jetpack-paypal-payments'
),
} );
return false;
Expand All @@ -290,7 +292,7 @@ class SimplePaymentsEdit extends Component {
'The price cannot have more than %d decimal place.',
'The price cannot have more than %d decimal places.',
precision,
'jetpack'
'jetpack-paypal-payments'
),
precision
),
Expand Down Expand Up @@ -318,7 +320,7 @@ class SimplePaymentsEdit extends Component {
this.setState( {
fieldEmailError: __(
'We want to make sure payments reach you, so please add an email address.',
'jetpack'
'jetpack-paypal-payments'
),
} );
return false;
Expand All @@ -328,7 +330,7 @@ class SimplePaymentsEdit extends Component {
this.setState( {
fieldEmailError: sprintf(
/* translators: placeholder is an email address. */
__( '%s is not a valid email address.', 'jetpack' ),
__( '%s is not a valid email address.', 'jetpack-paypal-payments' ),
email
),
} );
Expand All @@ -355,7 +357,7 @@ class SimplePaymentsEdit extends Component {
this.setState( {
fieldTitleError: __(
'Please add a brief title so that people know what they’re paying for.',
'jetpack'
'jetpack-paypal-payments'
),
} );
return false;
Expand Down Expand Up @@ -410,15 +412,15 @@ class SimplePaymentsEdit extends Component {

renderSettings = () => (
<InspectorControls>
<PanelBody title={ __( 'Settings', 'jetpack' ) } initialOpen={ false }>
<PanelBody title={ __( 'Settings', 'jetpack-paypal-payments' ) } initialOpen={ false }>
<TextControl
label={ __( 'Purchase link text', 'jetpack' ) }
label={ __( 'Purchase link text', 'jetpack-paypal-payments' ) }
help={ __(
'Enter the text you want to display on a purchase link used as fallback when the PayPal button cannot be used (e.g. emails, AMP, etc.)',
'jetpack'
'jetpack-paypal-payments'
) }
className="jetpack-simple-payments__purchase-link-text"
placeholder={ __( 'Click here to purchase', 'jetpack' ) }
placeholder={ __( 'Click here to purchase', 'jetpack-paypal-payments' ) }
onChange={ newPostLinkText =>
this.props.setAttributes( { postLinkText: newPostLinkText } )
}
Expand Down Expand Up @@ -499,9 +501,9 @@ class SimplePaymentsEdit extends Component {
className={ clsx( 'simple-payments__field', 'simple-payments__field-title', {
'simple-payments__field-has-error': fieldTitleError,
} ) }
label={ __( 'Item name', 'jetpack' ) }
label={ __( 'Item name', 'jetpack-paypal-payments' ) }
onChange={ this.handleTitleChange }
placeholder={ __( 'Item name', 'jetpack' ) }
placeholder={ __( 'Item name', 'jetpack-paypal-payments' ) }
required
type="text"
value={ title }
Expand All @@ -512,17 +514,17 @@ class SimplePaymentsEdit extends Component {

<TextareaControl
className="simple-payments__field simple-payments__field-content"
label={ __( 'Describe your item in a few words', 'jetpack' ) }
label={ __( 'Describe your item in a few words', 'jetpack-paypal-payments' ) }
onChange={ this.handleContentChange }
placeholder={ __( 'Describe your item in a few words', 'jetpack' ) }
placeholder={ __( 'Describe your item in a few words', 'jetpack-paypal-payments' ) }
value={ content }
/>

<div className="simple-payments__price-container">
<SelectControl
__next40pxDefaultSize
className="simple-payments__field simple-payments__field-currency"
label={ __( 'Currency', 'jetpack' ) }
label={ __( 'Currency', 'jetpack-paypal-payments' ) }
onChange={ this.handleCurrencyChange }
options={ this.getCurrencyList }
value={ currency }
Expand All @@ -532,7 +534,7 @@ class SimplePaymentsEdit extends Component {
className={ clsx( 'simple-payments__field', 'simple-payments__field-price', {
'simple-payments__field-has-error': fieldPriceError,
} ) }
label={ __( 'Price', 'jetpack' ) }
label={ __( 'Price', 'jetpack-paypal-payments' ) }
onChange={ this.handlePriceChange }
placeholder={ formatPriceFallback( 0, currency, false ) }
required
Expand All @@ -548,7 +550,10 @@ class SimplePaymentsEdit extends Component {
<div className="simple-payments__field-multiple">
<ToggleControl
checked={ Boolean( multiple ) }
label={ __( 'Allow people to buy more than one item at a time', 'jetpack' ) }
label={ __(
'Allow people to buy more than one item at a time',
'jetpack-paypal-payments'
) }
onChange={ this.handleMultipleChange }
/>
</div>
Expand All @@ -558,9 +563,9 @@ class SimplePaymentsEdit extends Component {
className={ clsx( 'simple-payments__field', 'simple-payments__field-email', {
'simple-payments__field-has-error': fieldEmailError,
} ) }
label={ __( 'Email', 'jetpack' ) }
label={ __( 'Email', 'jetpack-paypal-payments' ) }
onChange={ this.handleEmailChange }
placeholder={ __( 'Email', 'jetpack' ) }
placeholder={ __( 'Email', 'jetpack-paypal-payments' ) }
required
// TODO: switch this back to type="email" once Gutenberg paste handler ignores inputs of type email
type="text"
Expand All @@ -572,10 +577,10 @@ class SimplePaymentsEdit extends Component {
<HelpMessage id={ `${ instanceId }-email-help` }>
{ __(
'Enter the email address associated with your PayPal account. Don’t have an account?',
'jetpack'
'jetpack-paypal-payments'
) + ' ' }
<ExternalLink href="https://www.paypal.com/">
{ __( 'Create one on PayPal', 'jetpack' ) }
{ __( 'Create one on PayPal', 'jetpack-paypal-payments' ) }
</ExternalLink>
</HelpMessage>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,25 @@ const supportLink =
: 'https://jetpack.com/support/jetpack-blocks/pay-with-paypal/';

const settings = {
title: __( 'Pay with PayPal', 'jetpack' ),
title: __( 'Pay with PayPal', 'jetpack-paypal-payments' ),

description: (
<Fragment>
<p>
{ __(
'Lets you add credit and debit card payment buttons with minimal setup.',
'jetpack'
'jetpack-paypal-payments'
) }
</p>
<p>
{ __( 'Good for collecting donations or payments for products and services.', 'jetpack' ) }
{ __(
'Good for collecting donations or payments for products and services.',
'jetpack-paypal-payments'
) }
</p>
<ExternalLink href={ supportLink }>{ __( 'Support reference', 'jetpack' ) }</ExternalLink>
<ExternalLink href={ supportLink }>
{ __( 'Support reference', 'jetpack-paypal-payments' ) }
</ExternalLink>
</Fragment>
),

Expand All @@ -48,14 +53,14 @@ const settings = {
category: 'monetize',

keywords: [
_x( 'buy', 'block search term', 'jetpack' ),
_x( 'commerce', 'block search term', 'jetpack' ),
_x( 'products', 'block search term', 'jetpack' ),
_x( 'purchase', 'block search term', 'jetpack' ),
_x( 'sell', 'block search term', 'jetpack' ),
_x( 'shop', 'block search term', 'jetpack' ),
_x( 'simple', 'block search term', 'jetpack' ),
_x( 'payments', 'block search term', 'jetpack' ),
_x( 'buy', 'block search term', 'jetpack-paypal-payments' ),
_x( 'commerce', 'block search term', 'jetpack-paypal-payments' ),
_x( 'products', 'block search term', 'jetpack-paypal-payments' ),
_x( 'purchase', 'block search term', 'jetpack-paypal-payments' ),
_x( 'sell', 'block search term', 'jetpack-paypal-payments' ),
_x( 'shop', 'block search term', 'jetpack-paypal-payments' ),
_x( 'simple', 'block search term', 'jetpack-paypal-payments' ),
_x( 'payments', 'block search term', 'jetpack-paypal-payments' ),
'PayPal',
],

Expand Down Expand Up @@ -106,7 +111,7 @@ const settings = {
type: 'string',
source: 'html',
selector: '.jetpack-simple-payments-purchase',
default: __( 'Click here to purchase.', 'jetpack' ),
default: __( 'Click here to purchase.', 'jetpack-paypal-payments' ),
},
price: {
type: 'number',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { formatPriceFallback } from '../../utils';

/**

Check warning on line 3 in projects/packages/paypal-payments/src/simple-payments/deprecated/v2/save.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc block description

Check warning on line 3 in projects/packages/paypal-payments/src/simple-payments/deprecated/v2/save.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @return declaration
*
* @param root0

Check warning on line 5 in projects/packages/paypal-payments/src/simple-payments/deprecated/v2/save.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0" description

Check failure on line 5 in projects/packages/paypal-payments/src/simple-payments/deprecated/v2/save.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0" type
* @param root0.attributes

Check warning on line 6 in projects/packages/paypal-payments/src/simple-payments/deprecated/v2/save.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0.attributes" description

Check failure on line 6 in projects/packages/paypal-payments/src/simple-payments/deprecated/v2/save.js

View workflow job for this annotation

GitHub Actions / ESLint (non-excluded files only)

Missing JSDoc @param "root0.attributes" type
*/
export default function Save( { attributes } ) {
const {
content,
Expand Down
Loading
Loading