-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2872 from woocommerce/PCP-3939-cannot-be-zero-or-…
…negative-with-express-checkout-for-free-trial-subscriptions-on-block-checkout "CANNOT_BE_ZERO_OR_NEGATIVE" with Express Checkout for Free Trial Subscriptions on Block checkout (3939)
- Loading branch information
Showing
8 changed files
with
952 additions
and
774 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
modules/ppcp-blocks/resources/js/Components/block-editor-paypal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { useMemo } from '@wordpress/element'; | ||
import { normalizeStyleForFundingSource } from '../../../../ppcp-button/resources/js/modules/Helper/Style'; | ||
import { PayPalButtons, PayPalScriptProvider } from '@paypal/react-paypal-js'; | ||
|
||
export const BlockEditorPayPalComponent = ( { | ||
config, | ||
fundingSource, | ||
buttonAttributes, | ||
} ) => { | ||
const urlParams = useMemo( | ||
() => ( { | ||
clientId: 'test', | ||
...config.scriptData.url_params, | ||
dataNamespace: 'ppcp-blocks-editor-paypal-buttons', | ||
components: 'buttons', | ||
} ), | ||
[] | ||
); | ||
|
||
const style = useMemo( () => { | ||
const configStyle = normalizeStyleForFundingSource( | ||
config.scriptData.button.style, | ||
fundingSource | ||
); | ||
|
||
if ( buttonAttributes ) { | ||
return { | ||
...configStyle, | ||
height: buttonAttributes.height | ||
? Number( buttonAttributes.height ) | ||
: configStyle.height, | ||
borderRadius: buttonAttributes.borderRadius | ||
? Number( buttonAttributes.borderRadius ) | ||
: configStyle.borderRadius, | ||
}; | ||
} | ||
|
||
return configStyle; | ||
}, [ fundingSource, buttonAttributes ] ); | ||
|
||
return ( | ||
<PayPalScriptProvider options={ urlParams }> | ||
<PayPalButtons | ||
className={ `ppc-button-container-${ fundingSource }` } | ||
fundingSource={ fundingSource } | ||
style={ style } | ||
forceReRender={ [ buttonAttributes || {} ] } | ||
onClick={ () => false } | ||
/> | ||
</PayPalScriptProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
modules/ppcp-blocks/resources/js/Components/paypal-label.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const PaypalLabel = ( { components, config } ) => { | ||
const { PaymentMethodIcons } = components; | ||
|
||
return ( | ||
<> | ||
<span | ||
dangerouslySetInnerHTML={ { | ||
__html: config.title, | ||
} } | ||
/> | ||
<PaymentMethodIcons icons={ config.icon } align="right" /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.