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
8 changes: 8 additions & 0 deletions .changeset/whole-horses-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@godaddy/react": patch
"@godaddy/localizations": patch
---

- Update collect SDK CDN urls
- Add localization keys for cart components
- Optional businessId for GDP config (will pull from store data if not provided)
2 changes: 1 addition & 1 deletion packages/react/src/components/checkout/checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type StripeConfig = {
};

export type GodaddyPaymentsConfig = {
businessId: string;
businessId?: string;
appId: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export function ExpressCheckoutButton() {
// couponConfig,
// });
collect.current = new (window as any).TokenizeJs(
godaddyPaymentsConfig?.businessId,
godaddyPaymentsConfig?.businessId || session?.businessId,
godaddyPaymentsConfig?.appId,
{
country: countryCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function PazeCheckoutButton() {
) {
// console.log("[poynt collect] Initializing TokenizeJs instance");
collect.current = new (window as any).TokenizeJs(
godaddyPaymentsConfig?.businessId,
godaddyPaymentsConfig?.businessId || session?.businessId,
godaddyPaymentsConfig?.appId,
{
country: countryCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function PaymentForm(
session?.paymentMethods?.paze?.processor === PaymentProvider.GODADDY
) {
collect.current = new (window as any).TokenizeJs(
godaddyPaymentsConfig?.businessId,
godaddyPaymentsConfig?.businessId || session?.businessId,
godaddyPaymentsConfig?.appId,
{
country: countryCode,
Expand All @@ -178,6 +178,7 @@ export function PaymentForm(
currencyCode,
session?.paymentMethods?.paze?.processor,
session?.storeName,
session?.businessId,
isPoyntLoaded,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { PaymentMethodType } from '@/types';

export function GoDaddyCreditCardForm() {
const { t } = useGoDaddyContext();
const { session } = useCheckoutContext();
const { setCollect, setIsLoadingNonce } = usePoyntCollect();
const { isPoyntLoaded } = useLoadPoyntCollect();
const { godaddyPaymentsConfig, setCheckoutErrors } = useCheckoutContext();
Expand Down Expand Up @@ -189,7 +190,7 @@ export function GoDaddyCreditCardForm() {
if (!isPoyntLoaded || !godaddyPaymentsConfig || collect.current) return;

collect.current = new (window as any).TokenizeJs(
godaddyPaymentsConfig?.businessId,
godaddyPaymentsConfig?.businessId || session?.businessId,
godaddyPaymentsConfig?.appId
);

Expand Down Expand Up @@ -240,6 +241,7 @@ export function GoDaddyCreditCardForm() {
setCheckoutErrors,
t,
setIsLoadingNonce,
session?.businessId,
]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ export function ConditionalPaymentProviders({
}

// Only wrap with PoyntCollectProvider (GoDaddy Payments) if configured
if (
godaddyPaymentsConfig?.businessId?.trim() &&
godaddyPaymentsConfig?.appId?.trim()
) {
if (godaddyPaymentsConfig?.appId?.trim()) {
wrappedChildren = (
<PoyntCollectProvider>{wrappedChildren}</PoyntCollectProvider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { useEffect, useState } from 'react';
import { useCheckoutContext } from '@/components/checkout/checkout';
import { useGetEnvFromContext } from '@/components/checkout/utils/use-get-env-from-context.ts';
import { useGoDaddyContext } from '@/godaddy-provider.tsx';

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

export function useLoadSquare() {
const { squareConfig } = useCheckoutContext();
const { apiHost } = useGoDaddyContext();
const [loaded, setLoaded] = useState(isSquareLoaded);
const environment = useGetEnvFromContext();

const squareCDN =
environment === 'prod'
apiHost && !apiHost.includes('test') && !apiHost.includes('dev')
? 'https://web.squarecdn.com/v1/square.js'
: 'https://sandbox.web.squarecdn.com/v1/square.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { useMemo } from 'react';
import { useGetEnvFromContext } from '@/components/checkout/utils/use-get-env-from-context.ts';
import { useGoDaddyContext } from '@/godaddy-provider.tsx';

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

return useMemo(() => {
switch (environment) {
case 'prod':
return 'https://cdn.poynt.net/collect.js';
case 'test':
return 'https://cdn.poynt.net/test/collect-test.js';
case 'dev':
return 'https://cdn.poynt.net/ci/collect-ci.js';
default:
return 'https://cdn.poynt.net/collect.js';
}
}, [environment]);
return `https://${HOST}/sdk.js`;
}, [apiHost]);
};

This file was deleted.

Loading