@delopay/sdk 0.87.0 → 0.91.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/dist/{chunk-DQ36QCU7.js → chunk-BWTQ34HP.js} +115 -1
- package/dist/{chunk-DQ36QCU7.js.map → chunk-BWTQ34HP.js.map} +1 -1
- package/dist/index.cjs +114 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -3
- package/dist/index.d.ts +143 -3
- package/dist/index.js +1 -1
- package/dist/internal.cjs +114 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5378,6 +5378,14 @@ function withoutCredentialHeaders(extra) {
|
|
|
5378
5378
|
}
|
|
5379
5379
|
return out;
|
|
5380
5380
|
}
|
|
5381
|
+
function withoutHeader(headers, name) {
|
|
5382
|
+
const out = {};
|
|
5383
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
5384
|
+
if (key.toLowerCase() === name) continue;
|
|
5385
|
+
out[key] = value;
|
|
5386
|
+
}
|
|
5387
|
+
return out;
|
|
5388
|
+
}
|
|
5381
5389
|
var CheckoutSession = class {
|
|
5382
5390
|
constructor(options) {
|
|
5383
5391
|
this.merchantId = options.merchantId;
|
|
@@ -5424,6 +5432,112 @@ var CheckoutSession = class {
|
|
|
5424
5432
|
}
|
|
5425
5433
|
return this.clientSecret;
|
|
5426
5434
|
}
|
|
5435
|
+
/**
|
|
5436
|
+
* The hosted checkout's bootstrap payload for a one-time payment —
|
|
5437
|
+
* `CheckoutDetails` while payable, a status view once settled.
|
|
5438
|
+
*
|
|
5439
|
+
* Deliberately unauthenticated: a `pay_` link bootstraps before any
|
|
5440
|
+
* credential exists, so no credential header is ever attached (caller
|
|
5441
|
+
* extras are still stripped of credentials). The response is a large
|
|
5442
|
+
* discriminated union owned by the consuming checkout, which keeps its
|
|
5443
|
+
* own types and runtime gates — hence the loose return type.
|
|
5444
|
+
*
|
|
5445
|
+
* `theme` is the route's one declared query parameter (a named checkout
|
|
5446
|
+
* variant, backend#793). `locale` travels as `Accept-Language` — the only
|
|
5447
|
+
* channel the backend's locale resolution reads; a `?locale=` query is
|
|
5448
|
+
* silently ignored by this route.
|
|
5449
|
+
*
|
|
5450
|
+
* `GET /payment-link/data/{merchantId}/{paymentId}`
|
|
5451
|
+
*/
|
|
5452
|
+
async fetchCheckoutData(params, options) {
|
|
5453
|
+
return this.client.request(
|
|
5454
|
+
"GET",
|
|
5455
|
+
`/payment-link/data/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
|
|
5456
|
+
{
|
|
5457
|
+
query: { theme: params?.theme },
|
|
5458
|
+
...options,
|
|
5459
|
+
headers: {
|
|
5460
|
+
...params?.locale ? {
|
|
5461
|
+
...withoutHeader(withoutCredentialHeaders(options?.headers), "accept-language"),
|
|
5462
|
+
"Accept-Language": params.locale
|
|
5463
|
+
} : withoutCredentialHeaders(options?.headers)
|
|
5464
|
+
}
|
|
5465
|
+
}
|
|
5466
|
+
);
|
|
5467
|
+
}
|
|
5468
|
+
/**
|
|
5469
|
+
* The subscription twin of {@link CheckoutSession.fetchCheckoutData}: the
|
|
5470
|
+
* bootstrap payload for a `sub_` checkout. Authenticated with the
|
|
5471
|
+
* subscription's client secret (construct the session with the `sub_…` id
|
|
5472
|
+
* in the `paymentId` slot). `locale` travels as `Accept-Language`, same
|
|
5473
|
+
* as {@link CheckoutSession.fetchCheckoutData}.
|
|
5474
|
+
*
|
|
5475
|
+
* `GET /subscriptions/data/{merchantId}/{subscriptionId}`
|
|
5476
|
+
*/
|
|
5477
|
+
async fetchSubscriptionData(params, options) {
|
|
5478
|
+
return this.client.request(
|
|
5479
|
+
"GET",
|
|
5480
|
+
`/subscriptions/data/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
|
|
5481
|
+
{
|
|
5482
|
+
...options,
|
|
5483
|
+
headers: {
|
|
5484
|
+
...params?.locale ? {
|
|
5485
|
+
...withoutHeader(this.bearerHeaders(options?.headers), "accept-language"),
|
|
5486
|
+
"Accept-Language": params.locale
|
|
5487
|
+
} : this.bearerHeaders(options?.headers)
|
|
5488
|
+
}
|
|
5489
|
+
}
|
|
5490
|
+
);
|
|
5491
|
+
}
|
|
5492
|
+
/**
|
|
5493
|
+
* Report buyer/device signals for rails that never reach
|
|
5494
|
+
* `/payments/{id}/confirm` (the Stripe SAQ-A rail: raw cards, Apple Pay,
|
|
5495
|
+
* Google Pay). Same telemetry contract as
|
|
5496
|
+
* {@link CheckoutSession.recordEvent}: sent with `keepalive: true`, and
|
|
5497
|
+
* failures resolve instead of rejecting — signals must never block or
|
|
5498
|
+
* break a checkout. Unauthenticated by design.
|
|
5499
|
+
*
|
|
5500
|
+
* `POST /payment-link/client-signals/{merchantId}/{paymentId}`
|
|
5501
|
+
*/
|
|
5502
|
+
async reportClientSignals(params, options) {
|
|
5503
|
+
try {
|
|
5504
|
+
await this.client.request(
|
|
5505
|
+
"POST",
|
|
5506
|
+
`/payment-link/client-signals/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,
|
|
5507
|
+
{
|
|
5508
|
+
body: params,
|
|
5509
|
+
keepalive: true,
|
|
5510
|
+
...options,
|
|
5511
|
+
headers: withoutCredentialHeaders(options?.headers)
|
|
5512
|
+
}
|
|
5513
|
+
);
|
|
5514
|
+
} catch {
|
|
5515
|
+
}
|
|
5516
|
+
}
|
|
5517
|
+
/**
|
|
5518
|
+
* Confirm a subscription (PayPal approval rail). The client secret is
|
|
5519
|
+
* attached automatically; the shop's profile id travels as the
|
|
5520
|
+
* `X-Profile-Id` header the subscription routes require.
|
|
5521
|
+
*
|
|
5522
|
+
* `POST /subscriptions/{subscriptionId}/confirm` (publishable key)
|
|
5523
|
+
*/
|
|
5524
|
+
async confirmSubscription(subscriptionId, profileId, params, options) {
|
|
5525
|
+
return this.client.request(
|
|
5526
|
+
"POST",
|
|
5527
|
+
`/subscriptions/${encodeURIComponent(subscriptionId)}/confirm`,
|
|
5528
|
+
{
|
|
5529
|
+
body: { ...params, client_secret: this.requireClientSecret() },
|
|
5530
|
+
...options,
|
|
5531
|
+
// Strip any caller-supplied x-profile-id first (case-insensitively):
|
|
5532
|
+
// Fetch folds duplicate headers into `caller, pro_x`, and the
|
|
5533
|
+
// subscription routes must see exactly one profile scope.
|
|
5534
|
+
headers: {
|
|
5535
|
+
...withoutHeader(this.pkHeaders(options?.headers), "x-profile-id"),
|
|
5536
|
+
"X-Profile-Id": profileId
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
5539
|
+
);
|
|
5540
|
+
}
|
|
5427
5541
|
/**
|
|
5428
5542
|
* The Paysepro rail catalog for the buyer's country.
|
|
5429
5543
|
*
|