@xpayeg/sdk 1.0.1 → 2.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/CHANGELOG.md +19 -0
- package/README.md +3 -11
- package/dist/index.d.cts +26 -10
- package/dist/index.d.mts +26 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @xpayeg/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
### Major Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#331](https://github.com/xpayeg/xpay/pull/331) [`bdc6a48`](https://github.com/xpayeg/xpay/commit/bdc6a4865f8c0326a4c0eb3dd20808e1207d682a) Thanks [@Elmosh](https://github.com/Elmosh)! - **Breaking:** `returnUrl` is removed from `confirmPayment()` options. The return destination is always the checkout session's `afterCompletion.redirect.url`, set server-side at session creation.
|
|
9
|
+
|
|
10
|
+
The URL is sent to the bank during authentication, before the browser leaves your page, so a value passed at confirm time could only ever conflict with what the bank already received. Delete `returnUrl` from `confirmPayment()` and set `afterCompletion.redirect.url` on `createSession`. `redirect: "always"` now follows that destination.
|
|
11
|
+
|
|
12
|
+
**Breaking:** `afterCompletion` is now required for `uiMode: "embedded"` and `uiMode: "custom"`, and must be `type: "redirect"`. That URL is where the bank returns when authentication takes over the full page, which happens in in-app browsers where an embedded challenge cannot run. `hosted_confirmation` is rejected for these modes since those integrations run on your own site and there is no XPay page to return to.
|
|
13
|
+
|
|
14
|
+
Also fixed: the 3DS challenge now renders at the size declared to the issuer (previously cropped or oversized), the overlay waits for the issuer's page to paint instead of showing an empty frame, and a challenge that cannot run in an iframe takes over the full tab instead of failing silently.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
- [#333](https://github.com/xpayeg/xpay/pull/333) [`3dcea81`](https://github.com/xpayeg/xpay/commit/3dcea81b3e3f67267624105560c38f2615c35d96) Thanks [@Elmosh](https://github.com/Elmosh)! - Documentation: the `redirect: "always"` tables and examples now state that the destination is the checkout session's `afterCompletion.redirect.url`, set server-side at session creation.
|
|
21
|
+
|
|
3
22
|
## 1.0.1
|
|
4
23
|
### Patch Changes
|
|
5
24
|
|
package/README.md
CHANGED
|
@@ -231,18 +231,10 @@ await checkout.confirm({
|
|
|
231
231
|
| `redirect` | Behavior |
|
|
232
232
|
|---|---|
|
|
233
233
|
| Not set (default) | `"if_required"` — returns result to your code |
|
|
234
|
-
| `"always"` | Redirects to
|
|
234
|
+
| `"always"` | Redirects to the session's `afterCompletion.redirect.url` |
|
|
235
235
|
| `"if_required"` | Returns result to your code — no redirect |
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
```javascript
|
|
240
|
-
await checkout.confirm({
|
|
241
|
-
customerDetails: { email, name },
|
|
242
|
-
redirect: 'always',
|
|
243
|
-
returnUrl: 'https://mysite.com/custom-success', // Overrides server URL
|
|
244
|
-
});
|
|
245
|
-
```
|
|
237
|
+
Your server sets that URL when it creates the session. XPay navigates there unchanged, appending nothing.
|
|
246
238
|
|
|
247
239
|
### Pre-validation with `submit()`
|
|
248
240
|
|
|
@@ -466,7 +458,7 @@ elements.changeAppearance({ colorMode: 'light' });
|
|
|
466
458
|
|
|
467
459
|
## API Reference
|
|
468
460
|
|
|
469
|
-
### `loadXPay(publishableKey
|
|
461
|
+
### `loadXPay(publishableKey)`
|
|
470
462
|
|
|
471
463
|
Loads the XPay SDK from CDN. Returns a Promise. Call at module level, not inside components.
|
|
472
464
|
|
package/dist/index.d.cts
CHANGED
|
@@ -749,7 +749,11 @@ interface ChargeCardDetailsDto {
|
|
|
749
749
|
expYear: number;
|
|
750
750
|
funding: string;
|
|
751
751
|
last4: string;
|
|
752
|
-
|
|
752
|
+
/**
|
|
753
|
+
* Payment rails the transaction rode (e.g. mastercard for a Meeza card). Null until the charge is processed by the gateway.
|
|
754
|
+
* @nullable
|
|
755
|
+
*/
|
|
756
|
+
network: string | null;
|
|
753
757
|
/** Card fingerprint for identifying the same card across customers */
|
|
754
758
|
fingerprint: string;
|
|
755
759
|
threeDSecure: ThreeDSecureDto;
|
|
@@ -1347,6 +1351,16 @@ interface ChargeResponseDto {
|
|
|
1347
1351
|
config: ChargeConfigDto;
|
|
1348
1352
|
geocoding?: ChargeGeocodingDto;
|
|
1349
1353
|
session?: ChargeSessionDto;
|
|
1354
|
+
/**
|
|
1355
|
+
* Origin of the page where this checkout ran — the merchant's site for embedded integrations (SDK Elements / drop-in), or our hosted checkout domain for hosted checkout and payment links. Null for merchant-initiated charges (recurring / MOTO).
|
|
1356
|
+
* @nullable
|
|
1357
|
+
*/
|
|
1358
|
+
merchantOrigin?: string | null;
|
|
1359
|
+
/**
|
|
1360
|
+
* Registrable domain (eTLD+1) derived from merchantOrigin.
|
|
1361
|
+
* @nullable
|
|
1362
|
+
*/
|
|
1363
|
+
merchantDomain?: string | null;
|
|
1350
1364
|
processorCapabilities?: ProcessorCapabilitiesDto;
|
|
1351
1365
|
/**
|
|
1352
1366
|
* ID of the currently-active risk hold on this charge, if any
|
|
@@ -3158,6 +3172,8 @@ interface CheckoutSessionResponseDto {
|
|
|
3158
3172
|
clientSecret?: string;
|
|
3159
3173
|
/** Expiration timestamp (ISO 8601) */
|
|
3160
3174
|
expiresAt?: string;
|
|
3175
|
+
/** Whether this session can no longer be paid because it has expired (either swept/expired by status, or past `expiresAt`). Clients MUST render from this flag and MUST NOT re-derive expiry by comparing `expiresAt` against the local clock — a customer device running fast reads a live session as dead. */
|
|
3176
|
+
isExpired: boolean;
|
|
3161
3177
|
/** Customer ID (when existing customer linked) */
|
|
3162
3178
|
customerId?: string;
|
|
3163
3179
|
/** Customer object (when customerId is provided). Contains existing customer data for prefill. */
|
|
@@ -3594,7 +3610,12 @@ interface PaymentElement extends BaseElement {
|
|
|
3594
3610
|
*
|
|
3595
3611
|
* The `redirect` option controls what happens after a successful payment:
|
|
3596
3612
|
* - `"if_required"` (default) — returns the result to your code
|
|
3597
|
-
* - `"always"` — always redirects to
|
|
3613
|
+
* - `"always"` — always redirects to the session's own destination after payment
|
|
3614
|
+
*
|
|
3615
|
+
* The destination is never set here. It is the `afterCompletion.redirect.url` you gave
|
|
3616
|
+
* when creating the checkout session, because the same address is handed to the
|
|
3617
|
+
* customer's bank during verification — before the browser leaves your page. A value
|
|
3618
|
+
* supplied from the page could only ever disagree with what the bank was already told.
|
|
3598
3619
|
*
|
|
3599
3620
|
* @example
|
|
3600
3621
|
* ```ts
|
|
@@ -3603,11 +3624,8 @@ interface PaymentElement extends BaseElement {
|
|
|
3603
3624
|
* customerDetails: { email: "user@example.com" },
|
|
3604
3625
|
* });
|
|
3605
3626
|
*
|
|
3606
|
-
* // Always redirect after payment
|
|
3607
|
-
* await checkout.confirm({
|
|
3608
|
-
* redirect: "always",
|
|
3609
|
-
* returnUrl: "https://merchant.com/success",
|
|
3610
|
-
* });
|
|
3627
|
+
* // Always redirect to the session's own destination after payment
|
|
3628
|
+
* await checkout.confirm({ redirect: "always" });
|
|
3611
3629
|
* ```
|
|
3612
3630
|
*/
|
|
3613
3631
|
interface ConfirmPaymentOptions {
|
|
@@ -3627,11 +3645,9 @@ interface ConfirmPaymentOptions {
|
|
|
3627
3645
|
/**
|
|
3628
3646
|
* Redirect behavior after payment.
|
|
3629
3647
|
* - `"if_required"` (default) — returns the result to your code; only redirects if the payment method requires it
|
|
3630
|
-
* - `"always"` — always redirects to `
|
|
3648
|
+
* - `"always"` — always redirects to the session's `afterCompletion.redirect.url` after payment. The page navigates away and the function never returns on success.
|
|
3631
3649
|
*/
|
|
3632
3650
|
redirect?: "if_required" | "always";
|
|
3633
|
-
/** URL to redirect to after payment. Overrides the session's `afterCompletion.redirect.url`. Only needed if you want a different URL than the one set server-side. */
|
|
3634
|
-
returnUrl?: string;
|
|
3635
3651
|
}
|
|
3636
3652
|
/**
|
|
3637
3653
|
* Options for creating a drop-in checkout instance.
|
package/dist/index.d.mts
CHANGED
|
@@ -749,7 +749,11 @@ interface ChargeCardDetailsDto {
|
|
|
749
749
|
expYear: number;
|
|
750
750
|
funding: string;
|
|
751
751
|
last4: string;
|
|
752
|
-
|
|
752
|
+
/**
|
|
753
|
+
* Payment rails the transaction rode (e.g. mastercard for a Meeza card). Null until the charge is processed by the gateway.
|
|
754
|
+
* @nullable
|
|
755
|
+
*/
|
|
756
|
+
network: string | null;
|
|
753
757
|
/** Card fingerprint for identifying the same card across customers */
|
|
754
758
|
fingerprint: string;
|
|
755
759
|
threeDSecure: ThreeDSecureDto;
|
|
@@ -1347,6 +1351,16 @@ interface ChargeResponseDto {
|
|
|
1347
1351
|
config: ChargeConfigDto;
|
|
1348
1352
|
geocoding?: ChargeGeocodingDto;
|
|
1349
1353
|
session?: ChargeSessionDto;
|
|
1354
|
+
/**
|
|
1355
|
+
* Origin of the page where this checkout ran — the merchant's site for embedded integrations (SDK Elements / drop-in), or our hosted checkout domain for hosted checkout and payment links. Null for merchant-initiated charges (recurring / MOTO).
|
|
1356
|
+
* @nullable
|
|
1357
|
+
*/
|
|
1358
|
+
merchantOrigin?: string | null;
|
|
1359
|
+
/**
|
|
1360
|
+
* Registrable domain (eTLD+1) derived from merchantOrigin.
|
|
1361
|
+
* @nullable
|
|
1362
|
+
*/
|
|
1363
|
+
merchantDomain?: string | null;
|
|
1350
1364
|
processorCapabilities?: ProcessorCapabilitiesDto;
|
|
1351
1365
|
/**
|
|
1352
1366
|
* ID of the currently-active risk hold on this charge, if any
|
|
@@ -3158,6 +3172,8 @@ interface CheckoutSessionResponseDto {
|
|
|
3158
3172
|
clientSecret?: string;
|
|
3159
3173
|
/** Expiration timestamp (ISO 8601) */
|
|
3160
3174
|
expiresAt?: string;
|
|
3175
|
+
/** Whether this session can no longer be paid because it has expired (either swept/expired by status, or past `expiresAt`). Clients MUST render from this flag and MUST NOT re-derive expiry by comparing `expiresAt` against the local clock — a customer device running fast reads a live session as dead. */
|
|
3176
|
+
isExpired: boolean;
|
|
3161
3177
|
/** Customer ID (when existing customer linked) */
|
|
3162
3178
|
customerId?: string;
|
|
3163
3179
|
/** Customer object (when customerId is provided). Contains existing customer data for prefill. */
|
|
@@ -3594,7 +3610,12 @@ interface PaymentElement extends BaseElement {
|
|
|
3594
3610
|
*
|
|
3595
3611
|
* The `redirect` option controls what happens after a successful payment:
|
|
3596
3612
|
* - `"if_required"` (default) — returns the result to your code
|
|
3597
|
-
* - `"always"` — always redirects to
|
|
3613
|
+
* - `"always"` — always redirects to the session's own destination after payment
|
|
3614
|
+
*
|
|
3615
|
+
* The destination is never set here. It is the `afterCompletion.redirect.url` you gave
|
|
3616
|
+
* when creating the checkout session, because the same address is handed to the
|
|
3617
|
+
* customer's bank during verification — before the browser leaves your page. A value
|
|
3618
|
+
* supplied from the page could only ever disagree with what the bank was already told.
|
|
3598
3619
|
*
|
|
3599
3620
|
* @example
|
|
3600
3621
|
* ```ts
|
|
@@ -3603,11 +3624,8 @@ interface PaymentElement extends BaseElement {
|
|
|
3603
3624
|
* customerDetails: { email: "user@example.com" },
|
|
3604
3625
|
* });
|
|
3605
3626
|
*
|
|
3606
|
-
* // Always redirect after payment
|
|
3607
|
-
* await checkout.confirm({
|
|
3608
|
-
* redirect: "always",
|
|
3609
|
-
* returnUrl: "https://merchant.com/success",
|
|
3610
|
-
* });
|
|
3627
|
+
* // Always redirect to the session's own destination after payment
|
|
3628
|
+
* await checkout.confirm({ redirect: "always" });
|
|
3611
3629
|
* ```
|
|
3612
3630
|
*/
|
|
3613
3631
|
interface ConfirmPaymentOptions {
|
|
@@ -3627,11 +3645,9 @@ interface ConfirmPaymentOptions {
|
|
|
3627
3645
|
/**
|
|
3628
3646
|
* Redirect behavior after payment.
|
|
3629
3647
|
* - `"if_required"` (default) — returns the result to your code; only redirects if the payment method requires it
|
|
3630
|
-
* - `"always"` — always redirects to `
|
|
3648
|
+
* - `"always"` — always redirects to the session's `afterCompletion.redirect.url` after payment. The page navigates away and the function never returns on success.
|
|
3631
3649
|
*/
|
|
3632
3650
|
redirect?: "if_required" | "always";
|
|
3633
|
-
/** URL to redirect to after payment. Overrides the session's `afterCompletion.redirect.url`. Only needed if you want a different URL than the one set server-side. */
|
|
3634
|
-
returnUrl?: string;
|
|
3635
3651
|
}
|
|
3636
3652
|
/**
|
|
3637
3653
|
* Options for creating a drop-in checkout instance.
|