@tagadapay/plugin-sdk 3.1.25 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1129 -1129
- package/build-cdn.js +499 -499
- package/dist/external-tracker.js +5 -5
- package/dist/external-tracker.min.js +2 -2
- package/dist/external-tracker.min.js.map +2 -2
- package/dist/react/config/payment.d.ts +2 -2
- package/dist/react/config/payment.js +5 -5
- package/dist/react/hooks/usePayment.d.ts +7 -0
- package/dist/react/hooks/usePayment.js +1 -0
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/tagada-react-sdk-minimal.min.js +2 -2
- package/dist/tagada-react-sdk-minimal.min.js.map +4 -4
- package/dist/tagada-react-sdk.js +1616 -1275
- package/dist/tagada-react-sdk.min.js +2 -2
- package/dist/tagada-react-sdk.min.js.map +4 -4
- package/dist/tagada-sdk.js +869 -27
- package/dist/tagada-sdk.min.js +2 -2
- package/dist/tagada-sdk.min.js.map +4 -4
- package/dist/v2/core/config/environment.d.ts +3 -3
- package/dist/v2/core/config/environment.js +7 -7
- package/dist/v2/core/funnelClient.d.ts +2 -0
- package/dist/v2/core/resources/funnel.d.ts +1 -1
- package/dist/v2/core/resources/geo.d.ts +50 -0
- package/dist/v2/core/resources/geo.js +35 -0
- package/dist/v2/core/resources/payments.d.ts +19 -1
- package/dist/v2/core/resources/payments.js +8 -0
- package/dist/v2/core/utils/previewModeIndicator.js +101 -101
- package/dist/v2/react/components/FunnelScriptInjector.js +167 -19
- package/dist/v2/react/components/StripeExpressButton.d.ts +8 -0
- package/dist/v2/react/components/StripeExpressButton.js +22 -1
- package/dist/v2/react/hooks/payment-actions/useNgeniusThreedsAction.d.ts +15 -0
- package/dist/v2/react/hooks/payment-actions/useNgeniusThreedsAction.js +166 -0
- package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +12 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +1 -0
- package/dist/v2/react/hooks/useISOData.js +25 -7
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +1 -1
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -4
- package/dist/v2/react/providers/TagadaProvider.js +5 -5
- package/dist/v2/standalone/apple-pay-service.d.ts +12 -0
- package/dist/v2/standalone/apple-pay-service.js +12 -0
- package/dist/v2/standalone/external-tracker.d.ts +1 -1
- package/dist/v2/standalone/google-pay-service.d.ts +9 -0
- package/dist/v2/standalone/google-pay-service.js +9 -0
- package/dist/v2/standalone/index.d.ts +8 -1
- package/dist/v2/standalone/index.js +7 -0
- package/dist/v2/standalone/payment-service.d.ts +18 -5
- package/dist/v2/standalone/payment-service.js +62 -9
- package/package.json +115 -114
package/dist/tagada-sdk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TagadaPay SDK
|
|
2
|
+
* TagadaPay SDK v4.0.0
|
|
3
3
|
* CDN Bundle - Full standalone SDK (Debug Build)
|
|
4
4
|
* Usage: window.tgd.createTagadaClient(), window.tgd.formatMoney(), etc.
|
|
5
5
|
* @license MIT
|
|
@@ -182,10 +182,10 @@ var TagadaSDKBundle = (() => {
|
|
|
182
182
|
}
|
|
183
183
|
return "local";
|
|
184
184
|
}
|
|
185
|
-
if (hostname
|
|
185
|
+
if (hostname.includes("tagada.io") || hostname.includes("tagadapay.com") || hostname.includes("yourproductiondomain.com")) {
|
|
186
186
|
return "production";
|
|
187
187
|
}
|
|
188
|
-
if (hostname
|
|
188
|
+
if (hostname.includes("tagada.dev") || hostname.includes("tagadapay.dev") || hostname.includes("vercel.app") || hostname.includes("netlify.app") || hostname.includes("surge.sh") || hostname.includes("github.io") || hostname.includes("herokuapp.com") || hostname.includes("railway.app") || href.includes("?env=dev") || href.includes("?dev=true") || href.includes("#dev")) {
|
|
189
189
|
return "development";
|
|
190
190
|
}
|
|
191
191
|
console.warn("[SDK] Unknown domain: ".concat(hostname, ", defaulting to production"));
|
|
@@ -207,7 +207,7 @@ var TagadaSDKBundle = (() => {
|
|
|
207
207
|
"use strict";
|
|
208
208
|
ENVIRONMENT_CONFIGS = {
|
|
209
209
|
production: {
|
|
210
|
-
baseUrl: "https://
|
|
210
|
+
baseUrl: "https://api.tagada.io",
|
|
211
211
|
endpoints: {
|
|
212
212
|
checkout: {
|
|
213
213
|
sessionInit: "/api/v1/checkout/session/init",
|
|
@@ -225,7 +225,7 @@ var TagadaSDKBundle = (() => {
|
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
227
|
development: {
|
|
228
|
-
baseUrl: "https://
|
|
228
|
+
baseUrl: "https://api.tagada.dev",
|
|
229
229
|
endpoints: {
|
|
230
230
|
checkout: {
|
|
231
231
|
sessionInit: "/api/v1/checkout/session/init",
|
|
@@ -7569,7 +7569,7 @@ var TagadaSDKBundle = (() => {
|
|
|
7569
7569
|
debug: false,
|
|
7570
7570
|
appInfo: {}
|
|
7571
7571
|
};
|
|
7572
|
-
var
|
|
7572
|
+
var BasisTheory2 = class {
|
|
7573
7573
|
constructor() {
|
|
7574
7574
|
_defineProperty(this, "_initStatus", "not-started");
|
|
7575
7575
|
}
|
|
@@ -7780,7 +7780,7 @@ var TagadaSDKBundle = (() => {
|
|
|
7780
7780
|
this._elements = elements;
|
|
7781
7781
|
}
|
|
7782
7782
|
};
|
|
7783
|
-
exports.BasisTheory =
|
|
7783
|
+
exports.BasisTheory = BasisTheory2;
|
|
7784
7784
|
}
|
|
7785
7785
|
});
|
|
7786
7786
|
|
|
@@ -8399,8 +8399,10 @@ var TagadaSDKBundle = (() => {
|
|
|
8399
8399
|
CurrencyUtils: () => CurrencyUtils,
|
|
8400
8400
|
ExpressPaymentMethodsResource: () => ExpressPaymentMethodsResource,
|
|
8401
8401
|
FunnelActionType: () => FunnelActionType,
|
|
8402
|
+
GeoResource: () => GeoResource,
|
|
8402
8403
|
GoogleAutocompleteCore: () => GoogleAutocompleteCore,
|
|
8403
8404
|
ISODataCore: () => ISODataCore,
|
|
8405
|
+
OffersResource: () => OffersResource,
|
|
8404
8406
|
OrderBumpUtils: () => OrderBumpUtils,
|
|
8405
8407
|
OrderUtils: () => OrderUtils,
|
|
8406
8408
|
OrdersResource: () => OrdersResource,
|
|
@@ -8432,7 +8434,7 @@ var TagadaSDKBundle = (() => {
|
|
|
8432
8434
|
funnelQueryKeys: () => funnelQueryKeys,
|
|
8433
8435
|
getAssignedPaymentFlowId: () => getAssignedPaymentFlowId,
|
|
8434
8436
|
getAssignedStepConfig: () => getAssignedStepConfig,
|
|
8435
|
-
getBasisTheoryApiKey: () =>
|
|
8437
|
+
getBasisTheoryApiKey: () => getBasisTheoryApiKey3,
|
|
8436
8438
|
getBasisTheoryTenantId: () => getBasisTheoryTenantId2,
|
|
8437
8439
|
getFunnelSessionCookie: () => getFunnelSessionCookie,
|
|
8438
8440
|
getFunnelVariantId: () => getFunnelVariantId,
|
|
@@ -8441,13 +8443,17 @@ var TagadaSDKBundle = (() => {
|
|
|
8441
8443
|
getPluginConfig: () => getPluginConfig,
|
|
8442
8444
|
hasFunnelSessionCookie: () => hasFunnelSessionCookie,
|
|
8443
8445
|
injectStepConfigScripts: () => injectStepConfigScripts,
|
|
8446
|
+
isApplePayAvailable: () => isApplePayAvailable,
|
|
8447
|
+
isGooglePayAvailable: () => isGooglePayAvailable,
|
|
8444
8448
|
isPathRemapped: () => isPathRemapped,
|
|
8445
8449
|
loadLocalConfig: () => loadLocalConfig,
|
|
8446
8450
|
loadPluginConfig: () => loadPluginConfig,
|
|
8447
8451
|
matchRoute: () => matchRoute,
|
|
8448
8452
|
onConfigUpdate: () => onConfigUpdate,
|
|
8449
8453
|
sendConfigUpdate: () => sendConfigUpdate,
|
|
8450
|
-
setFunnelSessionCookie: () => setFunnelSessionCookie
|
|
8454
|
+
setFunnelSessionCookie: () => setFunnelSessionCookie,
|
|
8455
|
+
startApplePaySession: () => startApplePaySession,
|
|
8456
|
+
startGooglePaySession: () => startGooglePaySession
|
|
8451
8457
|
});
|
|
8452
8458
|
|
|
8453
8459
|
// src/v2/core/client.ts
|
|
@@ -10545,8 +10551,8 @@ var TagadaSDKBundle = (() => {
|
|
|
10545
10551
|
if (hostname.includes("app-dev.tagadapay.com") || hostname.includes("cdn-dev.tagadapay.com")) {
|
|
10546
10552
|
return false;
|
|
10547
10553
|
}
|
|
10548
|
-
if (hostname.includes("tagadapay.com")) return true;
|
|
10549
|
-
if (hostname.includes("tagadapay.dev")) return false;
|
|
10554
|
+
if (hostname.includes("tagada.io") || hostname.includes("tagadapay.com")) return true;
|
|
10555
|
+
if (hostname.includes("tagada.dev") || hostname.includes("tagadapay.dev")) return false;
|
|
10550
10556
|
if (hostname === "localhost" || hostname.startsWith("127.") || hostname.startsWith("192.168.") || hostname.startsWith("10.") || hostname.includes(".local") || hostname === "" || hostname === "0.0.0.0" || hostname.includes("ngrok") || hostname.includes(".loclx.io") || hostname.includes("vercel.app") || hostname.includes("netlify.app")) {
|
|
10551
10557
|
return false;
|
|
10552
10558
|
}
|
|
@@ -10741,10 +10747,10 @@ var TagadaSDKBundle = (() => {
|
|
|
10741
10747
|
console.log("[PaymentsResource] Full options object:", JSON.stringify(options, null, 2));
|
|
10742
10748
|
console.log("[PaymentsResource] processorId:", options.processorId, "paymentMethod:", options.paymentMethod);
|
|
10743
10749
|
try {
|
|
10744
|
-
const requestBody = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
10750
|
+
const requestBody = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
10745
10751
|
checkoutSessionId,
|
|
10746
10752
|
paymentInstrumentId
|
|
10747
|
-
}, threedsSessionId && { threedsSessionId }), options.initiatedBy && { initiatedBy: options.initiatedBy }), options.source && { source: options.source }), options.paymentFlowId && { paymentFlowId: options.paymentFlowId }), options.processorId && { processorId: options.processorId }), options.paymentMethod && { paymentMethod: options.paymentMethod }), options.isExpress && { isExpress: options.isExpress });
|
|
10753
|
+
}, threedsSessionId && { threedsSessionId }), options.initiatedBy && { initiatedBy: options.initiatedBy }), options.source && { source: options.source }), options.paymentFlowId && { paymentFlowId: options.paymentFlowId }), options.processorId && { processorId: options.processorId }), options.paymentMethod && { paymentMethod: options.paymentMethod }), options.isExpress && { isExpress: options.isExpress }), options.shippingRateId && { shippingRateId: options.shippingRateId });
|
|
10748
10754
|
console.log("[PaymentsResource] Request body being sent:", JSON.stringify(requestBody, null, 2));
|
|
10749
10755
|
const response = await this.apiClient.post("/api/public/v1/checkout/pay-v2", requestBody);
|
|
10750
10756
|
console.log("[PaymentsResource] processPaymentDirect SUCCESS:", response);
|
|
@@ -10801,6 +10807,13 @@ var TagadaSDKBundle = (() => {
|
|
|
10801
10807
|
async updateThreedsStatus(data) {
|
|
10802
10808
|
return this.apiClient.post("/api/v1/threeds/status", data);
|
|
10803
10809
|
}
|
|
10810
|
+
/**
|
|
10811
|
+
* Complete N-Genius payment after WebSDK 3DS flow finishes.
|
|
10812
|
+
* Verifies state from N-Genius server-side and updates the payment record.
|
|
10813
|
+
*/
|
|
10814
|
+
async ngeniusThreedsComplete(data) {
|
|
10815
|
+
return this.apiClient.post("/api/v1/payments/ngenius/threeds-complete", data);
|
|
10816
|
+
}
|
|
10804
10817
|
};
|
|
10805
10818
|
|
|
10806
10819
|
// src/v2/core/resources/orders.ts
|
|
@@ -10855,6 +10868,280 @@ var TagadaSDKBundle = (() => {
|
|
|
10855
10868
|
}
|
|
10856
10869
|
};
|
|
10857
10870
|
|
|
10871
|
+
// src/v2/core/resources/offers.ts
|
|
10872
|
+
init_previewMode();
|
|
10873
|
+
var OffersResource = class {
|
|
10874
|
+
constructor(apiClient) {
|
|
10875
|
+
this.apiClient = apiClient;
|
|
10876
|
+
}
|
|
10877
|
+
/**
|
|
10878
|
+
* Get a single offer by ID
|
|
10879
|
+
*/
|
|
10880
|
+
async getOfferById(offerId) {
|
|
10881
|
+
const response = await this.apiClient.get("/api/v1/offers/".concat(offerId));
|
|
10882
|
+
return response;
|
|
10883
|
+
}
|
|
10884
|
+
/**
|
|
10885
|
+
* Get offers for a store
|
|
10886
|
+
* @param storeId - Store ID
|
|
10887
|
+
* @param offerIds - Optional array of offer IDs to filter by
|
|
10888
|
+
*/
|
|
10889
|
+
async getOffers(storeId, offerIds) {
|
|
10890
|
+
let url = "/api/v1/stores/".concat(storeId, "/offers");
|
|
10891
|
+
if (offerIds && offerIds.length > 0) {
|
|
10892
|
+
const idsParam = offerIds.map((id) => "ids=".concat(encodeURIComponent(id))).join("&");
|
|
10893
|
+
url += "?".concat(idsParam);
|
|
10894
|
+
}
|
|
10895
|
+
const response = await this.apiClient.get(url);
|
|
10896
|
+
return response.offers || [];
|
|
10897
|
+
}
|
|
10898
|
+
/**
|
|
10899
|
+
* Get offers by IDs (now uses backend filtering for better performance)
|
|
10900
|
+
*/
|
|
10901
|
+
async getOffersByIds(storeId, offerIds) {
|
|
10902
|
+
return await this.getOffers(storeId, offerIds);
|
|
10903
|
+
}
|
|
10904
|
+
/**
|
|
10905
|
+
* Preview an offer with calculated summary (no checkout session creation)
|
|
10906
|
+
* @param offerId - Offer ID
|
|
10907
|
+
* @param currency - Currency code
|
|
10908
|
+
* @param lineItems - Optional line items with variant/quantity selections
|
|
10909
|
+
* - Use lineItemId for precise updates (same product, different variants)
|
|
10910
|
+
* - Use productId for simple updates (all items with this product)
|
|
10911
|
+
*/
|
|
10912
|
+
async previewOffer(offerId, currency = "", lineItems) {
|
|
10913
|
+
console.log("\u{1F4E1} [OffersResource] Calling preview API:", {
|
|
10914
|
+
offerId,
|
|
10915
|
+
currency,
|
|
10916
|
+
lineItems,
|
|
10917
|
+
endpoint: "/api/v1/offers/".concat(offerId, "/preview")
|
|
10918
|
+
});
|
|
10919
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/preview"), {
|
|
10920
|
+
offerId,
|
|
10921
|
+
currency,
|
|
10922
|
+
lineItems
|
|
10923
|
+
});
|
|
10924
|
+
console.log("\u{1F4E5} [OffersResource] Preview API response:", response);
|
|
10925
|
+
return response;
|
|
10926
|
+
}
|
|
10927
|
+
/**
|
|
10928
|
+
* Preview and pay for an offer with variant selections
|
|
10929
|
+
* Combines preview + checkout session creation in one call
|
|
10930
|
+
* @param offerId - Offer ID
|
|
10931
|
+
* @param currency - Currency code
|
|
10932
|
+
* @param lineItems - Line items with variant/quantity selections
|
|
10933
|
+
* @param returnUrl - Optional return URL for checkout
|
|
10934
|
+
* @param mainOrderId - Optional main order ID (for upsells)
|
|
10935
|
+
*/
|
|
10936
|
+
async payPreviewedOffer(offerId, currency = "", lineItems, returnUrl, mainOrderId) {
|
|
10937
|
+
console.log("\u{1F4B3} [OffersResource] Calling pay-preview API:", {
|
|
10938
|
+
offerId,
|
|
10939
|
+
currency,
|
|
10940
|
+
lineItems,
|
|
10941
|
+
returnUrl,
|
|
10942
|
+
mainOrderId,
|
|
10943
|
+
endpoint: "/api/v1/offers/".concat(offerId, "/pay-preview")
|
|
10944
|
+
});
|
|
10945
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay-preview"), {
|
|
10946
|
+
offerId,
|
|
10947
|
+
currency,
|
|
10948
|
+
lineItems,
|
|
10949
|
+
returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.href : ""),
|
|
10950
|
+
mainOrderId
|
|
10951
|
+
});
|
|
10952
|
+
console.log("\u{1F4E5} [OffersResource] Pay-preview API response:", response);
|
|
10953
|
+
return response;
|
|
10954
|
+
}
|
|
10955
|
+
/**
|
|
10956
|
+
* Create checkout session from previewed offer WITHOUT paying
|
|
10957
|
+
* Used for landing pages to prepare checkout before actual payment
|
|
10958
|
+
* @param offerId - Offer ID
|
|
10959
|
+
* @param currency - Currency code
|
|
10960
|
+
* @param lineItems - Line items with variant/quantity selections
|
|
10961
|
+
* @param returnUrl - Optional return URL for checkout
|
|
10962
|
+
* @param mainOrderId - Optional main order ID
|
|
10963
|
+
*/
|
|
10964
|
+
async toCheckout(offerId, currency = "", lineItems, returnUrl, mainOrderId) {
|
|
10965
|
+
console.log("\u{1F6D2} [OffersResource] Calling to-checkout API:", {
|
|
10966
|
+
offerId,
|
|
10967
|
+
currency,
|
|
10968
|
+
lineItems,
|
|
10969
|
+
returnUrl,
|
|
10970
|
+
mainOrderId,
|
|
10971
|
+
endpoint: "/api/v1/offers/".concat(offerId, "/to-checkout")
|
|
10972
|
+
});
|
|
10973
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/to-checkout"), {
|
|
10974
|
+
offerId,
|
|
10975
|
+
currency,
|
|
10976
|
+
lineItems,
|
|
10977
|
+
returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.href : ""),
|
|
10978
|
+
mainOrderId
|
|
10979
|
+
});
|
|
10980
|
+
console.log("\u{1F4E5} [OffersResource] To-checkout API response:", response);
|
|
10981
|
+
return response;
|
|
10982
|
+
}
|
|
10983
|
+
/**
|
|
10984
|
+
* Initialize checkout session for an offer
|
|
10985
|
+
* @param offerId - Offer ID (required)
|
|
10986
|
+
* @param orderId - Order ID (optional - used for post-purchase upsells)
|
|
10987
|
+
* @param customerId - Customer ID (optional)
|
|
10988
|
+
*/
|
|
10989
|
+
async initCheckoutSession(offerId, orderId, customerId) {
|
|
10990
|
+
const draft = isDraftMode();
|
|
10991
|
+
const payload = {
|
|
10992
|
+
offerId,
|
|
10993
|
+
returnUrl: typeof window !== "undefined" ? window.location.href : "",
|
|
10994
|
+
customerId: customerId || "",
|
|
10995
|
+
draft
|
|
10996
|
+
// 🎯 Pass draft mode
|
|
10997
|
+
};
|
|
10998
|
+
if (orderId) {
|
|
10999
|
+
payload.orderId = orderId;
|
|
11000
|
+
}
|
|
11001
|
+
const response = await this.apiClient.post("/api/v1/checkout/offer/init", payload);
|
|
11002
|
+
return { checkoutSessionId: response.checkoutSessionId };
|
|
11003
|
+
}
|
|
11004
|
+
/**
|
|
11005
|
+
* Create checkout session for an offer
|
|
11006
|
+
*/
|
|
11007
|
+
async createCheckoutSession(offerId, returnUrl) {
|
|
11008
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/checkout"), {
|
|
11009
|
+
returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.origin : "")
|
|
11010
|
+
});
|
|
11011
|
+
return { checkoutUrl: response.checkoutUrl };
|
|
11012
|
+
}
|
|
11013
|
+
/**
|
|
11014
|
+
* Pay with checkout session
|
|
11015
|
+
*/
|
|
11016
|
+
async payWithCheckoutSession(checkoutSessionId, orderId) {
|
|
11017
|
+
const draft = isDraftMode();
|
|
11018
|
+
await this.apiClient.post("/api/v1/checkout-sessions/".concat(checkoutSessionId, "/pay"), {
|
|
11019
|
+
checkoutSessionId,
|
|
11020
|
+
draft,
|
|
11021
|
+
// 🎯 Use dynamic draft mode instead of hardcoded false
|
|
11022
|
+
returnUrl: typeof window !== "undefined" ? window.location.href : "",
|
|
11023
|
+
metadata: {
|
|
11024
|
+
comingFromPostPurchase: true,
|
|
11025
|
+
postOrder: orderId,
|
|
11026
|
+
upsell: true,
|
|
11027
|
+
source: "offer"
|
|
11028
|
+
}
|
|
11029
|
+
});
|
|
11030
|
+
}
|
|
11031
|
+
/**
|
|
11032
|
+
* Pay for an offer directly
|
|
11033
|
+
*/
|
|
11034
|
+
async payOffer(offerId, orderId) {
|
|
11035
|
+
const draft = isDraftMode();
|
|
11036
|
+
return this.apiClient.post("/api/v1/offers/".concat(offerId, "/pay"), {
|
|
11037
|
+
offerId,
|
|
11038
|
+
draft,
|
|
11039
|
+
// 🎯 Use dynamic draft mode instead of hardcoded false
|
|
11040
|
+
returnUrl: typeof window !== "undefined" ? window.location.href : "",
|
|
11041
|
+
metadata: orderId ? {
|
|
11042
|
+
comingFromPostPurchase: true,
|
|
11043
|
+
postOrder: orderId,
|
|
11044
|
+
upsell: true,
|
|
11045
|
+
source: "offer"
|
|
11046
|
+
} : {
|
|
11047
|
+
upsell: true,
|
|
11048
|
+
source: "offer"
|
|
11049
|
+
}
|
|
11050
|
+
});
|
|
11051
|
+
}
|
|
11052
|
+
/**
|
|
11053
|
+
* Transform offer to checkout session with dynamic variant selection
|
|
11054
|
+
* Uses lineItems from the offer to create a new checkout session
|
|
11055
|
+
*/
|
|
11056
|
+
async transformToCheckoutSession(offerId, lineItems, mainOrderId, returnUrl) {
|
|
11057
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/transform-to-checkout"), {
|
|
11058
|
+
offerId,
|
|
11059
|
+
lineItems,
|
|
11060
|
+
mainOrderId,
|
|
11061
|
+
returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.origin : "")
|
|
11062
|
+
});
|
|
11063
|
+
return {
|
|
11064
|
+
checkoutUrl: response.checkoutUrl,
|
|
11065
|
+
checkoutSessionId: response.checkoutSessionId,
|
|
11066
|
+
customerId: response.customerId
|
|
11067
|
+
};
|
|
11068
|
+
}
|
|
11069
|
+
/**
|
|
11070
|
+
* Transform offer to checkout session (async mode) ⚡
|
|
11071
|
+
* Response time: ~50ms (20-50x faster!)
|
|
11072
|
+
*
|
|
11073
|
+
* Returns checkoutToken immediately, background job completes processing.
|
|
11074
|
+
* Use getCheckout() to fetch full session data - it auto-waits for completion.
|
|
11075
|
+
*
|
|
11076
|
+
* @example
|
|
11077
|
+
* // Fast transform
|
|
11078
|
+
* const { checkoutToken } = await offers.toCheckoutAsync(offerId, currency, lineItems, returnUrl, mainOrderId);
|
|
11079
|
+
*
|
|
11080
|
+
* // Redirect user immediately
|
|
11081
|
+
* window.location.href = `/checkout/${checkoutToken}/op`;
|
|
11082
|
+
*
|
|
11083
|
+
* // By the time page loads, background processing is usually complete
|
|
11084
|
+
*/
|
|
11085
|
+
async toCheckoutAsync(offerId, currency = "", lineItems, returnUrl, mainOrderId) {
|
|
11086
|
+
console.log("\u{1F6D2} [OffersResource] Calling to-checkout-async API:", {
|
|
11087
|
+
offerId,
|
|
11088
|
+
currency,
|
|
11089
|
+
lineItems,
|
|
11090
|
+
returnUrl,
|
|
11091
|
+
mainOrderId,
|
|
11092
|
+
endpoint: "/api/v1/offers/".concat(offerId, "/to-checkout-async")
|
|
11093
|
+
});
|
|
11094
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/to-checkout-async"), {
|
|
11095
|
+
offerId,
|
|
11096
|
+
lineItems: (lineItems == null ? void 0 : lineItems.map((item) => ({
|
|
11097
|
+
variantId: item.variantId,
|
|
11098
|
+
quantity: item.quantity
|
|
11099
|
+
}))) || [],
|
|
11100
|
+
returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.href : ""),
|
|
11101
|
+
mainOrderId: mainOrderId || ""
|
|
11102
|
+
});
|
|
11103
|
+
console.log("\u{1F4E5} [OffersResource] To-checkout-async API response:", response);
|
|
11104
|
+
return response;
|
|
11105
|
+
}
|
|
11106
|
+
/**
|
|
11107
|
+
* @deprecated Use transformToCheckoutSession instead
|
|
11108
|
+
* Transform offer to checkout session with dynamic variant selection
|
|
11109
|
+
*/
|
|
11110
|
+
async transformToCheckout(offerId, returnUrl) {
|
|
11111
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/transform-to-checkout"), {
|
|
11112
|
+
returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.origin : "")
|
|
11113
|
+
});
|
|
11114
|
+
return { checkoutUrl: response.checkoutUrl };
|
|
11115
|
+
}
|
|
11116
|
+
/**
|
|
11117
|
+
* Initialize checkout session for an offer with variants (similar to postPurchases)
|
|
11118
|
+
*/
|
|
11119
|
+
async initCheckoutSessionWithVariants(offerId, lineItems, returnUrl) {
|
|
11120
|
+
const response = await this.apiClient.post("/api/v1/offers/".concat(offerId, "/transform-to-checkout"), {
|
|
11121
|
+
offerId,
|
|
11122
|
+
lineItems,
|
|
11123
|
+
returnUrl: returnUrl || (typeof window !== "undefined" ? window.location.href : "")
|
|
11124
|
+
});
|
|
11125
|
+
return { checkoutSessionId: response.checkoutSessionId };
|
|
11126
|
+
}
|
|
11127
|
+
/**
|
|
11128
|
+
* Get order summary for a checkout session
|
|
11129
|
+
*/
|
|
11130
|
+
async getOrderSummary(sessionId, includeVariantOptions = false) {
|
|
11131
|
+
return this.apiClient.post("/api/v1/checkout-sessions/".concat(sessionId, "/order-summary"), {
|
|
11132
|
+
includeVariantOptions
|
|
11133
|
+
});
|
|
11134
|
+
}
|
|
11135
|
+
/**
|
|
11136
|
+
* Update line items for a checkout session
|
|
11137
|
+
*/
|
|
11138
|
+
async updateLineItems(sessionId, lineItems) {
|
|
11139
|
+
return this.apiClient.post("/api/v1/checkout-sessions/".concat(sessionId, "/line-items"), {
|
|
11140
|
+
lineItems
|
|
11141
|
+
});
|
|
11142
|
+
}
|
|
11143
|
+
};
|
|
11144
|
+
|
|
10858
11145
|
// src/v2/core/resources/expressPaymentMethods.ts
|
|
10859
11146
|
var ExpressPaymentMethodsResource = class {
|
|
10860
11147
|
constructor(apiClient) {
|
|
@@ -10896,6 +11183,38 @@ var TagadaSDKBundle = (() => {
|
|
|
10896
11183
|
}
|
|
10897
11184
|
};
|
|
10898
11185
|
|
|
11186
|
+
// src/v2/core/resources/geo.ts
|
|
11187
|
+
var GeoResource = class {
|
|
11188
|
+
constructor(apiClient) {
|
|
11189
|
+
this.apiClient = apiClient;
|
|
11190
|
+
}
|
|
11191
|
+
/**
|
|
11192
|
+
* Get geolocation data from the visitor's IP address
|
|
11193
|
+
*/
|
|
11194
|
+
async getGeoLocation() {
|
|
11195
|
+
return this.apiClient.get("/api/v1/geo");
|
|
11196
|
+
}
|
|
11197
|
+
/**
|
|
11198
|
+
* Get geolocation data for a specific IP address
|
|
11199
|
+
*/
|
|
11200
|
+
async getGeoLocationByIp(ip) {
|
|
11201
|
+
return this.apiClient.get("/api/v1/geo?ip=".concat(encodeURIComponent(ip)));
|
|
11202
|
+
}
|
|
11203
|
+
/**
|
|
11204
|
+
* Convenience: get just the country code from IP geolocation
|
|
11205
|
+
* Returns ISO 3166-1 alpha-2 code (e.g. 'US', 'FR') or null
|
|
11206
|
+
*/
|
|
11207
|
+
async detectCountry() {
|
|
11208
|
+
try {
|
|
11209
|
+
const data = await this.getGeoLocation();
|
|
11210
|
+
const code = data == null ? void 0 : data.country_code;
|
|
11211
|
+
return code && typeof code === "string" && code.length === 2 ? code : null;
|
|
11212
|
+
} catch (e) {
|
|
11213
|
+
return null;
|
|
11214
|
+
}
|
|
11215
|
+
}
|
|
11216
|
+
};
|
|
11217
|
+
|
|
10899
11218
|
// src/v2/core/resources/threeds.ts
|
|
10900
11219
|
var ThreedsResource = class {
|
|
10901
11220
|
constructor(apiClient) {
|
|
@@ -12212,8 +12531,8 @@ var TagadaSDKBundle = (() => {
|
|
|
12212
12531
|
this.btInitPromise = (async () => {
|
|
12213
12532
|
try {
|
|
12214
12533
|
const apiKey = getBasisTheoryApiKey();
|
|
12215
|
-
const { BasisTheory } = await Promise.resolve().then(() => __toESM(require_basis_theory_js()));
|
|
12216
|
-
const bt = await new
|
|
12534
|
+
const { BasisTheory: BasisTheory2 } = await Promise.resolve().then(() => __toESM(require_basis_theory_js()));
|
|
12535
|
+
const bt = await new BasisTheory2().init(apiKey, { elements: false });
|
|
12217
12536
|
this.basisTheory = bt;
|
|
12218
12537
|
console.log("[PaymentService] BasisTheory initialized");
|
|
12219
12538
|
return this.basisTheory;
|
|
@@ -12333,7 +12652,8 @@ var TagadaSDKBundle = (() => {
|
|
|
12333
12652
|
source: (extra == null ? void 0 : extra.source) || "checkout",
|
|
12334
12653
|
paymentFlowId,
|
|
12335
12654
|
processorId: extra == null ? void 0 : extra.processorId,
|
|
12336
|
-
paymentMethod: extra == null ? void 0 : extra.paymentMethod
|
|
12655
|
+
paymentMethod: extra == null ? void 0 : extra.paymentMethod,
|
|
12656
|
+
shippingRateId: extra == null ? void 0 : extra.shippingRateId
|
|
12337
12657
|
}
|
|
12338
12658
|
);
|
|
12339
12659
|
console.log("[PaymentService] Payment response:", {
|
|
@@ -12426,6 +12746,9 @@ var TagadaSDKBundle = (() => {
|
|
|
12426
12746
|
const redirectUrl = ((_c = (_b = actionData.metadata) == null ? void 0 : _b.redirect) == null ? void 0 : _c.redirectUrl) || actionData.redirectUrl || actionData.url;
|
|
12427
12747
|
if (redirectUrl) {
|
|
12428
12748
|
console.log("[PaymentService] Redirecting:", redirectUrl);
|
|
12749
|
+
if (this.callbacks.onBeforeRedirect) {
|
|
12750
|
+
await this.callbacks.onBeforeRedirect(payment, redirectUrl);
|
|
12751
|
+
}
|
|
12429
12752
|
window.location.href = redirectUrl;
|
|
12430
12753
|
} else if (payment.status === "succeeded") {
|
|
12431
12754
|
(_e = (_d = this.callbacks).onProcessing) == null ? void 0 : _e.call(_d, false);
|
|
@@ -12467,6 +12790,9 @@ var TagadaSDKBundle = (() => {
|
|
|
12467
12790
|
case "mastercard_auth":
|
|
12468
12791
|
await this.handleMasterCardAuth(payment, actionData);
|
|
12469
12792
|
break;
|
|
12793
|
+
case "ngenius_3ds":
|
|
12794
|
+
await this.handleNgeniusThreeds(payment, actionData);
|
|
12795
|
+
break;
|
|
12470
12796
|
default: {
|
|
12471
12797
|
console.log("[PaymentService] Unhandled action, starting polling:", actionData.type);
|
|
12472
12798
|
this.startPolling(payment.id, {
|
|
@@ -12635,6 +12961,52 @@ var TagadaSDKBundle = (() => {
|
|
|
12635
12961
|
}
|
|
12636
12962
|
}
|
|
12637
12963
|
// --------------------------------------------------------------------------
|
|
12964
|
+
// N-Genius 3DS (WebSDK)
|
|
12965
|
+
// --------------------------------------------------------------------------
|
|
12966
|
+
async handleNgeniusThreeds(payment, actionData) {
|
|
12967
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
12968
|
+
const sdk = (_a = actionData.metadata) == null ? void 0 : _a.sdk;
|
|
12969
|
+
if (!(sdk == null ? void 0 : sdk.paymentResponse) || !sdk.orderReference || !sdk.paymentReference) {
|
|
12970
|
+
(_c = (_b = this.callbacks).onError) == null ? void 0 : _c.call(_b, "N-Genius 3DS: missing SDK metadata");
|
|
12971
|
+
(_e = (_d = this.callbacks).onProcessing) == null ? void 0 : _e.call(_d, false);
|
|
12972
|
+
return;
|
|
12973
|
+
}
|
|
12974
|
+
try {
|
|
12975
|
+
const sdkUrl = sdk.isSandboxed ? "https://paypage.sandbox.ngenius-payments.com/hosted-sessions/sdk.js" : "https://paypage.ngenius-payments.com/hosted-sessions/sdk.js";
|
|
12976
|
+
if (!document.getElementById("ngenius-websdk")) {
|
|
12977
|
+
await new Promise((resolve, reject) => {
|
|
12978
|
+
const script = document.createElement("script");
|
|
12979
|
+
script.id = "ngenius-websdk";
|
|
12980
|
+
script.src = sdkUrl;
|
|
12981
|
+
script.onload = () => resolve();
|
|
12982
|
+
script.onerror = () => reject(new Error("Failed to load N-Genius WebSDK"));
|
|
12983
|
+
document.head.appendChild(script);
|
|
12984
|
+
});
|
|
12985
|
+
}
|
|
12986
|
+
const NI = window.NI;
|
|
12987
|
+
if (!(NI == null ? void 0 : NI.handlePaymentResponse)) {
|
|
12988
|
+
throw new Error("N-Genius WebSDK did not expose window.NI.handlePaymentResponse");
|
|
12989
|
+
}
|
|
12990
|
+
console.log("[N-Genius 3DS] Starting WebSDK challenge");
|
|
12991
|
+
const outcome = await NI.handlePaymentResponse(
|
|
12992
|
+
sdk.paymentResponse,
|
|
12993
|
+
{ mountId: "ngenius-3ds-container", style: { width: "100%", height: 500 } }
|
|
12994
|
+
);
|
|
12995
|
+
console.log("[N-Genius 3DS] WebSDK outcome:", outcome.status);
|
|
12996
|
+
const completedPayment = await this.paymentsResource.ngeniusThreedsComplete({
|
|
12997
|
+
paymentId: payment.id,
|
|
12998
|
+
orderReference: sdk.orderReference,
|
|
12999
|
+
paymentReference: sdk.paymentReference
|
|
13000
|
+
});
|
|
13001
|
+
await this.handleResumedPayment(completedPayment);
|
|
13002
|
+
} catch (error) {
|
|
13003
|
+
const msg = error instanceof Error ? error.message : "N-Genius 3DS failed";
|
|
13004
|
+
console.error("[N-Genius 3DS] Error:", error);
|
|
13005
|
+
(_g = (_f = this.callbacks).onError) == null ? void 0 : _g.call(_f, msg);
|
|
13006
|
+
(_i = (_h = this.callbacks).onProcessing) == null ? void 0 : _i.call(_h, false);
|
|
13007
|
+
}
|
|
13008
|
+
}
|
|
13009
|
+
// --------------------------------------------------------------------------
|
|
12638
13010
|
// Airwallex Radar
|
|
12639
13011
|
// --------------------------------------------------------------------------
|
|
12640
13012
|
async handleAirwallexRadar(payment, actionData) {
|
|
@@ -12959,7 +13331,7 @@ var TagadaSDKBundle = (() => {
|
|
|
12959
13331
|
// ==========================================================================
|
|
12960
13332
|
// PAYMENT PROCESSING (all methods)
|
|
12961
13333
|
// ==========================================================================
|
|
12962
|
-
async processCardPayment(checkoutSessionId, cardData) {
|
|
13334
|
+
async processCardPayment(checkoutSessionId, cardData, options) {
|
|
12963
13335
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
12964
13336
|
(_b = (_a = this.callbacks).onProcessing) == null ? void 0 : _b.call(_a, true);
|
|
12965
13337
|
(_d = (_c = this.callbacks).onError) == null ? void 0 : _d.call(_c, null);
|
|
@@ -12979,7 +13351,7 @@ var TagadaSDKBundle = (() => {
|
|
|
12979
13351
|
} catch (e) {
|
|
12980
13352
|
}
|
|
12981
13353
|
}
|
|
12982
|
-
return await this.processAndHandle(checkoutSessionId, instrument.id, threedsSessionId);
|
|
13354
|
+
return await this.processAndHandle(checkoutSessionId, instrument.id, threedsSessionId, { shippingRateId: options == null ? void 0 : options.shippingRateId });
|
|
12983
13355
|
} catch (error) {
|
|
12984
13356
|
const msg = error instanceof Error ? error.message : String(error);
|
|
12985
13357
|
(_g = (_f = this.callbacks).onError) == null ? void 0 : _g.call(_f, msg);
|
|
@@ -12987,13 +13359,13 @@ var TagadaSDKBundle = (() => {
|
|
|
12987
13359
|
return { success: false, error: msg };
|
|
12988
13360
|
}
|
|
12989
13361
|
}
|
|
12990
|
-
async processApplePayPayment(checkoutSessionId, applePayToken) {
|
|
13362
|
+
async processApplePayPayment(checkoutSessionId, applePayToken, options) {
|
|
12991
13363
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
12992
13364
|
(_b = (_a = this.callbacks).onProcessing) == null ? void 0 : _b.call(_a, true);
|
|
12993
13365
|
(_d = (_c = this.callbacks).onError) == null ? void 0 : _d.call(_c, null);
|
|
12994
13366
|
try {
|
|
12995
13367
|
const instrument = await this.createApplePayPaymentInstrument(applePayToken);
|
|
12996
|
-
return await this.processAndHandle(checkoutSessionId, instrument.id);
|
|
13368
|
+
return await this.processAndHandle(checkoutSessionId, instrument.id, void 0, { shippingRateId: options == null ? void 0 : options.shippingRateId });
|
|
12997
13369
|
} catch (error) {
|
|
12998
13370
|
const msg = error instanceof Error ? error.message : String(error);
|
|
12999
13371
|
(_f = (_e = this.callbacks).onError) == null ? void 0 : _f.call(_e, msg);
|
|
@@ -13001,13 +13373,13 @@ var TagadaSDKBundle = (() => {
|
|
|
13001
13373
|
return { success: false, error: msg };
|
|
13002
13374
|
}
|
|
13003
13375
|
}
|
|
13004
|
-
async processGooglePayPayment(checkoutSessionId, googlePayToken) {
|
|
13376
|
+
async processGooglePayPayment(checkoutSessionId, googlePayToken, options) {
|
|
13005
13377
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13006
13378
|
(_b = (_a = this.callbacks).onProcessing) == null ? void 0 : _b.call(_a, true);
|
|
13007
13379
|
(_d = (_c = this.callbacks).onError) == null ? void 0 : _d.call(_c, null);
|
|
13008
13380
|
try {
|
|
13009
13381
|
const instrument = await this.createGooglePayPaymentInstrument(googlePayToken);
|
|
13010
|
-
return await this.processAndHandle(checkoutSessionId, instrument.id);
|
|
13382
|
+
return await this.processAndHandle(checkoutSessionId, instrument.id, void 0, { shippingRateId: options == null ? void 0 : options.shippingRateId });
|
|
13011
13383
|
} catch (error) {
|
|
13012
13384
|
const msg = error instanceof Error ? error.message : String(error);
|
|
13013
13385
|
(_f = (_e = this.callbacks).onError) == null ? void 0 : _f.call(_e, msg);
|
|
@@ -13015,12 +13387,12 @@ var TagadaSDKBundle = (() => {
|
|
|
13015
13387
|
return { success: false, error: msg };
|
|
13016
13388
|
}
|
|
13017
13389
|
}
|
|
13018
|
-
async processPaymentWithInstrument(checkoutSessionId, paymentInstrumentId) {
|
|
13390
|
+
async processPaymentWithInstrument(checkoutSessionId, paymentInstrumentId, options) {
|
|
13019
13391
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13020
13392
|
(_b = (_a = this.callbacks).onProcessing) == null ? void 0 : _b.call(_a, true);
|
|
13021
13393
|
(_d = (_c = this.callbacks).onError) == null ? void 0 : _d.call(_c, null);
|
|
13022
13394
|
try {
|
|
13023
|
-
return await this.processAndHandle(checkoutSessionId, paymentInstrumentId);
|
|
13395
|
+
return await this.processAndHandle(checkoutSessionId, paymentInstrumentId, void 0, { shippingRateId: options == null ? void 0 : options.shippingRateId });
|
|
13024
13396
|
} catch (error) {
|
|
13025
13397
|
const msg = error instanceof Error ? error.message : String(error);
|
|
13026
13398
|
(_f = (_e = this.callbacks).onError) == null ? void 0 : _f.call(_e, msg);
|
|
@@ -13028,7 +13400,7 @@ var TagadaSDKBundle = (() => {
|
|
|
13028
13400
|
return { success: false, error: msg };
|
|
13029
13401
|
}
|
|
13030
13402
|
}
|
|
13031
|
-
async processApmPayment(checkoutSessionId, apmData) {
|
|
13403
|
+
async processApmPayment(checkoutSessionId, apmData, options) {
|
|
13032
13404
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13033
13405
|
(_b = (_a = this.callbacks).onProcessing) == null ? void 0 : _b.call(_a, true);
|
|
13034
13406
|
(_d = (_c = this.callbacks).onError) == null ? void 0 : _d.call(_c, null);
|
|
@@ -13037,7 +13409,8 @@ var TagadaSDKBundle = (() => {
|
|
|
13037
13409
|
processorId: apmData.processorId,
|
|
13038
13410
|
paymentMethod: apmData.paymentMethod,
|
|
13039
13411
|
initiatedBy: apmData.initiatedBy,
|
|
13040
|
-
source: apmData.source
|
|
13412
|
+
source: apmData.source,
|
|
13413
|
+
shippingRateId: options == null ? void 0 : options.shippingRateId
|
|
13041
13414
|
});
|
|
13042
13415
|
} catch (error) {
|
|
13043
13416
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -13048,6 +13421,475 @@ var TagadaSDKBundle = (() => {
|
|
|
13048
13421
|
}
|
|
13049
13422
|
};
|
|
13050
13423
|
|
|
13424
|
+
// ../core-js/dist/core/providers/BasisTheoryProvider.js
|
|
13425
|
+
var import_basis_theory_js = __toESM(require_basis_theory_js());
|
|
13426
|
+
|
|
13427
|
+
// ../core-js/dist/radar/types.js
|
|
13428
|
+
var AirwallexRadarErrorCode;
|
|
13429
|
+
(function(AirwallexRadarErrorCode2) {
|
|
13430
|
+
AirwallexRadarErrorCode2["SCRIPT_LOAD_FAILED"] = "SCRIPT_LOAD_FAILED";
|
|
13431
|
+
AirwallexRadarErrorCode2["SESSION_SAVE_FAILED"] = "SESSION_SAVE_FAILED";
|
|
13432
|
+
AirwallexRadarErrorCode2["RESUME_FAILED"] = "RESUME_FAILED";
|
|
13433
|
+
AirwallexRadarErrorCode2["NO_API_CLIENT"] = "NO_API_CLIENT";
|
|
13434
|
+
AirwallexRadarErrorCode2["SSR_NOT_SUPPORTED"] = "SSR_NOT_SUPPORTED";
|
|
13435
|
+
})(AirwallexRadarErrorCode || (AirwallexRadarErrorCode = {}));
|
|
13436
|
+
|
|
13437
|
+
// ../core-js/dist/payments/types.js
|
|
13438
|
+
var PaymentsClientErrorCode;
|
|
13439
|
+
(function(PaymentsClientErrorCode2) {
|
|
13440
|
+
PaymentsClientErrorCode2["CONTINUE_PAYMENT_FAILED"] = "CONTINUE_PAYMENT_FAILED";
|
|
13441
|
+
PaymentsClientErrorCode2["MISSING_PAYMENT_ID"] = "MISSING_PAYMENT_ID";
|
|
13442
|
+
})(PaymentsClientErrorCode || (PaymentsClientErrorCode = {}));
|
|
13443
|
+
|
|
13444
|
+
// ../core-js/dist/payments/apple-pay-service.js
|
|
13445
|
+
var APPLE_PAY_SDK_URL = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
|
|
13446
|
+
var APPLE_PAY_SESSION_VERSION = 3;
|
|
13447
|
+
var sdkLoadPromise = null;
|
|
13448
|
+
function loadApplePaySdk() {
|
|
13449
|
+
if (sdkLoadPromise)
|
|
13450
|
+
return sdkLoadPromise;
|
|
13451
|
+
if (typeof window === "undefined") {
|
|
13452
|
+
return Promise.reject(new Error("[ApplePayService] No window \u2014 not in browser"));
|
|
13453
|
+
}
|
|
13454
|
+
if (window.ApplePaySession) {
|
|
13455
|
+
sdkLoadPromise = Promise.resolve();
|
|
13456
|
+
return sdkLoadPromise;
|
|
13457
|
+
}
|
|
13458
|
+
const existing = document.querySelector('script[src="'.concat(APPLE_PAY_SDK_URL, '"]'));
|
|
13459
|
+
if (existing) {
|
|
13460
|
+
sdkLoadPromise = new Promise((resolve) => {
|
|
13461
|
+
if (window.ApplePaySession)
|
|
13462
|
+
return resolve();
|
|
13463
|
+
existing.addEventListener("load", () => resolve());
|
|
13464
|
+
const check = setInterval(() => {
|
|
13465
|
+
if (window.ApplePaySession) {
|
|
13466
|
+
clearInterval(check);
|
|
13467
|
+
resolve();
|
|
13468
|
+
}
|
|
13469
|
+
}, 100);
|
|
13470
|
+
setTimeout(() => {
|
|
13471
|
+
clearInterval(check);
|
|
13472
|
+
resolve();
|
|
13473
|
+
}, 5e3);
|
|
13474
|
+
});
|
|
13475
|
+
return sdkLoadPromise;
|
|
13476
|
+
}
|
|
13477
|
+
sdkLoadPromise = new Promise((resolve, reject) => {
|
|
13478
|
+
const script = document.createElement("script");
|
|
13479
|
+
script.src = APPLE_PAY_SDK_URL;
|
|
13480
|
+
script.crossOrigin = "anonymous";
|
|
13481
|
+
script.async = true;
|
|
13482
|
+
script.onload = () => resolve();
|
|
13483
|
+
script.onerror = () => {
|
|
13484
|
+
sdkLoadPromise = null;
|
|
13485
|
+
reject(new Error("[ApplePayService] Failed to load Apple Pay SDK"));
|
|
13486
|
+
};
|
|
13487
|
+
document.head.appendChild(script);
|
|
13488
|
+
});
|
|
13489
|
+
return sdkLoadPromise;
|
|
13490
|
+
}
|
|
13491
|
+
async function isApplePayAvailable() {
|
|
13492
|
+
try {
|
|
13493
|
+
await loadApplePaySdk();
|
|
13494
|
+
const ApplePaySession = window.ApplePaySession;
|
|
13495
|
+
return !!ApplePaySession && ApplePaySession.canMakePayments();
|
|
13496
|
+
} catch (e) {
|
|
13497
|
+
return false;
|
|
13498
|
+
}
|
|
13499
|
+
}
|
|
13500
|
+
async function validateMerchant(basisTheoryApiKey, displayName, domain) {
|
|
13501
|
+
const response = await fetch("https://api.basistheory.com/apple-pay/session", {
|
|
13502
|
+
method: "POST",
|
|
13503
|
+
headers: {
|
|
13504
|
+
"Content-Type": "application/json",
|
|
13505
|
+
"BT-API-KEY": basisTheoryApiKey
|
|
13506
|
+
},
|
|
13507
|
+
body: JSON.stringify({
|
|
13508
|
+
display_name: displayName,
|
|
13509
|
+
domain
|
|
13510
|
+
})
|
|
13511
|
+
});
|
|
13512
|
+
if (!response.ok) {
|
|
13513
|
+
throw new Error("[ApplePayService] Merchant validation failed: HTTP ".concat(response.status));
|
|
13514
|
+
}
|
|
13515
|
+
return response.json();
|
|
13516
|
+
}
|
|
13517
|
+
async function tokenizeApplePayPayment(basisTheoryApiKey, paymentToken) {
|
|
13518
|
+
const response = await fetch("https://api.basistheory.com/apple-pay", {
|
|
13519
|
+
method: "POST",
|
|
13520
|
+
headers: {
|
|
13521
|
+
"Content-Type": "application/json",
|
|
13522
|
+
"BT-API-KEY": basisTheoryApiKey
|
|
13523
|
+
},
|
|
13524
|
+
body: JSON.stringify({
|
|
13525
|
+
apple_payment_data: paymentToken
|
|
13526
|
+
})
|
|
13527
|
+
});
|
|
13528
|
+
if (!response.ok) {
|
|
13529
|
+
throw new Error("[ApplePayService] Tokenization failed: HTTP ".concat(response.status));
|
|
13530
|
+
}
|
|
13531
|
+
const result = await response.json();
|
|
13532
|
+
return result.apple_pay;
|
|
13533
|
+
}
|
|
13534
|
+
function minorToDecimal(amountMinor, currency) {
|
|
13535
|
+
const zeroDecimal = [
|
|
13536
|
+
"BIF",
|
|
13537
|
+
"CLP",
|
|
13538
|
+
"DJF",
|
|
13539
|
+
"GNF",
|
|
13540
|
+
"JPY",
|
|
13541
|
+
"KMF",
|
|
13542
|
+
"KRW",
|
|
13543
|
+
"MGA",
|
|
13544
|
+
"PYG",
|
|
13545
|
+
"RWF",
|
|
13546
|
+
"UGX",
|
|
13547
|
+
"VND",
|
|
13548
|
+
"VUV",
|
|
13549
|
+
"XAF",
|
|
13550
|
+
"XOF",
|
|
13551
|
+
"XPF"
|
|
13552
|
+
];
|
|
13553
|
+
if (zeroDecimal.includes(currency.toUpperCase())) {
|
|
13554
|
+
return String(amountMinor);
|
|
13555
|
+
}
|
|
13556
|
+
return (amountMinor / 100).toFixed(2);
|
|
13557
|
+
}
|
|
13558
|
+
function startApplePaySession(config, request, callbacks) {
|
|
13559
|
+
var _a, _b;
|
|
13560
|
+
const ApplePaySession = window.ApplePaySession;
|
|
13561
|
+
if (!ApplePaySession) {
|
|
13562
|
+
(_a = callbacks.onError) == null ? void 0 : _a.call(callbacks, "Apple Pay is not available on this device");
|
|
13563
|
+
return;
|
|
13564
|
+
}
|
|
13565
|
+
const countryCode = config.countryCode || "US";
|
|
13566
|
+
const storeName = config.storeName || "Store";
|
|
13567
|
+
const totalStr = minorToDecimal(request.totalAmountMinor, request.currency);
|
|
13568
|
+
const applePayRequest = {
|
|
13569
|
+
countryCode,
|
|
13570
|
+
currencyCode: request.currency,
|
|
13571
|
+
supportedNetworks: ["visa", "masterCard", "amex", "discover"],
|
|
13572
|
+
merchantCapabilities: ["supports3DS"],
|
|
13573
|
+
total: {
|
|
13574
|
+
label: storeName,
|
|
13575
|
+
amount: totalStr,
|
|
13576
|
+
type: "final"
|
|
13577
|
+
},
|
|
13578
|
+
requiredShippingContactFields: ["name", "phone", "email", "postalAddress"],
|
|
13579
|
+
requiredBillingContactFields: ["postalAddress"]
|
|
13580
|
+
};
|
|
13581
|
+
if (request.lineItems) {
|
|
13582
|
+
applePayRequest.lineItems = request.lineItems.map((li) => __spreadProps(__spreadValues({}, li), { type: "final" }));
|
|
13583
|
+
}
|
|
13584
|
+
if (request.shippingMethods) {
|
|
13585
|
+
applePayRequest.shippingMethods = request.shippingMethods;
|
|
13586
|
+
}
|
|
13587
|
+
try {
|
|
13588
|
+
const session = new ApplePaySession(APPLE_PAY_SESSION_VERSION, applePayRequest);
|
|
13589
|
+
session.onvalidatemerchant = () => {
|
|
13590
|
+
void (async () => {
|
|
13591
|
+
var _a2;
|
|
13592
|
+
try {
|
|
13593
|
+
const merchantSession = await validateMerchant(config.basisTheoryApiKey, storeName, window.location.host);
|
|
13594
|
+
session.completeMerchantValidation(merchantSession);
|
|
13595
|
+
} catch (err) {
|
|
13596
|
+
console.error("[ApplePayService] Merchant validation failed:", err);
|
|
13597
|
+
session.abort();
|
|
13598
|
+
(_a2 = callbacks.onError) == null ? void 0 : _a2.call(callbacks, "Merchant validation failed");
|
|
13599
|
+
}
|
|
13600
|
+
})();
|
|
13601
|
+
};
|
|
13602
|
+
session.onpaymentauthorized = (event) => {
|
|
13603
|
+
void (async () => {
|
|
13604
|
+
var _a2;
|
|
13605
|
+
try {
|
|
13606
|
+
const token = await tokenizeApplePayPayment(config.basisTheoryApiKey, event.payment.token);
|
|
13607
|
+
session.completePayment(ApplePaySession.STATUS_SUCCESS);
|
|
13608
|
+
await callbacks.onSuccess(token, {
|
|
13609
|
+
shipping: event.payment.shippingContact,
|
|
13610
|
+
billing: event.payment.billingContact
|
|
13611
|
+
});
|
|
13612
|
+
} catch (err) {
|
|
13613
|
+
console.error("[ApplePayService] Payment processing failed:", err);
|
|
13614
|
+
session.completePayment(ApplePaySession.STATUS_FAILURE);
|
|
13615
|
+
(_a2 = callbacks.onError) == null ? void 0 : _a2.call(callbacks, "Payment failed");
|
|
13616
|
+
}
|
|
13617
|
+
})();
|
|
13618
|
+
};
|
|
13619
|
+
if (callbacks.onShippingContactSelected) {
|
|
13620
|
+
session.onshippingcontactselected = (event) => {
|
|
13621
|
+
void (async () => {
|
|
13622
|
+
try {
|
|
13623
|
+
const result = await callbacks.onShippingContactSelected(event.shippingContact);
|
|
13624
|
+
if (!result) {
|
|
13625
|
+
session.abort();
|
|
13626
|
+
return;
|
|
13627
|
+
}
|
|
13628
|
+
session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS, result.shippingMethods || [], __spreadProps(__spreadValues({}, result.total), { type: "final" }), result.lineItems.map((li) => __spreadProps(__spreadValues({}, li), { type: "final" })));
|
|
13629
|
+
} catch (e) {
|
|
13630
|
+
session.abort();
|
|
13631
|
+
}
|
|
13632
|
+
})();
|
|
13633
|
+
};
|
|
13634
|
+
}
|
|
13635
|
+
if (callbacks.onShippingMethodSelected) {
|
|
13636
|
+
session.onshippingmethodselected = (event) => {
|
|
13637
|
+
void (async () => {
|
|
13638
|
+
try {
|
|
13639
|
+
const result = await callbacks.onShippingMethodSelected(event.shippingMethod.identifier);
|
|
13640
|
+
if (!result) {
|
|
13641
|
+
session.abort();
|
|
13642
|
+
return;
|
|
13643
|
+
}
|
|
13644
|
+
session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS, __spreadProps(__spreadValues({}, result.total), { type: "final" }), result.lineItems.map((li) => __spreadProps(__spreadValues({}, li), { type: "final" })));
|
|
13645
|
+
} catch (e) {
|
|
13646
|
+
session.abort();
|
|
13647
|
+
}
|
|
13648
|
+
})();
|
|
13649
|
+
};
|
|
13650
|
+
}
|
|
13651
|
+
session.oncancel = () => {
|
|
13652
|
+
var _a2;
|
|
13653
|
+
(_a2 = callbacks.onCancel) == null ? void 0 : _a2.call(callbacks);
|
|
13654
|
+
};
|
|
13655
|
+
session.onerror = (event) => {
|
|
13656
|
+
var _a2;
|
|
13657
|
+
console.error("[ApplePayService] Session error:", event);
|
|
13658
|
+
(_a2 = callbacks.onError) == null ? void 0 : _a2.call(callbacks, "Apple Pay session error");
|
|
13659
|
+
};
|
|
13660
|
+
session.begin();
|
|
13661
|
+
} catch (err) {
|
|
13662
|
+
console.error("[ApplePayService] Failed to start Apple Pay session:", err);
|
|
13663
|
+
(_b = callbacks.onError) == null ? void 0 : _b.call(callbacks, "Failed to start Apple Pay");
|
|
13664
|
+
}
|
|
13665
|
+
}
|
|
13666
|
+
|
|
13667
|
+
// ../core-js/dist/payments/google-pay-service.js
|
|
13668
|
+
var GOOGLE_PAY_SDK_URL = "https://pay.google.com/gp/p/js/pay.js";
|
|
13669
|
+
var sdkLoadPromise2 = null;
|
|
13670
|
+
function loadGooglePaySdk() {
|
|
13671
|
+
var _a, _b, _c;
|
|
13672
|
+
if (sdkLoadPromise2)
|
|
13673
|
+
return sdkLoadPromise2;
|
|
13674
|
+
if (typeof window === "undefined") {
|
|
13675
|
+
return Promise.reject(new Error("[GooglePayService] No window \u2014 not in browser"));
|
|
13676
|
+
}
|
|
13677
|
+
if ((_c = (_b = (_a = window.google) == null ? void 0 : _a.payments) == null ? void 0 : _b.api) == null ? void 0 : _c.PaymentsClient) {
|
|
13678
|
+
sdkLoadPromise2 = Promise.resolve();
|
|
13679
|
+
return sdkLoadPromise2;
|
|
13680
|
+
}
|
|
13681
|
+
const existing = document.querySelector('script[src="'.concat(GOOGLE_PAY_SDK_URL, '"]'));
|
|
13682
|
+
if (existing) {
|
|
13683
|
+
sdkLoadPromise2 = new Promise((resolve) => {
|
|
13684
|
+
var _a2, _b2, _c2;
|
|
13685
|
+
if ((_c2 = (_b2 = (_a2 = window.google) == null ? void 0 : _a2.payments) == null ? void 0 : _b2.api) == null ? void 0 : _c2.PaymentsClient)
|
|
13686
|
+
return resolve();
|
|
13687
|
+
existing.addEventListener("load", () => resolve());
|
|
13688
|
+
const check = setInterval(() => {
|
|
13689
|
+
var _a3, _b3, _c3;
|
|
13690
|
+
if ((_c3 = (_b3 = (_a3 = window.google) == null ? void 0 : _a3.payments) == null ? void 0 : _b3.api) == null ? void 0 : _c3.PaymentsClient) {
|
|
13691
|
+
clearInterval(check);
|
|
13692
|
+
resolve();
|
|
13693
|
+
}
|
|
13694
|
+
}, 100);
|
|
13695
|
+
setTimeout(() => {
|
|
13696
|
+
clearInterval(check);
|
|
13697
|
+
resolve();
|
|
13698
|
+
}, 5e3);
|
|
13699
|
+
});
|
|
13700
|
+
return sdkLoadPromise2;
|
|
13701
|
+
}
|
|
13702
|
+
sdkLoadPromise2 = new Promise((resolve, reject) => {
|
|
13703
|
+
const script = document.createElement("script");
|
|
13704
|
+
script.src = GOOGLE_PAY_SDK_URL;
|
|
13705
|
+
script.async = true;
|
|
13706
|
+
script.onload = () => resolve();
|
|
13707
|
+
script.onerror = () => {
|
|
13708
|
+
sdkLoadPromise2 = null;
|
|
13709
|
+
reject(new Error("[GooglePayService] Failed to load Google Pay SDK"));
|
|
13710
|
+
};
|
|
13711
|
+
document.head.appendChild(script);
|
|
13712
|
+
});
|
|
13713
|
+
return sdkLoadPromise2;
|
|
13714
|
+
}
|
|
13715
|
+
var BASE_CARD_PAYMENT_METHOD = {
|
|
13716
|
+
type: "CARD",
|
|
13717
|
+
parameters: {
|
|
13718
|
+
allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
|
|
13719
|
+
allowedCardNetworks: ["VISA", "MASTERCARD", "AMEX", "DISCOVER", "JCB"]
|
|
13720
|
+
}
|
|
13721
|
+
};
|
|
13722
|
+
async function isGooglePayAvailable(sandboxed = false) {
|
|
13723
|
+
var _a, _b, _c;
|
|
13724
|
+
try {
|
|
13725
|
+
await loadGooglePaySdk();
|
|
13726
|
+
const PaymentsClient2 = (_c = (_b = (_a = window.google) == null ? void 0 : _a.payments) == null ? void 0 : _b.api) == null ? void 0 : _c.PaymentsClient;
|
|
13727
|
+
if (!PaymentsClient2)
|
|
13728
|
+
return false;
|
|
13729
|
+
const client = new PaymentsClient2({
|
|
13730
|
+
environment: sandboxed ? "TEST" : "PRODUCTION"
|
|
13731
|
+
});
|
|
13732
|
+
const result = await client.isReadyToPay({
|
|
13733
|
+
apiVersion: 2,
|
|
13734
|
+
apiVersionMinor: 0,
|
|
13735
|
+
allowedPaymentMethods: [BASE_CARD_PAYMENT_METHOD]
|
|
13736
|
+
});
|
|
13737
|
+
return result.result === true;
|
|
13738
|
+
} catch (e) {
|
|
13739
|
+
return false;
|
|
13740
|
+
}
|
|
13741
|
+
}
|
|
13742
|
+
async function tokenizeGooglePayPayment(basisTheoryApiKey, paymentToken) {
|
|
13743
|
+
let parsedToken;
|
|
13744
|
+
try {
|
|
13745
|
+
parsedToken = typeof paymentToken === "string" ? JSON.parse(paymentToken) : paymentToken;
|
|
13746
|
+
} catch (e) {
|
|
13747
|
+
parsedToken = paymentToken;
|
|
13748
|
+
}
|
|
13749
|
+
const response = await fetch("https://api.basistheory.com/google-pay", {
|
|
13750
|
+
method: "POST",
|
|
13751
|
+
headers: {
|
|
13752
|
+
"Content-Type": "application/json",
|
|
13753
|
+
"BT-API-KEY": basisTheoryApiKey
|
|
13754
|
+
},
|
|
13755
|
+
body: JSON.stringify({
|
|
13756
|
+
google_payment_data: parsedToken
|
|
13757
|
+
})
|
|
13758
|
+
});
|
|
13759
|
+
if (!response.ok) {
|
|
13760
|
+
throw new Error("[GooglePayService] Tokenization failed: HTTP ".concat(response.status));
|
|
13761
|
+
}
|
|
13762
|
+
const result = await response.json();
|
|
13763
|
+
return result.google_pay;
|
|
13764
|
+
}
|
|
13765
|
+
function minorToDecimal2(amountMinor, currency) {
|
|
13766
|
+
const zeroDecimal = [
|
|
13767
|
+
"BIF",
|
|
13768
|
+
"CLP",
|
|
13769
|
+
"DJF",
|
|
13770
|
+
"GNF",
|
|
13771
|
+
"JPY",
|
|
13772
|
+
"KMF",
|
|
13773
|
+
"KRW",
|
|
13774
|
+
"MGA",
|
|
13775
|
+
"PYG",
|
|
13776
|
+
"RWF",
|
|
13777
|
+
"UGX",
|
|
13778
|
+
"VND",
|
|
13779
|
+
"VUV",
|
|
13780
|
+
"XAF",
|
|
13781
|
+
"XOF",
|
|
13782
|
+
"XPF"
|
|
13783
|
+
];
|
|
13784
|
+
if (zeroDecimal.includes(currency.toUpperCase())) {
|
|
13785
|
+
return String(amountMinor);
|
|
13786
|
+
}
|
|
13787
|
+
return (amountMinor / 100).toFixed(2);
|
|
13788
|
+
}
|
|
13789
|
+
function extractAddress(data) {
|
|
13790
|
+
if (!data)
|
|
13791
|
+
return void 0;
|
|
13792
|
+
return {
|
|
13793
|
+
name: data.name,
|
|
13794
|
+
phoneNumber: data.phoneNumber,
|
|
13795
|
+
address1: data.address1,
|
|
13796
|
+
address2: data.address2,
|
|
13797
|
+
address3: data.address3,
|
|
13798
|
+
locality: data.locality,
|
|
13799
|
+
administrativeArea: data.administrativeArea,
|
|
13800
|
+
postalCode: data.postalCode,
|
|
13801
|
+
countryCode: data.countryCode,
|
|
13802
|
+
sortingCode: data.sortingCode
|
|
13803
|
+
};
|
|
13804
|
+
}
|
|
13805
|
+
function startGooglePaySession(config, request, callbacks) {
|
|
13806
|
+
var _a, _b, _c, _d, _e;
|
|
13807
|
+
const PaymentsClient2 = (_c = (_b = (_a = window.google) == null ? void 0 : _a.payments) == null ? void 0 : _b.api) == null ? void 0 : _c.PaymentsClient;
|
|
13808
|
+
if (!PaymentsClient2) {
|
|
13809
|
+
(_d = callbacks.onError) == null ? void 0 : _d.call(callbacks, "Google Pay is not available on this device");
|
|
13810
|
+
return;
|
|
13811
|
+
}
|
|
13812
|
+
const countryCode = config.countryCode || "US";
|
|
13813
|
+
const merchantName = config.merchantName || "Store";
|
|
13814
|
+
const totalStr = minorToDecimal2(request.totalAmountMinor, request.currency);
|
|
13815
|
+
const client = new PaymentsClient2({
|
|
13816
|
+
environment: config.sandboxed ? "TEST" : "PRODUCTION"
|
|
13817
|
+
});
|
|
13818
|
+
const paymentDataRequest = {
|
|
13819
|
+
apiVersion: 2,
|
|
13820
|
+
apiVersionMinor: 0,
|
|
13821
|
+
allowedPaymentMethods: [
|
|
13822
|
+
__spreadProps(__spreadValues({}, BASE_CARD_PAYMENT_METHOD), {
|
|
13823
|
+
tokenizationSpecification: {
|
|
13824
|
+
type: "PAYMENT_GATEWAY",
|
|
13825
|
+
parameters: {
|
|
13826
|
+
gateway: "basistheory",
|
|
13827
|
+
gatewayMerchantId: config.basisTheoryTenantId
|
|
13828
|
+
}
|
|
13829
|
+
}
|
|
13830
|
+
})
|
|
13831
|
+
],
|
|
13832
|
+
merchantInfo: {
|
|
13833
|
+
merchantId: config.sandboxed ? "12345678901234567890" : config.merchantId,
|
|
13834
|
+
merchantName
|
|
13835
|
+
},
|
|
13836
|
+
transactionInfo: {
|
|
13837
|
+
totalPriceStatus: request.totalPriceStatus || "FINAL",
|
|
13838
|
+
totalPrice: totalStr,
|
|
13839
|
+
currencyCode: request.currency,
|
|
13840
|
+
countryCode
|
|
13841
|
+
},
|
|
13842
|
+
emailRequired: true,
|
|
13843
|
+
shippingAddressRequired: true,
|
|
13844
|
+
shippingAddressParameters: {
|
|
13845
|
+
phoneNumberRequired: true
|
|
13846
|
+
}
|
|
13847
|
+
};
|
|
13848
|
+
if (request.displayItems) {
|
|
13849
|
+
paymentDataRequest.transactionInfo.displayItems = request.displayItems;
|
|
13850
|
+
}
|
|
13851
|
+
try {
|
|
13852
|
+
client.loadPaymentData(paymentDataRequest).then(async (paymentData) => {
|
|
13853
|
+
var _a2, _b2, _c2;
|
|
13854
|
+
try {
|
|
13855
|
+
const paymentMethodData = paymentData.paymentMethodData;
|
|
13856
|
+
const tokenString = (_a2 = paymentMethodData == null ? void 0 : paymentMethodData.tokenizationData) == null ? void 0 : _a2.token;
|
|
13857
|
+
if (!tokenString) {
|
|
13858
|
+
throw new Error("No payment token received from Google Pay");
|
|
13859
|
+
}
|
|
13860
|
+
const token = await tokenizeGooglePayPayment(config.basisTheoryApiKey, tokenString);
|
|
13861
|
+
if (paymentMethodData == null ? void 0 : paymentMethodData.info) {
|
|
13862
|
+
token.details = __spreadValues({
|
|
13863
|
+
auth_method: paymentMethodData.info.cardNetwork
|
|
13864
|
+
}, token.details);
|
|
13865
|
+
}
|
|
13866
|
+
const shippingAddress = extractAddress(paymentData.shippingAddress);
|
|
13867
|
+
const billingAddress = extractAddress((_b2 = paymentMethodData == null ? void 0 : paymentMethodData.info) == null ? void 0 : _b2.billingAddress);
|
|
13868
|
+
const email = paymentData.email;
|
|
13869
|
+
await callbacks.onSuccess(token, {
|
|
13870
|
+
shipping: shippingAddress,
|
|
13871
|
+
billing: billingAddress,
|
|
13872
|
+
email
|
|
13873
|
+
});
|
|
13874
|
+
} catch (err) {
|
|
13875
|
+
console.error("[GooglePayService] Payment processing failed:", err);
|
|
13876
|
+
(_c2 = callbacks.onError) == null ? void 0 : _c2.call(callbacks, "Payment failed");
|
|
13877
|
+
}
|
|
13878
|
+
}).catch((err) => {
|
|
13879
|
+
var _a2, _b2;
|
|
13880
|
+
if (err.statusCode === "CANCELED") {
|
|
13881
|
+
(_a2 = callbacks.onCancel) == null ? void 0 : _a2.call(callbacks);
|
|
13882
|
+
} else {
|
|
13883
|
+
console.error("[GooglePayService] Google Pay error:", err);
|
|
13884
|
+
(_b2 = callbacks.onError) == null ? void 0 : _b2.call(callbacks, err.statusMessage || "Google Pay failed");
|
|
13885
|
+
}
|
|
13886
|
+
});
|
|
13887
|
+
} catch (err) {
|
|
13888
|
+
console.error("[GooglePayService] Failed to start Google Pay session:", err);
|
|
13889
|
+
(_e = callbacks.onError) == null ? void 0 : _e.call(callbacks, "Failed to start Google Pay");
|
|
13890
|
+
}
|
|
13891
|
+
}
|
|
13892
|
+
|
|
13051
13893
|
// src/v2/standalone/external-tracker.ts
|
|
13052
13894
|
init_tokenStorage();
|
|
13053
13895
|
var TRACKER_VERSION = "1.0.0";
|
|
@@ -13465,7 +14307,7 @@ var TagadaSDKBundle = (() => {
|
|
|
13465
14307
|
function createTagadaClient(config = {}) {
|
|
13466
14308
|
return new TagadaClient(config);
|
|
13467
14309
|
}
|
|
13468
|
-
function
|
|
14310
|
+
function getBasisTheoryApiKey3() {
|
|
13469
14311
|
return getBasisTheoryApiKey();
|
|
13470
14312
|
}
|
|
13471
14313
|
function getBasisTheoryTenantId2() {
|