@tagadapay/headless-sdk 1.3.2 → 1.5.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 +84 -7
- package/dist/core/client.d.ts +6 -0
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +6 -0
- package/dist/core/client.js.map +1 -1
- package/dist/core/http.js +2 -2
- package/dist/core/http.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/modules/checkout.d.ts +113 -12
- package/dist/core/modules/checkout.d.ts.map +1 -1
- package/dist/core/modules/checkout.js +201 -55
- package/dist/core/modules/checkout.js.map +1 -1
- package/dist/core/modules/payment.d.ts +120 -4
- package/dist/core/modules/payment.d.ts.map +1 -1
- package/dist/core/modules/payment.js +336 -7
- package/dist/core/modules/payment.js.map +1 -1
- package/dist/core/types.d.ts +112 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/react/hooks/useCheckout.d.ts.map +1 -1
- package/dist/react/hooks/useCheckout.js +9 -15
- package/dist/react/hooks/useCheckout.js.map +1 -1
- package/dist/react/hooks/usePayment.d.ts +58 -13
- package/dist/react/hooks/usePayment.d.ts.map +1 -1
- package/dist/react/hooks/usePayment.js +124 -11
- package/dist/react/hooks/usePayment.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/stripe/StripeExpressButton.d.ts +30 -0
- package/dist/stripe/StripeExpressButton.d.ts.map +1 -0
- package/dist/stripe/StripeExpressButton.js +32 -0
- package/dist/stripe/StripeExpressButton.js.map +1 -0
- package/dist/stripe/StripeExpressCheckout.d.ts +98 -0
- package/dist/stripe/StripeExpressCheckout.d.ts.map +1 -0
- package/dist/stripe/StripeExpressCheckout.js +198 -0
- package/dist/stripe/StripeExpressCheckout.js.map +1 -0
- package/dist/stripe/index.d.ts +8 -0
- package/dist/stripe/index.d.ts.map +1 -0
- package/dist/stripe/index.js +15 -0
- package/dist/stripe/index.js.map +1 -0
- package/dist/stripe/useStripeExpress.d.ts +54 -0
- package/dist/stripe/useStripeExpress.d.ts.map +1 -0
- package/dist/stripe/useStripeExpress.js +126 -0
- package/dist/stripe/useStripeExpress.js.map +1 -0
- package/dist/tagada-headless-react.min.js +2 -2
- package/dist/tagada-headless-react.min.js.map +3 -3
- package/dist/tagada-headless.js +483 -66
- package/dist/tagada-headless.min.js +2 -2
- package/dist/tagada-headless.min.js.map +3 -3
- package/package.json +9 -3
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Manages checkout sessions
|
|
2
|
+
* Manages checkout sessions — load, update cart, apply promo codes, handle shipping.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Works for both **shipped** and **digital** products:
|
|
5
|
+
*
|
|
6
|
+
* **Shipped products** (physical goods):
|
|
7
|
+
* ```
|
|
8
|
+
* updateCustomer(id, { email, firstName, lastName })
|
|
9
|
+
* updateAddress(id, { shippingAddress: { line1, city, ... } })
|
|
10
|
+
* getShippingRates(id)
|
|
11
|
+
* selectShippingRate(id, rateId)
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* **Digital products** (no shipping needed):
|
|
15
|
+
* ```
|
|
16
|
+
* updateCustomer(id, { email, firstName, lastName })
|
|
17
|
+
* updateAddress(id, { billingAddress: { line1, city, country } })
|
|
18
|
+
* // Skip shipping rates — go straight to payment
|
|
19
|
+
* ```
|
|
6
20
|
*/
|
|
7
21
|
export class CheckoutModule {
|
|
8
22
|
constructor(http, storeId, onTokenChange) {
|
|
@@ -15,17 +29,24 @@ export class CheckoutModule {
|
|
|
15
29
|
*
|
|
16
30
|
* @param checkoutToken The checkout token (from URL param `checkoutToken`).
|
|
17
31
|
* @param sessionToken The JWT session token (from URL param `token`). Required for auth.
|
|
32
|
+
* @param opts.currency Optional presentment currency override (e.g. 'EUR').
|
|
33
|
+
* Only applied when the session has no currency set yet (first load).
|
|
34
|
+
* Once set, currency is locked to the session and this param is ignored.
|
|
18
35
|
*
|
|
19
|
-
* Both
|
|
36
|
+
* Both `checkoutToken` and `sessionToken` come from the redirect URL returned by `createSession()`.
|
|
20
37
|
* Example URL: `/checkout?checkoutToken=abc123&token=eyJ...`
|
|
21
38
|
*/
|
|
22
|
-
async loadSession(checkoutToken, sessionToken) {
|
|
39
|
+
async loadSession(checkoutToken, sessionToken, opts) {
|
|
23
40
|
if (sessionToken) {
|
|
24
41
|
this.sessionToken = sessionToken;
|
|
25
42
|
this.onTokenChange?.(sessionToken);
|
|
26
43
|
}
|
|
44
|
+
const params = { skipAsyncWait: 'false' };
|
|
45
|
+
if (opts?.currency) {
|
|
46
|
+
params.currency = opts.currency;
|
|
47
|
+
}
|
|
27
48
|
const raw = await this.http.get(`/api/v1/checkout-sessions/${checkoutToken}/v2`, {
|
|
28
|
-
params
|
|
49
|
+
params,
|
|
29
50
|
token: this.sessionToken,
|
|
30
51
|
});
|
|
31
52
|
return this.normalizeSession(raw);
|
|
@@ -46,17 +67,19 @@ export class CheckoutModule {
|
|
|
46
67
|
storeId: this.storeId,
|
|
47
68
|
lineItems,
|
|
48
69
|
};
|
|
49
|
-
if (opts.currency)
|
|
50
|
-
body.currency = opts.currency;
|
|
51
70
|
if (opts.returnUrl)
|
|
52
71
|
body.returnUrl = opts.returnUrl;
|
|
72
|
+
// Always send currency in customer object (backend reads customer.currency)
|
|
73
|
+
const customerData = {};
|
|
74
|
+
if (opts.currency)
|
|
75
|
+
customerData.currency = opts.currency;
|
|
53
76
|
if (opts.customerEmail) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
customerData.email = opts.customerEmail;
|
|
78
|
+
customerData.firstName = opts.customerFirstName;
|
|
79
|
+
customerData.lastName = opts.customerLastName;
|
|
80
|
+
}
|
|
81
|
+
if (Object.keys(customerData).length > 0) {
|
|
82
|
+
body.customer = customerData;
|
|
60
83
|
}
|
|
61
84
|
const res = await this.http.post('/api/v1/checkout/session/init', body);
|
|
62
85
|
const url = new URL(res.checkoutUrl);
|
|
@@ -71,56 +94,125 @@ export class CheckoutModule {
|
|
|
71
94
|
customerId: res.customerId,
|
|
72
95
|
};
|
|
73
96
|
}
|
|
74
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Replace the cart items for an existing session.
|
|
99
|
+
*
|
|
100
|
+
* Returns a server-side mutation summary (counts of created/updated rows).
|
|
101
|
+
* It does NOT return the updated `CheckoutSession` — the underlying
|
|
102
|
+
* `POST /checkout-sessions/:id/line-items` endpoint never has and the
|
|
103
|
+
* previous typing was a lie that quietly assigned `{ success, updated, ... }`
|
|
104
|
+
* into a `CheckoutSession` slot in `useCheckout`.
|
|
105
|
+
*
|
|
106
|
+
* Call `loadSession()` after this if you need the refreshed session
|
|
107
|
+
* (the React `useCheckout` hook does this for you).
|
|
108
|
+
*/
|
|
75
109
|
async updateCart(sessionId, items) {
|
|
76
110
|
return this.http.post(`/api/v1/checkout-sessions/${sessionId}/line-items`, { items }, { token: this.sessionToken });
|
|
77
111
|
}
|
|
78
112
|
/**
|
|
79
|
-
* Update customer
|
|
80
|
-
*
|
|
113
|
+
* Update customer identity (email, name, phone).
|
|
114
|
+
*
|
|
115
|
+
* Call this before `updateAddress()` — the SDK remembers the values and
|
|
116
|
+
* includes them automatically when addresses are submitted.
|
|
117
|
+
*
|
|
118
|
+
* If you prefer a single call, use `updateCustomerAndAddress()` instead.
|
|
81
119
|
*/
|
|
82
120
|
async updateCustomer(sessionId, customer) {
|
|
121
|
+
if (customer.email)
|
|
122
|
+
this.customerEmail = customer.email;
|
|
123
|
+
if (customer.firstName)
|
|
124
|
+
this.customerFirstName = customer.firstName;
|
|
125
|
+
if (customer.lastName)
|
|
126
|
+
this.customerLastName = customer.lastName;
|
|
127
|
+
if (customer.phone)
|
|
128
|
+
this.customerPhone = customer.phone;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Update shipping and/or billing address on the session.
|
|
132
|
+
*
|
|
133
|
+
* Automatically includes customer name/phone stored from `updateCustomer()`.
|
|
134
|
+
* Uses the same atomic API call as the production checkout, so email,
|
|
135
|
+
* customer name, and addresses are all persisted together.
|
|
136
|
+
*
|
|
137
|
+
* **Shipped products**: pass `shippingAddress`. If `billingAddress` is omitted,
|
|
138
|
+
* the shipping address is automatically used as billing.
|
|
139
|
+
*
|
|
140
|
+
* **Digital products**: pass only `billingAddress` (no shipping needed).
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* // Shipped product — billing = shipping automatically
|
|
144
|
+
* await checkout.updateAddress(sessionId, {
|
|
145
|
+
* shippingAddress: { line1: '10 Rue de la Paix', city: 'Paris', postalCode: '75002', country: 'FR' },
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* // Digital product — billing only
|
|
150
|
+
* await checkout.updateAddress(sessionId, {
|
|
151
|
+
* billingAddress: { country: 'FR' },
|
|
152
|
+
* });
|
|
153
|
+
*/
|
|
154
|
+
async updateAddress(sessionId, addresses) {
|
|
155
|
+
const shipping = this.mapAddress(addresses.shippingAddress);
|
|
156
|
+
const billing = this.mapAddress(addresses.billingAddress);
|
|
157
|
+
const effectiveShipping = shipping ?? billing ?? {};
|
|
158
|
+
const effectiveBilling = billing ?? shipping;
|
|
159
|
+
const differentBilling = !!(addresses.billingAddress && addresses.shippingAddress);
|
|
83
160
|
await this.http.post(`/api/v1/checkout-sessions/${sessionId}/customer-and-session-info`, {
|
|
84
161
|
checkoutSessionId: sessionId,
|
|
85
|
-
partial: true,
|
|
86
162
|
customerData: {
|
|
87
|
-
email:
|
|
88
|
-
},
|
|
89
|
-
shippingAddress: {
|
|
90
|
-
firstName: customer.firstName,
|
|
91
|
-
lastName: customer.lastName,
|
|
92
|
-
phone: customer.phone,
|
|
163
|
+
email: this.customerEmail,
|
|
93
164
|
},
|
|
94
|
-
|
|
95
|
-
|
|
165
|
+
shippingAddress: effectiveShipping,
|
|
166
|
+
billingAddress: effectiveBilling ?? {},
|
|
167
|
+
differentBillingAddress: differentBilling,
|
|
96
168
|
}, { token: this.sessionToken });
|
|
97
169
|
}
|
|
98
170
|
/**
|
|
99
|
-
*
|
|
171
|
+
* Set customer info + addresses in one call (mirrors production checkout).
|
|
100
172
|
*
|
|
101
|
-
*
|
|
173
|
+
* Equivalent to calling `updateCustomer()` then `updateAddress()`, but
|
|
174
|
+
* in a single network request.
|
|
102
175
|
*/
|
|
103
|
-
async
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
176
|
+
async updateCustomerAndAddress(sessionId, data) {
|
|
177
|
+
if (data.customer.email)
|
|
178
|
+
this.customerEmail = data.customer.email;
|
|
179
|
+
if (data.customer.firstName)
|
|
180
|
+
this.customerFirstName = data.customer.firstName;
|
|
181
|
+
if (data.customer.lastName)
|
|
182
|
+
this.customerLastName = data.customer.lastName;
|
|
183
|
+
if (data.customer.phone)
|
|
184
|
+
this.customerPhone = data.customer.phone;
|
|
185
|
+
const shipping = this.mapAddress(data.shippingAddress);
|
|
186
|
+
const billing = this.mapAddress(data.billingAddress);
|
|
187
|
+
const effectiveShipping = shipping ?? billing ?? {};
|
|
188
|
+
const effectiveBilling = billing ?? shipping;
|
|
189
|
+
const differentBilling = !!(data.billingAddress && data.shippingAddress);
|
|
190
|
+
await this.http.post(`/api/v1/checkout-sessions/${sessionId}/customer-and-session-info`, {
|
|
117
191
|
checkoutSessionId: sessionId,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
billingAddress: mapAddress(addresses.billingAddress),
|
|
192
|
+
customerData: {
|
|
193
|
+
email: this.customerEmail,
|
|
121
194
|
},
|
|
195
|
+
shippingAddress: effectiveShipping,
|
|
196
|
+
billingAddress: effectiveBilling ?? {},
|
|
197
|
+
differentBillingAddress: differentBilling,
|
|
122
198
|
}, { token: this.sessionToken });
|
|
123
199
|
}
|
|
200
|
+
/** Map an SDK Address to the API shape, injecting stored customer fields. */
|
|
201
|
+
mapAddress(a) {
|
|
202
|
+
if (!a)
|
|
203
|
+
return undefined;
|
|
204
|
+
return stripEmpty({
|
|
205
|
+
firstName: a.firstName ?? this.customerFirstName,
|
|
206
|
+
lastName: a.lastName ?? this.customerLastName,
|
|
207
|
+
phone: a.phone ?? this.customerPhone,
|
|
208
|
+
address1: a.line1,
|
|
209
|
+
address2: a.line2,
|
|
210
|
+
city: a.city,
|
|
211
|
+
state: a.state,
|
|
212
|
+
postal: a.postalCode,
|
|
213
|
+
country: a.country,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
124
216
|
/** Apply a promotion code to the session. */
|
|
125
217
|
async applyPromoCode(sessionId, code) {
|
|
126
218
|
await this.http.post(`/api/v1/checkout-sessions/${sessionId}/promotions/apply`, { checkoutSessionId: sessionId, code }, { token: this.sessionToken });
|
|
@@ -130,12 +222,21 @@ export class CheckoutModule {
|
|
|
130
222
|
const promoId = promotionId ?? 'default';
|
|
131
223
|
await this.http.delete(`/api/v1/checkout-sessions/${sessionId}/promotions/${promoId}`, { token: this.sessionToken });
|
|
132
224
|
}
|
|
133
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* Fetch available shipping rates for the session's address.
|
|
227
|
+
* Only relevant for **shipped products** — digital products can skip this step.
|
|
228
|
+
*
|
|
229
|
+
* Requires a shipping address to be set first via `updateAddress()`.
|
|
230
|
+
* Returns an empty array if no rates are configured or address is missing.
|
|
231
|
+
*/
|
|
134
232
|
async getShippingRates(sessionId) {
|
|
135
233
|
const res = await this.http.get(`/api/v1/checkout-sessions/${sessionId}/shipping-rates`, { token: this.sessionToken });
|
|
136
234
|
return res.rates ?? [];
|
|
137
235
|
}
|
|
138
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* Select a shipping rate for the session.
|
|
238
|
+
* Only relevant for **shipped products** — digital products can skip this step.
|
|
239
|
+
*/
|
|
139
240
|
async selectShippingRate(sessionId, rateId) {
|
|
140
241
|
await this.http.post(`/api/v1/checkout-sessions/${sessionId}/shipping-rate`, { checkoutSessionId: sessionId, shippingRateId: rateId }, { token: this.sessionToken });
|
|
141
242
|
}
|
|
@@ -149,12 +250,16 @@ export class CheckoutModule {
|
|
|
149
250
|
const summary = (raw.summary ?? cs.summary ?? orderSummaries[0] ?? {});
|
|
150
251
|
const lineItems = (cs.sessionLineItems ?? []);
|
|
151
252
|
const customer = cs.customer;
|
|
253
|
+
const sessionCurrency = (summary.currency ?? cs.selectedPresentmentCurrency)?.toUpperCase();
|
|
152
254
|
const items = lineItems.map((li) => {
|
|
153
255
|
const price = li.price;
|
|
154
256
|
const variant = (price?.variant ?? {});
|
|
155
257
|
const product = (variant.product ?? {});
|
|
156
258
|
const currencyOpts = (price?.currencyOptions ?? {});
|
|
157
|
-
|
|
259
|
+
// Pick the amount bucket matching the session's presentment currency, then fall back to first available
|
|
260
|
+
const priceEntry = (sessionCurrency ? currencyOpts[sessionCurrency] : undefined)
|
|
261
|
+
?? currencyOpts[Object.keys(currencyOpts)[0]];
|
|
262
|
+
const amount = priceEntry?.amount ?? 0;
|
|
158
263
|
return {
|
|
159
264
|
id: li.id,
|
|
160
265
|
variantId: li.variantId,
|
|
@@ -162,9 +267,9 @@ export class CheckoutModule {
|
|
|
162
267
|
productName: (product.name ?? ''),
|
|
163
268
|
variantName: (variant.name ?? ''),
|
|
164
269
|
quantity: (li.quantity ?? 1),
|
|
165
|
-
unitAmount:
|
|
166
|
-
totalAmount:
|
|
167
|
-
currency: (
|
|
270
|
+
unitAmount: amount,
|
|
271
|
+
totalAmount: amount * (li.quantity ?? 1),
|
|
272
|
+
currency: (sessionCurrency ?? 'USD'),
|
|
168
273
|
imageUrl: (variant.imageUrl ?? ''),
|
|
169
274
|
};
|
|
170
275
|
});
|
|
@@ -173,7 +278,7 @@ export class CheckoutModule {
|
|
|
173
278
|
id: cs.id,
|
|
174
279
|
storeId: cs.storeId,
|
|
175
280
|
checkoutToken: cs.checkoutToken,
|
|
176
|
-
currency: (
|
|
281
|
+
currency: (sessionCurrency ?? 'USD'),
|
|
177
282
|
items,
|
|
178
283
|
totals: {
|
|
179
284
|
subtotal: (summary.subtotalAmount ?? 0),
|
|
@@ -181,7 +286,7 @@ export class CheckoutModule {
|
|
|
181
286
|
shipping: (summary.shippingCost ?? 0),
|
|
182
287
|
tax: (summary.totalTaxAmount ?? 0),
|
|
183
288
|
total: (summary.totalAmount ?? summaryItems.reduce((s, i) => s + (i.amount ?? 0), 0)),
|
|
184
|
-
currency: (
|
|
289
|
+
currency: (sessionCurrency ?? 'USD'),
|
|
185
290
|
},
|
|
186
291
|
customer: customer
|
|
187
292
|
? {
|
|
@@ -189,12 +294,53 @@ export class CheckoutModule {
|
|
|
189
294
|
email: customer.email,
|
|
190
295
|
firstName: customer.firstName,
|
|
191
296
|
lastName: customer.lastName,
|
|
297
|
+
phone: customer.phone,
|
|
192
298
|
}
|
|
193
299
|
: undefined,
|
|
194
|
-
shippingAddress: cs.shippingAddress,
|
|
195
|
-
billingAddress: cs.billingAddress,
|
|
300
|
+
shippingAddress: this.normalizeAddress(cs.shippingAddress),
|
|
301
|
+
billingAddress: this.normalizeAddress(cs.billingAddress),
|
|
302
|
+
selectedShippingRateId: (cs.shippingRateId ?? null),
|
|
196
303
|
metadata: cs.metadata,
|
|
197
304
|
};
|
|
198
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Map the raw API address shape (`address1`, `address2`, `postal`) onto
|
|
308
|
+
* the SDK's `Address` shape (`line1`, `line2`, `postalCode`). Without
|
|
309
|
+
* this, `session.shippingAddress.line1` is silently undefined after a
|
|
310
|
+
* reload — the type was lying about the actual key names — which is
|
|
311
|
+
* what makes the demo lose form state on refresh.
|
|
312
|
+
*/
|
|
313
|
+
normalizeAddress(raw) {
|
|
314
|
+
if (!raw || typeof raw !== 'object')
|
|
315
|
+
return undefined;
|
|
316
|
+
const a = raw;
|
|
317
|
+
const out = {
|
|
318
|
+
firstName: a.firstName,
|
|
319
|
+
lastName: a.lastName,
|
|
320
|
+
line1: (a.line1 ?? a.address1),
|
|
321
|
+
line2: (a.line2 ?? a.address2),
|
|
322
|
+
city: a.city,
|
|
323
|
+
state: a.state,
|
|
324
|
+
postalCode: (a.postalCode ?? a.postal),
|
|
325
|
+
country: a.country,
|
|
326
|
+
phone: a.phone,
|
|
327
|
+
};
|
|
328
|
+
// If every field is undefined the API returned an empty address slot.
|
|
329
|
+
// Hand back undefined so consumers can `if (session.shippingAddress)`.
|
|
330
|
+
return Object.values(out).some((v) => v !== undefined && v !== '') ? out : undefined;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Remove keys with empty-string / null / undefined values from an object.
|
|
335
|
+
* Prevents sending `""` to APIs that reject empty values (e.g. Stripe `country`).
|
|
336
|
+
*/
|
|
337
|
+
function stripEmpty(obj) {
|
|
338
|
+
const result = {};
|
|
339
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
340
|
+
if (v !== undefined && v !== null && v !== '') {
|
|
341
|
+
result[k] = v;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return (Object.keys(result).length > 0 ? result : undefined);
|
|
199
345
|
}
|
|
200
346
|
//# sourceMappingURL=checkout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../../src/core/modules/checkout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../../src/core/modules/checkout.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,cAAc;IAOzB,YACmB,IAAgB,EAChB,OAAe,EACf,aAAuC;QAFvC,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;QACf,kBAAa,GAAb,aAAa,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IAAI,CAAC,CAAC,QAAQ,CAAuB;YACpD,IAAI,EAAE,CAAC,CAAC,IAA0B;YAClC,KAAK,EAAE,CAAC,CAAC,KAA2B;YACpC,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAuB;YAC5D,OAAO,EAAE,CAAC,CAAC,OAA6B;YACxC,KAAK,EAAE,CAAC,CAAC,KAA2B;SACrC,CAAC;QACF,sEAAsE;QACtE,uEAAuE;QACvE,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACvF,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,UAAU,CAAoC,GAAM;IAC3D,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YAC9C,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAM,CAAC;AACpE,CAAC"}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
|
-
import type { Environment, PaymentSetupConfig, ExpressMethods, StoreConfig, PayResult, PayOptions, PayDirectOptions, CreateInstrumentOptions, PaymentInstrument, ThreedsSession, PaymentStatus } from '../types.js';
|
|
2
|
+
import type { Environment, PaymentSetupConfig, ExpressMethods, StoreConfig, PayResult, PayOptions, PayDirectOptions, CreateInstrumentOptions, PaymentInstrument, ThreedsSession, PaymentStatus, ProcessPaymentOptions, ProcessPaymentResult } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Full payment lifecycle -- discover APMs, tokenize, create instruments,
|
|
5
5
|
* process payments, handle 3DS, and poll for status.
|
|
6
6
|
*
|
|
7
7
|
* Wraps the same REST endpoints that plugin-sdk uses internally.
|
|
8
|
+
*
|
|
9
|
+
* @remarks PCI DSS compliance notice
|
|
10
|
+
*
|
|
11
|
+
* This SDK collects card data (PAN, expiry, CVC) in the merchant's page
|
|
12
|
+
* context and sends it directly to Basis Theory for tokenization. Card data
|
|
13
|
+
* never reaches TagadaPay servers.
|
|
14
|
+
*
|
|
15
|
+
* Because card data transits through the merchant's JavaScript environment,
|
|
16
|
+
* merchants using this SDK are responsible for **PCI DSS SAQ-A-EP**
|
|
17
|
+
* compliance. This includes quarterly ASV scans, secure page delivery
|
|
18
|
+
* (TLS), and ensuring no unauthorized scripts can access cardholder data.
|
|
19
|
+
*
|
|
20
|
+
* TagadaPay is PCI DSS Level 1 certified. The merchant's PCI scope is
|
|
21
|
+
* determined by their integration method, not by TagadaPay's certification.
|
|
22
|
+
*
|
|
23
|
+
* See: https://docs.tagada.io/developer-tools/headless-sdk/pci-compliance
|
|
8
24
|
*/
|
|
9
25
|
export declare class PaymentModule {
|
|
10
26
|
private readonly http;
|
|
@@ -15,13 +31,22 @@ export declare class PaymentModule {
|
|
|
15
31
|
* Get the full payment setup config for a checkout session.
|
|
16
32
|
* Returns a map of payment methods with their configuration
|
|
17
33
|
* (card, apple_pay, google_pay, klarna, etc.).
|
|
34
|
+
*
|
|
35
|
+
* Priority chain:
|
|
36
|
+
* 1. Explicit `paymentSetupConfig` parameter (developer override)
|
|
37
|
+
* 2. `window.__TGD_STEP_CONFIG__` injection (Tagada routing infra)
|
|
38
|
+
* 3. API fallback (`GET /api/v1/payment-methods`)
|
|
18
39
|
*/
|
|
19
|
-
getPaymentSetup(checkoutSessionId: string
|
|
40
|
+
getPaymentSetup(checkoutSessionId: string, opts?: {
|
|
41
|
+
paymentSetupConfig?: PaymentSetupConfig;
|
|
42
|
+
}): Promise<PaymentSetupConfig>;
|
|
20
43
|
/**
|
|
21
44
|
* Get express payment methods (Apple Pay, Google Pay, PayPal, etc.)
|
|
22
45
|
* filtered to only those available in the current browser.
|
|
23
46
|
*/
|
|
24
|
-
getExpressMethods(checkoutSessionId: string
|
|
47
|
+
getExpressMethods(checkoutSessionId: string, opts?: {
|
|
48
|
+
paymentSetupConfig?: PaymentSetupConfig;
|
|
49
|
+
}): Promise<ExpressMethods>;
|
|
25
50
|
/**
|
|
26
51
|
* Get store-level payment config (3DS flags, default flow ID, etc.).
|
|
27
52
|
*/
|
|
@@ -29,11 +54,21 @@ export declare class PaymentModule {
|
|
|
29
54
|
/**
|
|
30
55
|
* Convenience: return only enabled payment method keys.
|
|
31
56
|
*/
|
|
32
|
-
getEnabledMethods(checkoutSessionId: string
|
|
57
|
+
getEnabledMethods(checkoutSessionId: string, opts?: {
|
|
58
|
+
paymentSetupConfig?: PaymentSetupConfig;
|
|
59
|
+
}): Promise<string[]>;
|
|
33
60
|
/**
|
|
34
61
|
* Tokenize a card using @tagadapay/core-js.
|
|
35
62
|
* Requires `@tagadapay/core-js` to be installed as a peer dependency.
|
|
36
63
|
*
|
|
64
|
+
* Card data is sent directly to Basis Theory for tokenization and never
|
|
65
|
+
* reaches TagadaPay servers. The returned `tagadaToken` is safe to pass
|
|
66
|
+
* to the TagadaPay API.
|
|
67
|
+
*
|
|
68
|
+
* **PCI note:** Using this method means card data passes through your
|
|
69
|
+
* JavaScript environment. You are responsible for PCI DSS SAQ-A-EP
|
|
70
|
+
* compliance. See https://docs.tagada.io/developer-tools/headless-sdk/pci-compliance
|
|
71
|
+
*
|
|
37
72
|
* @returns tagadaToken (base64 string) and rawToken with SCA metadata.
|
|
38
73
|
*/
|
|
39
74
|
tokenizeCard(card: {
|
|
@@ -106,6 +141,59 @@ export declare class PaymentModule {
|
|
|
106
141
|
processorId: string;
|
|
107
142
|
paymentFlowId?: string;
|
|
108
143
|
}): Promise<PayResult>;
|
|
144
|
+
/**
|
|
145
|
+
* Initiate a Stripe Express Checkout payment (Apple Pay, Google Pay, Link, etc.).
|
|
146
|
+
*
|
|
147
|
+
* Calls `pay-v2` with `isExpress: true`, which returns a `clientSecret` in
|
|
148
|
+
* `payment.requireActionData.metadata.stripeExpressCheckout.clientSecret`.
|
|
149
|
+
* The caller must then call `stripe.confirmPayment()` with that secret.
|
|
150
|
+
*
|
|
151
|
+
* Used by the `StripeExpressCheckout` class and `useStripeExpress` hook.
|
|
152
|
+
* Not typically called directly — use the Stripe integration classes instead.
|
|
153
|
+
*/
|
|
154
|
+
processStripeExpress(opts: {
|
|
155
|
+
checkoutSessionId: string;
|
|
156
|
+
processorId: string;
|
|
157
|
+
paymentMethod: string;
|
|
158
|
+
}): Promise<PayResult>;
|
|
159
|
+
/**
|
|
160
|
+
* Process a payment end-to-end: pay, handle 3DS / redirects, poll until done.
|
|
161
|
+
*
|
|
162
|
+
* This is the **recommended** way to process payments. It wraps `pay()`, detects
|
|
163
|
+
* `requireAction`, runs 3DS challenges (if `@tagadapay/core-js` is installed),
|
|
164
|
+
* and polls until a terminal status.
|
|
165
|
+
*
|
|
166
|
+
* Returns a discriminated union so you can pattern-match on `result.status`:
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* const result = await payment.processPayment({
|
|
171
|
+
* checkoutSessionId: session.id,
|
|
172
|
+
* tagadaToken,
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* switch (result.status) {
|
|
176
|
+
* case 'succeeded':
|
|
177
|
+
* console.log('Paid!', result.payment.id);
|
|
178
|
+
* break;
|
|
179
|
+
* case 'requires_redirect':
|
|
180
|
+
* // In browser: window.location.href = result.redirectUrl
|
|
181
|
+
* // The React hook handles this automatically.
|
|
182
|
+
* break;
|
|
183
|
+
* case 'failed':
|
|
184
|
+
* console.error(result.error);
|
|
185
|
+
* break;
|
|
186
|
+
* }
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
processPayment(opts: ProcessPaymentOptions): Promise<ProcessPaymentResult>;
|
|
190
|
+
/**
|
|
191
|
+
* Resume a payment after the user returns from a redirect (3DS, processor auth, APM).
|
|
192
|
+
*
|
|
193
|
+
* Called automatically by `usePayment()` in React when it detects return-URL params.
|
|
194
|
+
* You can also call it manually in non-React apps.
|
|
195
|
+
*/
|
|
196
|
+
resumeAfterRedirect(paymentId: string): Promise<ProcessPaymentResult>;
|
|
109
197
|
/** Get current status of a payment. */
|
|
110
198
|
getPaymentStatus(paymentId: string): Promise<PaymentStatus>;
|
|
111
199
|
/**
|
|
@@ -118,6 +206,34 @@ export declare class PaymentModule {
|
|
|
118
206
|
}): Promise<PaymentStatus>;
|
|
119
207
|
/** Finalize a payment after a 3DS challenge completes. */
|
|
120
208
|
completeAfter3ds(paymentId: string): Promise<PaymentStatus>;
|
|
209
|
+
/** Tell the server this action has been seen / is being processed. */
|
|
210
|
+
markActionProcessed(paymentId: string): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* Route a payment action to the appropriate handler.
|
|
213
|
+
* Returns `requires_redirect` for browser-level redirects,
|
|
214
|
+
* or attempts 3DS inline and polls to completion.
|
|
215
|
+
*/
|
|
216
|
+
private handlePaymentAction;
|
|
217
|
+
/**
|
|
218
|
+
* Extract redirect info from actionData.
|
|
219
|
+
* Works for processor_auth (GET or POST), redirect, and any unknown type with a URL.
|
|
220
|
+
*/
|
|
221
|
+
private extractRedirect;
|
|
222
|
+
/**
|
|
223
|
+
* Run a 3DS challenge using @tagadapay/core-js.
|
|
224
|
+
* If core-js is not installed, falls back to redirect.
|
|
225
|
+
*/
|
|
226
|
+
private handleThreedsAuth;
|
|
227
|
+
/**
|
|
228
|
+
* Poll until the payment reaches a terminal status, then return a ProcessPaymentResult.
|
|
229
|
+
* Also handles new requireAction that may appear during polling.
|
|
230
|
+
*/
|
|
231
|
+
private pollUntilDone;
|
|
232
|
+
/**
|
|
233
|
+
* Read paymentSetupConfig from the Tagada routing injection.
|
|
234
|
+
* Only available when running on Tagada infra (not on external hosting like Vercel).
|
|
235
|
+
*/
|
|
236
|
+
private readInjectedStepConfig;
|
|
121
237
|
private loadCoreJs;
|
|
122
238
|
}
|
|
123
239
|
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -1 +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,
|
|
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,EACb,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;GAqBG;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;;;;;;;;;OASG;IACG,eAAe,CACnB,iBAAiB,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