Skip to content

Commit f24654b

Browse files
Stripe express for apple and google pay (#1298)
* add apple pay for stripe * allow google and apple pay for stripe * update stripe express settings * use default trasaction error if stripe errors * add changeset * remove https dev
1 parent 58d748f commit f24654b

6 files changed

Lines changed: 890 additions & 127 deletions

File tree

.changeset/gentle-crabs-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@godaddy/react": patch
3+
---
4+
5+
Add google and apple pay stripe express payment methods

packages/react/src/components/checkout/payment/checkout-buttons/express/godaddy.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
PaymentProvider,
3131
useConfirmCheckout,
3232
} from '@/components/checkout/payment/utils/use-confirm-checkout';
33+
import { useIsPaymentDisabled } from '@/components/checkout/payment/utils/use-is-payment-disabled';
3334
import { useLoadPoyntCollect } from '@/components/checkout/payment/utils/use-load-poynt-collect';
3435
import { filterAndSortShippingMethods } from '@/components/checkout/shipping/utils/filter-shipping-methods';
3536
import { useGetShippingMethodByAddress } from '@/components/checkout/shipping/utils/use-get-shipping-methods';
@@ -53,8 +54,12 @@ import type { CalculatedAdjustments, CalculatedTaxes } from '@/types';
5354
export function ExpressCheckoutButton() {
5455
const formatCurrency = useFormatCurrency();
5556
const convertMajorToMinorUnits = useConvertMajorToMinorUnits();
56-
const { session, setCheckoutErrors } = useCheckoutContext();
57+
const { session, setCheckoutErrors, isConfirmingCheckout } =
58+
useCheckoutContext();
59+
const isPaymentDisabled = useIsPaymentDisabled();
5760
const { isPoyntLoaded } = useLoadPoyntCollect();
61+
62+
const isDisabled = isConfirmingCheckout || isPaymentDisabled;
5863
const { godaddyPaymentsConfig } = useCheckoutContext();
5964
const { t } = useGoDaddyContext();
6065
const [isCollectLoading, setIsCollectLoading] = useState(true);
@@ -183,6 +188,10 @@ export function ExpressCheckoutButton() {
183188

184189
const handleExpressPayClick = useCallback(
185190
async ({ source }: { source?: 'apple_pay' | 'google_pay' | 'paze' }) => {
191+
if (isDisabled) {
192+
return;
193+
}
194+
186195
// Read from refs to get current values (avoid stale closure)
187196
const currentCouponCode = appliedCouponCodeRef.current;
188197
const currentAdjustments = calculatedAdjustmentsRef.current;
@@ -292,6 +301,7 @@ export function ExpressCheckoutButton() {
292301
currencyCode,
293302
totals,
294303
formatCurrency,
304+
isDisabled,
295305
]
296306
);
297307

@@ -1475,7 +1485,10 @@ export function ExpressCheckoutButton() {
14751485

14761486
return (
14771487
<>
1478-
<div id='gdpay-express-pay-element' />
1488+
<div
1489+
id='gdpay-express-pay-element'
1490+
className={isDisabled ? 'opacity-50 pointer-events-none' : undefined}
1491+
/>
14791492
{isCollectLoading ? (
14801493
<div className='grid gap-1 grid-cols-1 sm:grid-cols-2'>
14811494
<Skeleton className='h-12 w-full mb-1' />

0 commit comments

Comments
 (0)