Skip to content

Commit 88fc09a

Browse files
Alex Floriscadiegocurbelo
andauthored
Integrate express payments buttonAttributes API from the Checkout Block (#3164)
* Render express button with attributes coming from the express checkout * Remove default height * Get label from stripe settings * Only respect button attributes when available * Remove px from height * safer type checking * Remove duplicate comment * Add an admin notice * Add an admin notice * Add admin notice * Update admin notice * Update admin notice * Remove darkMode --------- Co-authored-by: Diego Curbelo <[email protected]>
1 parent 9b93dae commit 88fc09a

File tree

4 files changed

+76
-3
lines changed

4 files changed

+76
-3
lines changed

client/blocks/payment-request/payment-request-express.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const PaymentRequestExpressComponent = ( {
4444
onClick,
4545
onClose,
4646
setExpressPaymentError,
47+
buttonAttributes,
4748
} ) => {
4849
const stripe = useStripe();
4950
const { needsShipping } = shippingData;
@@ -71,20 +72,24 @@ const PaymentRequestExpressComponent = ( {
7172

7273
// locale is not a valid value for the paymentRequestButton style.
7374
// Make sure `theme` defaults to 'dark' if it's not found in the server provided configuration.
74-
const {
75+
let {
7576
type = 'default',
7677
theme = 'dark',
7778
height = '48',
7879
} = getBlocksConfiguration()?.button;
7980

81+
// If we are on the checkout block, we receive button attributes which overwrite the extension specific settings
82+
if ( typeof buttonAttributes !== 'undefined' ) {
83+
height = buttonAttributes.height || height;
84+
}
85+
8086
const paymentRequestButtonStyle = {
8187
paymentRequestButton: {
8288
type,
8389
theme,
8490
height: `${ height }px`,
8591
},
8692
};
87-
8893
const isBranded = getBlocksConfiguration()?.button?.is_branded;
8994
const brandedType = getBlocksConfiguration()?.button?.branded_type;
9095
const isCustom = getBlocksConfiguration()?.button?.is_custom;

client/entrypoints/payment-request-settings/payment-request-settings-section.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
import { ADMIN_URL, getSetting } from '@woocommerce/settings';
12
import { __ } from '@wordpress/i18n';
23
import React, { useMemo } from 'react';
3-
import { Card, RadioControl, CheckboxControl } from '@wordpress/components';
4+
import {
5+
Card,
6+
RadioControl,
7+
CheckboxControl,
8+
Notice,
9+
} from '@wordpress/components';
410
import interpolateComponents from 'interpolate-components';
511
import { Elements } from '@stripe/react-stripe-js';
612
import { loadStripe } from '@stripe/stripe-js';
@@ -155,9 +161,21 @@ const PaymentRequestsSettingsSection = () => {
155161
}
156162
};
157163

164+
const checkoutPageUrl = `${ ADMIN_URL }post.php?post=${
165+
getSetting( 'storePages' )?.checkout?.id
166+
}&action=edit`;
167+
158168
return (
159169
<Card className="express-checkout-settings">
160170
<CardBody>
171+
<Notice status="warning" isDismissible={ false }>
172+
{ __(
173+
'Some appearance settings may be overridden by the express payment section of the'
174+
) }{ ' ' }
175+
<a href={ checkoutPageUrl }>
176+
{ __( 'Cart & Checkout blocks.' ) }
177+
</a>
178+
</Notice>
161179
<h4>
162180
{ __(
163181
'Show express checkouts on',

package-lock.json

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"@stripe/react-stripe-js": "1.4.1",
9595
"@stripe/stripe-js": "^1.36.0",
9696
"@testing-library/react-hooks": "^7.0.2",
97+
"@woocommerce/settings": "^1.0.0",
9798
"framer-motion": "^7.6.1",
9899
"gridicons": "^3.4.0",
99100
"interpolate-components": "^1.1.1"

0 commit comments

Comments
 (0)