Skip to content
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

Integrate express payments buttonAttributes API from the Checkout Block #3164

Merged
merged 18 commits into from
Sep 4, 2024
Merged
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
9 changes: 7 additions & 2 deletions client/blocks/payment-request/payment-request-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const PaymentRequestExpressComponent = ( {
onClick,
onClose,
setExpressPaymentError,
buttonAttributes,
} ) => {
const stripe = useStripe();
const { needsShipping } = shippingData;
Expand Down Expand Up @@ -71,20 +72,24 @@ const PaymentRequestExpressComponent = ( {

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

// If we are on the checkout block, we receive button attributes which overwrite the extension specific settings
if ( typeof buttonAttributes !== 'undefined' ) {
height = buttonAttributes.height || height;
}

const paymentRequestButtonStyle = {
paymentRequestButton: {
type,
theme,
height: `${ height }px`,
},
};

const isBranded = getBlocksConfiguration()?.button?.is_branded;
const brandedType = getBlocksConfiguration()?.button?.branded_type;
const isCustom = getBlocksConfiguration()?.button?.is_custom;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ADMIN_URL, getSetting } from '@woocommerce/settings';
import { __ } from '@wordpress/i18n';
import React, { useMemo } from 'react';
import { Card, RadioControl, CheckboxControl } from '@wordpress/components';
import {
Card,
RadioControl,
CheckboxControl,
Notice,
} from '@wordpress/components';
import interpolateComponents from 'interpolate-components';
import { Elements } from '@stripe/react-stripe-js';
import { loadStripe } from '@stripe/stripe-js';
Expand Down Expand Up @@ -155,9 +161,21 @@ const PaymentRequestsSettingsSection = () => {
}
};

const checkoutPageUrl = `${ ADMIN_URL }post.php?post=${
getSetting( 'storePages' )?.checkout?.id
}&action=edit`;

return (
<Card className="express-checkout-settings">
<CardBody>
<Notice status="warning" isDismissible={ false }>
{ __(
'Some appearance settings may be overridden by the express payment section of the'
) }{ ' ' }
<a href={ checkoutPageUrl }>
{ __( 'Cart & Checkout blocks.' ) }
</a>
</Notice>
<h4>
{ __(
'Show express checkouts on',
Expand Down
49 changes: 49 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"@stripe/react-stripe-js": "1.4.1",
"@stripe/stripe-js": "^1.36.0",
"@testing-library/react-hooks": "^7.0.2",
"@woocommerce/settings": "^1.0.0",
"framer-motion": "^7.6.1",
"gridicons": "^3.4.0",
"interpolate-components": "^1.1.1"
Expand Down
Loading