@tagadapay/headless-sdk 1.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.
Files changed (79) hide show
  1. package/README.md +110 -0
  2. package/dist/core/client.d.ts +48 -0
  3. package/dist/core/client.d.ts.map +1 -0
  4. package/dist/core/client.js +61 -0
  5. package/dist/core/client.js.map +1 -0
  6. package/dist/core/errors.d.ts +46 -0
  7. package/dist/core/errors.d.ts.map +1 -0
  8. package/dist/core/errors.js +57 -0
  9. package/dist/core/errors.js.map +1 -0
  10. package/dist/core/http.d.ts +27 -0
  11. package/dist/core/http.d.ts.map +1 -0
  12. package/dist/core/http.js +116 -0
  13. package/dist/core/http.js.map +1 -0
  14. package/dist/core/index.d.ts +10 -0
  15. package/dist/core/index.d.ts.map +1 -0
  16. package/dist/core/index.js +9 -0
  17. package/dist/core/index.js.map +1 -0
  18. package/dist/core/modules/analytics.d.ts +79 -0
  19. package/dist/core/modules/analytics.d.ts.map +1 -0
  20. package/dist/core/modules/analytics.js +265 -0
  21. package/dist/core/modules/analytics.js.map +1 -0
  22. package/dist/core/modules/checkout.d.ts +67 -0
  23. package/dist/core/modules/checkout.d.ts.map +1 -0
  24. package/dist/core/modules/checkout.js +164 -0
  25. package/dist/core/modules/checkout.js.map +1 -0
  26. package/dist/core/modules/customer.d.ts +33 -0
  27. package/dist/core/modules/customer.d.ts.map +1 -0
  28. package/dist/core/modules/customer.js +53 -0
  29. package/dist/core/modules/customer.js.map +1 -0
  30. package/dist/core/modules/offers.d.ts +43 -0
  31. package/dist/core/modules/offers.d.ts.map +1 -0
  32. package/dist/core/modules/offers.js +56 -0
  33. package/dist/core/modules/offers.js.map +1 -0
  34. package/dist/core/modules/payment.d.ts +123 -0
  35. package/dist/core/modules/payment.d.ts.map +1 -0
  36. package/dist/core/modules/payment.js +279 -0
  37. package/dist/core/modules/payment.js.map +1 -0
  38. package/dist/core/types.d.ts +276 -0
  39. package/dist/core/types.d.ts.map +1 -0
  40. package/dist/core/types.js +5 -0
  41. package/dist/core/types.js.map +1 -0
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +2 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/react/hooks/useAnalytics.d.ts +59 -0
  47. package/dist/react/hooks/useAnalytics.d.ts.map +1 -0
  48. package/dist/react/hooks/useAnalytics.js +49 -0
  49. package/dist/react/hooks/useAnalytics.js.map +1 -0
  50. package/dist/react/hooks/useCheckout.d.ts +45 -0
  51. package/dist/react/hooks/useCheckout.d.ts.map +1 -0
  52. package/dist/react/hooks/useCheckout.js +113 -0
  53. package/dist/react/hooks/useCheckout.js.map +1 -0
  54. package/dist/react/hooks/useCustomer.d.ts +28 -0
  55. package/dist/react/hooks/useCustomer.d.ts.map +1 -0
  56. package/dist/react/hooks/useCustomer.js +77 -0
  57. package/dist/react/hooks/useCustomer.js.map +1 -0
  58. package/dist/react/hooks/useOffers.d.ts +45 -0
  59. package/dist/react/hooks/useOffers.d.ts.map +1 -0
  60. package/dist/react/hooks/useOffers.js +88 -0
  61. package/dist/react/hooks/useOffers.js.map +1 -0
  62. package/dist/react/hooks/usePayment.d.ts +63 -0
  63. package/dist/react/hooks/usePayment.d.ts.map +1 -0
  64. package/dist/react/hooks/usePayment.js +114 -0
  65. package/dist/react/hooks/usePayment.js.map +1 -0
  66. package/dist/react/index.d.ts +14 -0
  67. package/dist/react/index.d.ts.map +1 -0
  68. package/dist/react/index.js +7 -0
  69. package/dist/react/index.js.map +1 -0
  70. package/dist/react/provider.d.ts +31 -0
  71. package/dist/react/provider.d.ts.map +1 -0
  72. package/dist/react/provider.js +32 -0
  73. package/dist/react/provider.js.map +1 -0
  74. package/dist/tagada-headless-react.min.js +8 -0
  75. package/dist/tagada-headless-react.min.js.map +7 -0
  76. package/dist/tagada-headless.js +1093 -0
  77. package/dist/tagada-headless.min.js +8 -0
  78. package/dist/tagada-headless.min.js.map +7 -0
  79. package/package.json +72 -0
@@ -0,0 +1,43 @@
1
+ import type { HttpClient } from '../http.js';
2
+ import type { Offer, OfferResult } from '../types.js';
3
+ /**
4
+ * Post-purchase offers -- upsells, downsells, and order bumps.
5
+ *
6
+ * Offers are configured in the CRM and referenced by ID.
7
+ * The headless SDK lets you load offer details, accept (one-click charge),
8
+ * or decline from your own UI.
9
+ */
10
+ export declare class OffersModule {
11
+ private readonly http;
12
+ private readonly storeId;
13
+ constructor(http: HttpClient, storeId: string);
14
+ /** Load offer details by ID. */
15
+ loadOffer(offerId: string): Promise<Offer>;
16
+ /** List all offers for the store. */
17
+ listOffers(opts?: {
18
+ type?: 'upsell' | 'orderbump';
19
+ }): Promise<Offer[]>;
20
+ /**
21
+ * Accept an offer (one-click upsell).
22
+ * Charges the stored payment instrument from the main checkout order.
23
+ */
24
+ acceptOffer(opts: {
25
+ offerId: string;
26
+ checkoutSessionId: string;
27
+ paymentInstrumentId?: string;
28
+ }): Promise<OfferResult>;
29
+ /** Decline an offer. Advances the funnel to the next step. */
30
+ declineOffer(opts: {
31
+ offerId: string;
32
+ checkoutSessionId: string;
33
+ }): Promise<OfferResult>;
34
+ /** List order bumps available for a checkout session (shown on the checkout page). */
35
+ listOrderBumps(checkoutSessionId: string): Promise<Offer[]>;
36
+ /** Toggle an order bump on/off for a checkout session. */
37
+ toggleOrderBump(opts: {
38
+ checkoutSessionId: string;
39
+ offerId: string;
40
+ selected: boolean;
41
+ }): Promise<void>;
42
+ }
43
+ //# sourceMappingURL=offers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"offers.d.ts","sourceRoot":"","sources":["../../../src/core/modules/offers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;;GAMG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM;IAGlC,gCAAgC;IAC1B,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAQhD,qCAAqC;IAC/B,UAAU,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAQ5E;;;OAGG;IACG,WAAW,CAAC,IAAI,EAAE;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,OAAO,CAAC,WAAW,CAAC;IASxB,8DAA8D;IACxD,YAAY,CAAC,IAAI,EAAE;QACvB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC,WAAW,CAAC;IAQxB,sFAAsF;IAChF,cAAc,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAQjE,0DAA0D;IACpD,eAAe,CAAC,IAAI,EAAE;QAC1B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,OAAO,CAAC;KACnB,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlB"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Post-purchase offers -- upsells, downsells, and order bumps.
3
+ *
4
+ * Offers are configured in the CRM and referenced by ID.
5
+ * The headless SDK lets you load offer details, accept (one-click charge),
6
+ * or decline from your own UI.
7
+ */
8
+ export class OffersModule {
9
+ constructor(http, storeId) {
10
+ this.http = http;
11
+ this.storeId = storeId;
12
+ }
13
+ /** Load offer details by ID. */
14
+ async loadOffer(offerId) {
15
+ const res = await this.http.get(`/api/v1/checkout-offers/${offerId}`, { params: { storeId: this.storeId } });
16
+ return res.offer;
17
+ }
18
+ /** List all offers for the store. */
19
+ async listOffers(opts) {
20
+ const res = await this.http.get('/api/v1/checkout-offers', { params: { storeId: this.storeId, type: opts?.type } });
21
+ return res.offers;
22
+ }
23
+ /**
24
+ * Accept an offer (one-click upsell).
25
+ * Charges the stored payment instrument from the main checkout order.
26
+ */
27
+ async acceptOffer(opts) {
28
+ return this.http.post('/api/v1/checkout-offers/accept', {
29
+ offerId: opts.offerId,
30
+ checkoutSessionId: opts.checkoutSessionId,
31
+ storeId: this.storeId,
32
+ paymentInstrumentId: opts.paymentInstrumentId,
33
+ });
34
+ }
35
+ /** Decline an offer. Advances the funnel to the next step. */
36
+ async declineOffer(opts) {
37
+ return this.http.post('/api/v1/checkout-offers/decline', {
38
+ offerId: opts.offerId,
39
+ checkoutSessionId: opts.checkoutSessionId,
40
+ storeId: this.storeId,
41
+ });
42
+ }
43
+ /** List order bumps available for a checkout session (shown on the checkout page). */
44
+ async listOrderBumps(checkoutSessionId) {
45
+ const res = await this.http.get('/api/v1/checkout-offers', { params: { storeId: this.storeId, checkoutSessionId, type: 'orderbump' } });
46
+ return res.offers;
47
+ }
48
+ /** Toggle an order bump on/off for a checkout session. */
49
+ async toggleOrderBump(opts) {
50
+ await this.http.post(`/api/v1/checkout-sessions/${opts.checkoutSessionId}/order-bumps`, {
51
+ offerId: opts.offerId,
52
+ selected: opts.selected,
53
+ });
54
+ }
55
+ }
56
+ //# sourceMappingURL=offers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"offers.js","sourceRoot":"","sources":["../../../src/core/modules/offers.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACvB,YACmB,IAAgB,EAChB,OAAe;QADf,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;IAC/B,CAAC;IAEJ,gCAAgC;IAChC,KAAK,CAAC,SAAS,CAAC,OAAe;QAC7B,MAAM,GAAG,GAAG,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,iBAAiB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,CAC5E,CAAC;QACF,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,0DAA0D;IAC1D,KAAK,CAAC,eAAe,CAAC,IAIrB;QACC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,6BAA6B,IAAI,CAAC,iBAAiB,cAAc,EAAE;YACtF,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,123 @@
1
+ import type { HttpClient } from '../http.js';
2
+ import type { Environment, PaymentSetupConfig, ExpressMethods, StoreConfig, PayResult, PayOptions, PayDirectOptions, CreateInstrumentOptions, PaymentInstrument, ThreedsSession, PaymentStatus } from '../types.js';
3
+ /**
4
+ * Full payment lifecycle -- discover APMs, tokenize, create instruments,
5
+ * process payments, handle 3DS, and poll for status.
6
+ *
7
+ * Wraps the same REST endpoints that plugin-sdk uses internally.
8
+ */
9
+ export declare class PaymentModule {
10
+ private readonly http;
11
+ private readonly storeId;
12
+ private readonly environment;
13
+ constructor(http: HttpClient, storeId: string, environment: Environment);
14
+ /**
15
+ * Get the full payment setup config for a checkout session.
16
+ * Returns a map of payment methods with their configuration
17
+ * (card, apple_pay, google_pay, klarna, etc.).
18
+ */
19
+ getPaymentSetup(checkoutSessionId: string): Promise<PaymentSetupConfig>;
20
+ /**
21
+ * Get express payment methods (Apple Pay, Google Pay, PayPal, etc.)
22
+ * filtered to only those available in the current browser.
23
+ */
24
+ getExpressMethods(checkoutSessionId: string): Promise<ExpressMethods>;
25
+ /**
26
+ * Get store-level payment config (3DS flags, default flow ID, etc.).
27
+ */
28
+ getStoreConfig(): Promise<StoreConfig>;
29
+ /**
30
+ * Convenience: return only enabled payment method keys.
31
+ */
32
+ getEnabledMethods(checkoutSessionId: string): Promise<string[]>;
33
+ /**
34
+ * Tokenize a card using @tagadapay/core-js.
35
+ * Requires `@tagadapay/core-js` to be installed as a peer dependency.
36
+ *
37
+ * @returns tagadaToken (base64 string) and rawToken with SCA metadata.
38
+ */
39
+ tokenizeCard(card: {
40
+ cardNumber: string;
41
+ expiryDate: string;
42
+ cvc: string;
43
+ cardholderName?: string;
44
+ }): Promise<{
45
+ tagadaToken: string;
46
+ rawToken: Record<string, unknown>;
47
+ }>;
48
+ /**
49
+ * Create a reusable payment instrument from a TagadaToken.
50
+ * Session-authenticated (uses the checkout session JWT).
51
+ */
52
+ createInstrument(opts: CreateInstrumentOptions): Promise<{
53
+ paymentInstrument: PaymentInstrument;
54
+ }>;
55
+ /**
56
+ * Create a 3DS session on the TagadaPay backend.
57
+ * This persists the session so the processor can use it during payment.
58
+ */
59
+ create3dsSession(opts: {
60
+ paymentInstrumentId: string;
61
+ sessionData: {
62
+ sessionId: string;
63
+ metadata?: Record<string, unknown>;
64
+ };
65
+ provider?: string;
66
+ }): Promise<ThreedsSession>;
67
+ /**
68
+ * High-level pay: single API call that decodes tagadaToken server-side,
69
+ * creates the payment instrument, and processes payment.
70
+ *
71
+ * Also accepts `paymentInstrumentId` directly for pre-created instruments.
72
+ */
73
+ pay(opts: PayOptions): Promise<PayResult>;
74
+ /**
75
+ * Low-level pay: process payment with an existing instrument or for APM/express flows
76
+ * where no instrument is needed (redirect-based methods).
77
+ */
78
+ payDirect(opts: PayDirectOptions): Promise<PayResult>;
79
+ /**
80
+ * Process an Apple Pay payment.
81
+ * Tokenizes the Apple Pay token and processes payment in one call.
82
+ */
83
+ processApplePay(opts: {
84
+ checkoutSessionId: string;
85
+ applePayToken: unknown;
86
+ paymentFlowId?: string;
87
+ processorId?: string;
88
+ }): Promise<PayResult>;
89
+ /**
90
+ * Process a Google Pay payment.
91
+ * Tokenizes the Google Pay token and processes payment in one call.
92
+ */
93
+ processGooglePay(opts: {
94
+ checkoutSessionId: string;
95
+ googlePayToken: string;
96
+ paymentFlowId?: string;
97
+ processorId?: string;
98
+ }): Promise<PayResult>;
99
+ /**
100
+ * Process an APM payment (Klarna, iDEAL, etc.) via redirect.
101
+ * These typically don't require a payment instrument -- the processor handles the redirect.
102
+ */
103
+ processApm(opts: {
104
+ checkoutSessionId: string;
105
+ paymentMethod: string;
106
+ processorId: string;
107
+ paymentFlowId?: string;
108
+ }): Promise<PayResult>;
109
+ /** Get current status of a payment. */
110
+ getPaymentStatus(paymentId: string): Promise<PaymentStatus>;
111
+ /**
112
+ * Poll a payment until it reaches a terminal status.
113
+ * Returns the final status or throws on timeout.
114
+ */
115
+ pollPaymentStatus(paymentId: string, opts?: {
116
+ intervalMs?: number;
117
+ timeoutMs?: number;
118
+ }): Promise<PaymentStatus>;
119
+ /** Finalize a payment after a 3DS challenge completes. */
120
+ completeAfter3ds(paymentId: string): Promise<PaymentStatus>;
121
+ private loadCoreJs;
122
+ }
123
+ //# sourceMappingURL=payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../src/core/modules/payment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAElB,cAAc,EACd,WAAW,EACX,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,qBAAa,aAAa;IAEtB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAFX,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW;IAO3C;;;;OAIG;IACG,eAAe,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAc7E;;;OAGG;IACG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,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;KACtB,GAAG,OAAO,CAAC,SAAS,CAAC;IAgBtB;;;OAGG;IACG,gBAAgB,CAAC,IAAI,EAAE;QAC3B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,SAAS,CAAC;IAgBtB;;;OAGG;IACG,UAAU,CAAC,IAAI,EAAE;QACrB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,SAAS,CAAC;IAatB,uCAAuC;IACjC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIjE;;;OAGG;IACG,iBAAiB,CACrB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GACjD,OAAO,CAAC,aAAa,CAAC;IAgBzB,0DAA0D;IACpD,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;YAWnD,UAAU;CASzB"}
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Full payment lifecycle -- discover APMs, tokenize, create instruments,
3
+ * process payments, handle 3DS, and poll for status.
4
+ *
5
+ * Wraps the same REST endpoints that plugin-sdk uses internally.
6
+ */
7
+ export class PaymentModule {
8
+ constructor(http, storeId, environment) {
9
+ this.http = http;
10
+ this.storeId = storeId;
11
+ this.environment = environment;
12
+ }
13
+ // ---------------------------------------------------------------------------
14
+ // Discovery: what payment methods are available?
15
+ // ---------------------------------------------------------------------------
16
+ /**
17
+ * Get the full payment setup config for a checkout session.
18
+ * Returns a map of payment methods with their configuration
19
+ * (card, apple_pay, google_pay, klarna, etc.).
20
+ */
21
+ async getPaymentSetup(checkoutSessionId) {
22
+ const methods = await this.http.get('/api/v1/payment-methods', { params: { checkoutSessionId } });
23
+ const config = {};
24
+ for (const m of methods.methods ?? []) {
25
+ const key = m.provider ? `${m.method}:${m.provider}` : m.method;
26
+ config[key] = m;
27
+ }
28
+ return config;
29
+ }
30
+ /**
31
+ * Get express payment methods (Apple Pay, Google Pay, PayPal, etc.)
32
+ * filtered to only those available in the current browser.
33
+ */
34
+ async getExpressMethods(checkoutSessionId) {
35
+ const setup = await this.getPaymentSetup(checkoutSessionId);
36
+ const result = {};
37
+ for (const [, config] of Object.entries(setup)) {
38
+ if (!config.enabled || !config.express)
39
+ continue;
40
+ const method = config.method;
41
+ const base = {
42
+ type: method,
43
+ available: true,
44
+ processorId: config.processorId,
45
+ publishableKey: config.publishableKey,
46
+ metadata: config.metadata,
47
+ };
48
+ if (method === 'apple_pay' || config.type === 'apple_pay') {
49
+ const hasApplePay = typeof window !== 'undefined' &&
50
+ 'ApplePaySession' in window &&
51
+ window
52
+ .ApplePaySession?.canMakePayments?.();
53
+ result.applePay = { ...base, available: !!hasApplePay };
54
+ }
55
+ else if (method === 'google_pay' || config.type === 'google_pay') {
56
+ result.googlePay = base;
57
+ }
58
+ else if (method === 'paypal') {
59
+ result.paypal = base;
60
+ }
61
+ else if (method === 'klarna' || method === 'klarna_express') {
62
+ result.klarna = base;
63
+ }
64
+ else if (method === 'link') {
65
+ result.link = base;
66
+ }
67
+ }
68
+ return result;
69
+ }
70
+ /**
71
+ * Get store-level payment config (3DS flags, default flow ID, etc.).
72
+ */
73
+ async getStoreConfig() {
74
+ const res = await this.http.get('/api/v1/checkout/config', { params: { storeId: this.storeId } });
75
+ return res.config ?? res;
76
+ }
77
+ /**
78
+ * Convenience: return only enabled payment method keys.
79
+ */
80
+ async getEnabledMethods(checkoutSessionId) {
81
+ const setup = await this.getPaymentSetup(checkoutSessionId);
82
+ return Object.entries(setup)
83
+ .filter(([, c]) => c.enabled)
84
+ .map(([key]) => key);
85
+ }
86
+ // ---------------------------------------------------------------------------
87
+ // Tokenization (delegates to @tagadapay/core-js if available)
88
+ // ---------------------------------------------------------------------------
89
+ /**
90
+ * Tokenize a card using @tagadapay/core-js.
91
+ * Requires `@tagadapay/core-js` to be installed as a peer dependency.
92
+ *
93
+ * @returns tagadaToken (base64 string) and rawToken with SCA metadata.
94
+ */
95
+ async tokenizeCard(card) {
96
+ const coreJs = await this.loadCoreJs();
97
+ const tokenizer = new coreJs.Tokenizer({ environment: this.environment });
98
+ await tokenizer.initialize();
99
+ const sanitized = {
100
+ cardNumber: card.cardNumber,
101
+ expiryDate: card.expiryDate,
102
+ cvc: card.cvc,
103
+ };
104
+ if (card.cardholderName)
105
+ sanitized.cardholderName = card.cardholderName;
106
+ const [tagadaToken, rawToken] = await Promise.all([
107
+ tokenizer.tokenizeCard(sanitized),
108
+ tokenizer.tokenizeCardRaw(sanitized),
109
+ ]);
110
+ return { tagadaToken, rawToken };
111
+ }
112
+ // ---------------------------------------------------------------------------
113
+ // Instrument creation
114
+ // ---------------------------------------------------------------------------
115
+ /**
116
+ * Create a reusable payment instrument from a TagadaToken.
117
+ * Session-authenticated (uses the checkout session JWT).
118
+ */
119
+ async createInstrument(opts) {
120
+ return this.http.post('/api/v1/payment/create-instrument-from-token', {
121
+ tagadaToken: opts.tagadaToken,
122
+ });
123
+ }
124
+ // ---------------------------------------------------------------------------
125
+ // 3DS
126
+ // ---------------------------------------------------------------------------
127
+ /**
128
+ * Create a 3DS session on the TagadaPay backend.
129
+ * This persists the session so the processor can use it during payment.
130
+ */
131
+ async create3dsSession(opts) {
132
+ return this.http.post('/api/public/v1/threeds/create-session', {
133
+ provider: opts.provider ?? 'basis_theory',
134
+ storeId: this.storeId,
135
+ paymentInstrumentId: opts.paymentInstrumentId,
136
+ sessionData: opts.sessionData,
137
+ });
138
+ }
139
+ // ---------------------------------------------------------------------------
140
+ // Payment processing
141
+ // ---------------------------------------------------------------------------
142
+ /**
143
+ * High-level pay: single API call that decodes tagadaToken server-side,
144
+ * creates the payment instrument, and processes payment.
145
+ *
146
+ * Also accepts `paymentInstrumentId` directly for pre-created instruments.
147
+ */
148
+ async pay(opts) {
149
+ if (opts.tagadaToken && !opts.paymentInstrumentId) {
150
+ return this.http.post('/api/v1/payment/pay-with-token', {
151
+ tagadaToken: opts.tagadaToken,
152
+ checkoutSessionId: opts.checkoutSessionId,
153
+ paymentFlowId: opts.paymentFlowId,
154
+ processorId: opts.processorId,
155
+ paymentMethod: opts.paymentMethod,
156
+ isExpress: opts.isExpress,
157
+ metadata: opts.metadata,
158
+ });
159
+ }
160
+ return this.http.post('/api/public/v1/checkout/pay-v2', {
161
+ checkoutSessionId: opts.checkoutSessionId,
162
+ paymentInstrumentId: opts.paymentInstrumentId,
163
+ storeId: this.storeId,
164
+ paymentFlowId: opts.paymentFlowId,
165
+ threedsSessionId: opts.threedsSessionId,
166
+ processorId: opts.processorId,
167
+ paymentMethod: opts.paymentMethod,
168
+ isExpress: opts.isExpress,
169
+ metadata: opts.metadata,
170
+ });
171
+ }
172
+ /**
173
+ * Low-level pay: process payment with an existing instrument or for APM/express flows
174
+ * where no instrument is needed (redirect-based methods).
175
+ */
176
+ async payDirect(opts) {
177
+ return this.http.post('/api/public/v1/checkout/pay-v2', {
178
+ checkoutSessionId: opts.checkoutSessionId,
179
+ paymentInstrumentId: opts.paymentInstrumentId ?? '',
180
+ storeId: this.storeId,
181
+ paymentFlowId: opts.paymentFlowId,
182
+ processorId: opts.processorId,
183
+ paymentMethod: opts.paymentMethod,
184
+ isExpress: opts.isExpress,
185
+ threedsSessionId: opts.threedsSessionId,
186
+ });
187
+ }
188
+ /**
189
+ * Process an Apple Pay payment.
190
+ * Tokenizes the Apple Pay token and processes payment in one call.
191
+ */
192
+ async processApplePay(opts) {
193
+ const coreJs = await this.loadCoreJs();
194
+ const tokenizer = new coreJs.Tokenizer({ environment: this.environment });
195
+ await tokenizer.initialize();
196
+ const { tagadaToken } = await tokenizer.tokenizeApplePay(opts.applePayToken);
197
+ return this.pay({
198
+ checkoutSessionId: opts.checkoutSessionId,
199
+ tagadaToken,
200
+ paymentFlowId: opts.paymentFlowId,
201
+ processorId: opts.processorId,
202
+ paymentMethod: 'apple_pay',
203
+ isExpress: true,
204
+ });
205
+ }
206
+ /**
207
+ * Process a Google Pay payment.
208
+ * Tokenizes the Google Pay token and processes payment in one call.
209
+ */
210
+ async processGooglePay(opts) {
211
+ const coreJs = await this.loadCoreJs();
212
+ const tokenizer = new coreJs.Tokenizer({ environment: this.environment });
213
+ await tokenizer.initialize();
214
+ const { tagadaToken } = await tokenizer.tokenizeGooglePay(opts.googlePayToken);
215
+ return this.pay({
216
+ checkoutSessionId: opts.checkoutSessionId,
217
+ tagadaToken,
218
+ paymentFlowId: opts.paymentFlowId,
219
+ processorId: opts.processorId,
220
+ paymentMethod: 'google_pay',
221
+ isExpress: true,
222
+ });
223
+ }
224
+ /**
225
+ * Process an APM payment (Klarna, iDEAL, etc.) via redirect.
226
+ * These typically don't require a payment instrument -- the processor handles the redirect.
227
+ */
228
+ async processApm(opts) {
229
+ return this.payDirect({
230
+ checkoutSessionId: opts.checkoutSessionId,
231
+ paymentMethod: opts.paymentMethod,
232
+ processorId: opts.processorId,
233
+ paymentFlowId: opts.paymentFlowId,
234
+ });
235
+ }
236
+ // ---------------------------------------------------------------------------
237
+ // Status polling
238
+ // ---------------------------------------------------------------------------
239
+ /** Get current status of a payment. */
240
+ async getPaymentStatus(paymentId) {
241
+ return this.http.get(`/api/v1/payments/${paymentId}`);
242
+ }
243
+ /**
244
+ * Poll a payment until it reaches a terminal status.
245
+ * Returns the final status or throws on timeout.
246
+ */
247
+ async pollPaymentStatus(paymentId, opts) {
248
+ const interval = opts?.intervalMs ?? 1500;
249
+ const timeout = opts?.timeoutMs ?? 60000;
250
+ const start = Date.now();
251
+ while (Date.now() - start < timeout) {
252
+ const status = await this.getPaymentStatus(paymentId);
253
+ if (status.status === 'succeeded' || status.status === 'failed' || status.status === 'declined') {
254
+ return status;
255
+ }
256
+ await new Promise((r) => setTimeout(r, interval));
257
+ }
258
+ throw new Error(`Payment ${paymentId} did not reach terminal status within ${timeout}ms.`);
259
+ }
260
+ /** Finalize a payment after a 3DS challenge completes. */
261
+ async completeAfter3ds(paymentId) {
262
+ return this.http.post('/api/v1/payments/complete-after-3ds', {
263
+ paymentId,
264
+ });
265
+ }
266
+ // ---------------------------------------------------------------------------
267
+ // Internal helpers
268
+ // ---------------------------------------------------------------------------
269
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
270
+ async loadCoreJs() {
271
+ try {
272
+ return await import('@tagadapay/core-js');
273
+ }
274
+ catch {
275
+ throw new Error('This method requires @tagadapay/core-js. Install it: npm install @tagadapay/core-js');
276
+ }
277
+ }
278
+ }
279
+ //# sourceMappingURL=payment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../src/core/modules/payment.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACxB,YACmB,IAAgB,EAChB,OAAe,EACf,WAAwB;QAFxB,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAEJ,8EAA8E;IAC9E,iDAAiD;IACjD,8EAA8E;IAE9E;;;;OAIG;IACH,KAAK,CAAC,eAAe,CAAC,iBAAyB;QAC7C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CACjC,yBAAyB,EACzB,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,EAAE,CAClC,CAAC;QAEF,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YACtC,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,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