Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/nine-cooks-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@godaddy/react": patch
---

Fix bug where GDP tries to load before having session values
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export function ExpressCheckoutButton() {
if (
!collect.current &&
godaddyPaymentsConfig &&
(godaddyPaymentsConfig?.businessId || session?.businessId) &&
isPoyntLoaded &&
isCollectLoading &&
!hasMounted.current &&
Expand Down Expand Up @@ -404,7 +405,8 @@ export function ExpressCheckoutButton() {
!godaddyPaymentsConfig ||
!isCollectLoading ||
!collect.current ||
hasMounted.current
hasMounted.current ||
(!godaddyPaymentsConfig?.businessId && !session?.businessId)
)
return;

Expand Down Expand Up @@ -456,6 +458,7 @@ export function ExpressCheckoutButton() {
godaddyPaymentsConfig,
isCollectLoading,
handleExpressPayClick,
session?.businessId,
]);

// Function to convert shipping address to shippingLines format for price adjustments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export function PazeCheckoutButton() {
if (
!collect.current &&
godaddyPaymentsConfig &&
(godaddyPaymentsConfig?.businessId || session?.businessId) &&
isCollectLoading &&
isPoyntLoaded &&
!hasMounted.current
Expand Down Expand Up @@ -132,6 +133,7 @@ export function PazeCheckoutButton() {
if (
!isPoyntLoaded ||
!godaddyPaymentsConfig ||
(!godaddyPaymentsConfig?.businessId && !session?.businessId) ||
!isCollectLoading ||
!collect.current ||
hasMounted.current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export function PaymentForm(
if (
!collect.current &&
godaddyPaymentsConfig &&
(godaddyPaymentsConfig?.businessId || session?.businessId) &&
isPoyntLoaded &&
countryCode &&
currencyCode &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ export function GoDaddyCreditCardForm() {
const collect = useRef<TokenizeJs | null>(null);

useLayoutEffect(() => {
if (!isPoyntLoaded || !godaddyPaymentsConfig || collect.current) return;
if (
!isPoyntLoaded ||
!godaddyPaymentsConfig ||
collect.current ||
(!godaddyPaymentsConfig?.businessId && !session?.businessId)
)
return;

collect.current = new (window as any).TokenizeJs(
godaddyPaymentsConfig?.businessId || session?.businessId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const listeners = new Set<(loaded: boolean) => void>();
// load collect.js globally so it can be used for card component and Apple/G Pay buttons
export function useLoadPoyntCollect() {
const { godaddyPaymentsConfig } = useCheckoutContext();
const { session } = useCheckoutContext();
const collectCDN = useGetPoyntCollectCdn();
const [loaded, setLoaded] = useState(isPoyntLoaded);

Expand All @@ -32,7 +33,8 @@ export function useLoadPoyntCollect() {
isPoyntCDNLoaded ||
isPoyntLoaded ||
!godaddyPaymentsConfig ||
!collectCDN
!collectCDN ||
(!session?.businessId && !godaddyPaymentsConfig?.businessId)
) {
return;
}
Expand All @@ -48,7 +50,7 @@ export function useLoadPoyntCollect() {
};

document?.body?.appendChild(script);
}, [godaddyPaymentsConfig, collectCDN]);
}, [godaddyPaymentsConfig, collectCDN, session?.businessId]);

return { isPoyntLoaded: loaded };
}
2 changes: 2 additions & 0 deletions packages/react/src/lib/godaddy/checkout-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export const GetCheckoutSessionQuery = graphql(`
checkoutSession {
id
token
url
sourceApp
returnUrl
successUrl
storeId
channelId
businessId
customerId
storeName
environment
Expand Down