File tree Expand file tree Collapse file tree 12 files changed +86
-782
lines changed
payment-methods/credit-card Expand file tree Collapse file tree 12 files changed +86
-782
lines changed Original file line number Diff line number Diff line change 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)
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ export type StripeConfig = {
6565} ;
6666
6767export type GodaddyPaymentsConfig = {
68- businessId : string ;
68+ businessId ? : string ;
6969 appId : string ;
7070} ;
7171
Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { PaymentMethodType } from '@/types';
1616
1717export 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 (
Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff line change 11import { useEffect , useState } from 'react' ;
22import { 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
55let isSquareLoaded = false ;
66let isSquareCDNLoaded = false ;
77const listeners = new Set < ( loaded : boolean ) => void > ( ) ;
88
99export 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
Original file line number Diff line number Diff line change 11import { useMemo } from 'react' ;
2- import { useGetEnvFromContext } from '@/components/checkout/utils/use-get-env-from-context.ts ' ;
2+ import { useGoDaddyContext } from '@/godaddy-provider.tsx ' ;
33
44export 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} ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments