Skip to content

Commit 2cb4ac6

Browse files
update collect cdn urls (#1224)
* update collect cdn urls * add changeset * use apiHost to load poynt cdn * use apiHost for all env loading * use businessId from session * update changeset * prioritize config businessId
1 parent d23674c commit 2cb4ac6

File tree

12 files changed

+86
-782
lines changed

12 files changed

+86
-782
lines changed

.changeset/whole-horses-stare.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@godaddy/react": patch
3+
"@godaddy/localizations": patch
4+
---
5+
6+
- Update collect SDK CDN urls
7+
- Add localization keys for cart components
8+
- Optional businessId for GDP config (will pull from store data if not provided)

packages/react/src/components/checkout/checkout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export type StripeConfig = {
6565
};
6666

6767
export type GodaddyPaymentsConfig = {
68-
businessId: string;
68+
businessId?: string;
6969
appId: string;
7070
};
7171

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ export function ExpressCheckoutButton() {
367367
// couponConfig,
368368
// });
369369
collect.current = new (window as any).TokenizeJs(
370-
godaddyPaymentsConfig?.businessId,
370+
godaddyPaymentsConfig?.businessId || session?.businessId,
371371
godaddyPaymentsConfig?.appId,
372372
{
373373
country: countryCode,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export function PazeCheckoutButton() {
106106
) {
107107
// console.log("[poynt collect] Initializing TokenizeJs instance");
108108
collect.current = new (window as any).TokenizeJs(
109-
godaddyPaymentsConfig?.businessId,
109+
godaddyPaymentsConfig?.businessId || session?.businessId,
110110
godaddyPaymentsConfig?.appId,
111111
{
112112
country: countryCode,

packages/react/src/components/checkout/payment/payment-form.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export function PaymentForm(
155155
session?.paymentMethods?.paze?.processor === PaymentProvider.GODADDY
156156
) {
157157
collect.current = new (window as any).TokenizeJs(
158-
godaddyPaymentsConfig?.businessId,
158+
godaddyPaymentsConfig?.businessId || session?.businessId,
159159
godaddyPaymentsConfig?.appId,
160160
{
161161
country: countryCode,
@@ -178,6 +178,7 @@ export function PaymentForm(
178178
currencyCode,
179179
session?.paymentMethods?.paze?.processor,
180180
session?.storeName,
181+
session?.businessId,
181182
isPoyntLoaded,
182183
]);
183184

packages/react/src/components/checkout/payment/payment-methods/credit-card/godaddy.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { PaymentMethodType } from '@/types';
1616

1717
export function GoDaddyCreditCardForm() {
1818
const { t } = useGoDaddyContext();
19+
const { session } = useCheckoutContext();
1920
const { setCollect, setIsLoadingNonce } = usePoyntCollect();
2021
const { isPoyntLoaded } = useLoadPoyntCollect();
2122
const { godaddyPaymentsConfig, setCheckoutErrors } = useCheckoutContext();
@@ -189,7 +190,7 @@ export function GoDaddyCreditCardForm() {
189190
if (!isPoyntLoaded || !godaddyPaymentsConfig || collect.current) return;
190191

191192
collect.current = new (window as any).TokenizeJs(
192-
godaddyPaymentsConfig?.businessId,
193+
godaddyPaymentsConfig?.businessId || session?.businessId,
193194
godaddyPaymentsConfig?.appId
194195
);
195196

@@ -240,6 +241,7 @@ export function GoDaddyCreditCardForm() {
240241
setCheckoutErrors,
241242
t,
242243
setIsLoadingNonce,
244+
session?.businessId,
243245
]);
244246

245247
return (

packages/react/src/components/checkout/payment/utils/conditional-providers.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ export function ConditionalPaymentProviders({
2626
}
2727

2828
// Only wrap with PoyntCollectProvider (GoDaddy Payments) if configured
29-
if (
30-
godaddyPaymentsConfig?.businessId?.trim() &&
31-
godaddyPaymentsConfig?.appId?.trim()
32-
) {
29+
if (godaddyPaymentsConfig?.appId?.trim()) {
3330
wrappedChildren = (
3431
<PoyntCollectProvider>{wrappedChildren}</PoyntCollectProvider>
3532
);

packages/react/src/components/checkout/payment/utils/use-load-square.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { useEffect, useState } from 'react';
22
import { useCheckoutContext } from '@/components/checkout/checkout';
3-
import { useGetEnvFromContext } from '@/components/checkout/utils/use-get-env-from-context.ts';
3+
import { useGoDaddyContext } from '@/godaddy-provider.tsx';
44

55
let isSquareLoaded = false;
66
let isSquareCDNLoaded = false;
77
const listeners = new Set<(loaded: boolean) => void>();
88

99
export function useLoadSquare() {
1010
const { squareConfig } = useCheckoutContext();
11+
const { apiHost } = useGoDaddyContext();
1112
const [loaded, setLoaded] = useState(isSquareLoaded);
12-
const environment = useGetEnvFromContext();
1313

1414
const squareCDN =
15-
environment === 'prod'
15+
apiHost && !apiHost.includes('test') && !apiHost.includes('dev')
1616
? 'https://web.squarecdn.com/v1/square.js'
1717
: 'https://sandbox.web.squarecdn.com/v1/square.js';
1818

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import { useMemo } from 'react';
2-
import { useGetEnvFromContext } from '@/components/checkout/utils/use-get-env-from-context.ts';
2+
import { useGoDaddyContext } from '@/godaddy-provider.tsx';
33

44
export const useGetPoyntCollectCdn = () => {
5-
const environment = useGetEnvFromContext();
5+
const { apiHost } = useGoDaddyContext();
6+
const HOST = apiHost?.replace('api.', 'collect.commerce.') || '';
67

78
return useMemo(() => {
8-
switch (environment) {
9-
case 'prod':
10-
return 'https://cdn.poynt.net/collect.js';
11-
case 'test':
12-
return 'https://cdn.poynt.net/test/collect-test.js';
13-
case 'dev':
14-
return 'https://cdn.poynt.net/ci/collect-ci.js';
15-
default:
16-
return 'https://cdn.poynt.net/collect.js';
17-
}
18-
}, [environment]);
9+
return `https://${HOST}/sdk.js`;
10+
}, [apiHost]);
1911
};

packages/react/src/components/checkout/utils/use-get-env-from-context.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)