@@ -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' ;
3334import { useLoadPoyntCollect } from '@/components/checkout/payment/utils/use-load-poynt-collect' ;
3435import { filterAndSortShippingMethods } from '@/components/checkout/shipping/utils/filter-shipping-methods' ;
3536import { useGetShippingMethodByAddress } from '@/components/checkout/shipping/utils/use-get-shipping-methods' ;
@@ -53,8 +54,12 @@ import type { CalculatedAdjustments, CalculatedTaxes } from '@/types';
5354export 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