@delopay/sdk 0.82.0 → 0.85.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-G44EQT6Q.js → chunk-HSUVEFKO.js} +578 -4
- package/dist/chunk-HSUVEFKO.js.map +1 -0
- package/dist/index.cjs +580 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1023 -9
- package/dist/index.d.ts +1023 -9
- package/dist/index.js +7 -1
- package/dist/internal.cjs +786 -3
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +314 -3
- package/dist/internal.d.ts +314 -3
- package/dist/internal.js +213 -1
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-G44EQT6Q.js.map +0 -1
|
@@ -1428,6 +1428,39 @@ var Payments = class {
|
|
|
1428
1428
|
...options
|
|
1429
1429
|
});
|
|
1430
1430
|
}
|
|
1431
|
+
/**
|
|
1432
|
+
* The status timeline of client/device observations captured while the
|
|
1433
|
+
* buyer interacted with the payment (checkout opens, confirms, redirect
|
|
1434
|
+
* legs, reported client signals), oldest first.
|
|
1435
|
+
*
|
|
1436
|
+
* `GET /payments/{paymentId}/client-context`
|
|
1437
|
+
*/
|
|
1438
|
+
async listClientContext(paymentId, options) {
|
|
1439
|
+
return this.request(
|
|
1440
|
+
"GET",
|
|
1441
|
+
`/payments/${encodeURIComponent(paymentId)}/client-context`,
|
|
1442
|
+
options
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Soft-delete a payment. Only payments whose status is in the merchant's
|
|
1447
|
+
* delete policy (see {@link Payments.getDeletePolicy}) can be deleted;
|
|
1448
|
+
* anything else fails with a precondition error.
|
|
1449
|
+
*
|
|
1450
|
+
* `DELETE /payments/{paymentId}`
|
|
1451
|
+
*/
|
|
1452
|
+
async delete(paymentId, options) {
|
|
1453
|
+
return this.request("DELETE", `/payments/${encodeURIComponent(paymentId)}`, options);
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* The effective deletable-status set for the calling merchant — lets a
|
|
1457
|
+
* dashboard show the delete action only where it is allowed.
|
|
1458
|
+
*
|
|
1459
|
+
* `GET /payments/delete-policy`
|
|
1460
|
+
*/
|
|
1461
|
+
async getDeletePolicy(options) {
|
|
1462
|
+
return this.request("GET", "/payments/delete-policy", options);
|
|
1463
|
+
}
|
|
1431
1464
|
// --- Advanced operations (Task 3.2) ---
|
|
1432
1465
|
/** Generate session tokens. `POST /payments/session-tokens` */
|
|
1433
1466
|
async sessionTokens(params) {
|
|
@@ -1498,10 +1531,30 @@ var Payments = class {
|
|
|
1498
1531
|
async listByFilter(params) {
|
|
1499
1532
|
return this.request("POST", "/payments/list", { body: params });
|
|
1500
1533
|
}
|
|
1534
|
+
/**
|
|
1535
|
+
* List payments by filter, scoped to the caller's profile (the shop-user
|
|
1536
|
+
* twin of `listByFilter`). The backend narrows to the profile from the
|
|
1537
|
+
* auth context, so `profile_id` / `project_id` must not be sent.
|
|
1538
|
+
*
|
|
1539
|
+
* Not to be confused with {@link Payments.listByProfile}, which is the GET
|
|
1540
|
+
* cursor variant and rejects this body.
|
|
1541
|
+
*
|
|
1542
|
+
* `POST /payments/profile/list`
|
|
1543
|
+
*/
|
|
1544
|
+
async listByProfileFilter(params, options) {
|
|
1545
|
+
return this.request("POST", "/payments/profile/list", { body: params, ...options });
|
|
1546
|
+
}
|
|
1501
1547
|
/** Get payment filter options. `GET /payments/filter` */
|
|
1502
1548
|
async getFilters(params) {
|
|
1503
1549
|
return this.request("GET", "/payments/filter", { query: params });
|
|
1504
1550
|
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Get payment filter options, scoped to the caller's profile.
|
|
1553
|
+
* `GET /payments/profile/filter`
|
|
1554
|
+
*/
|
|
1555
|
+
async getFiltersByProfile(params) {
|
|
1556
|
+
return this.request("GET", "/payments/profile/filter", { query: params });
|
|
1557
|
+
}
|
|
1505
1558
|
/** Get payment aggregates. `GET /payments/aggregate` */
|
|
1506
1559
|
async aggregate(params) {
|
|
1507
1560
|
return this.request("GET", "/payments/aggregate", { query: params });
|
|
@@ -1702,6 +1755,16 @@ var Profiles = class {
|
|
|
1702
1755
|
async list(accountId) {
|
|
1703
1756
|
return this.request("GET", `/account/${encodeURIComponent(accountId)}/business-profile`);
|
|
1704
1757
|
}
|
|
1758
|
+
/**
|
|
1759
|
+
* List the business profiles the caller can see at profile scope — the
|
|
1760
|
+
* `ProfileAccountRead` twin of `list()` (which needs merchant-level read).
|
|
1761
|
+
* A shop-scoped user gets exactly their own shop back.
|
|
1762
|
+
*
|
|
1763
|
+
* `GET /account/{accountId}/profile`
|
|
1764
|
+
*/
|
|
1765
|
+
async listByProfile(accountId) {
|
|
1766
|
+
return this.request("GET", `/account/${encodeURIComponent(accountId)}/profile`);
|
|
1767
|
+
}
|
|
1705
1768
|
async update(accountId, profileId, params) {
|
|
1706
1769
|
return this.request(
|
|
1707
1770
|
"POST",
|
|
@@ -2345,7 +2408,7 @@ var Shops = class {
|
|
|
2345
2408
|
/**
|
|
2346
2409
|
* Upload a logo file for a shop. The file is stored in Delopay's configured
|
|
2347
2410
|
* object store and a public HTTPS URL is returned. This method does NOT write
|
|
2348
|
-
* the URL into the shop's `payment_link_config.
|
|
2411
|
+
* the URL into the shop's `payment_link_config.logo` — call
|
|
2349
2412
|
* `shops.update` afterwards with the returned `logo_url` to persist the change.
|
|
2350
2413
|
*
|
|
2351
2414
|
* Accepts PNG, JPEG, WebP or SVG. The file must be ≤ 1 MiB.
|
|
@@ -2359,7 +2422,7 @@ var Shops = class {
|
|
|
2359
2422
|
* ```typescript
|
|
2360
2423
|
* const { logo_url } = await delopay.shops.uploadLogo('merch_1', 'pro_1', file);
|
|
2361
2424
|
* await delopay.shops.update('merch_1', 'pro_1', {
|
|
2362
|
-
* payment_link_config: {
|
|
2425
|
+
* payment_link_config: { logo: logo_url },
|
|
2363
2426
|
* });
|
|
2364
2427
|
* ```
|
|
2365
2428
|
*/
|
|
@@ -2372,6 +2435,29 @@ var Shops = class {
|
|
|
2372
2435
|
{ body: form }
|
|
2373
2436
|
);
|
|
2374
2437
|
}
|
|
2438
|
+
/**
|
|
2439
|
+
* Update only the checkout appearance (the `payment_link_config` blob:
|
|
2440
|
+
* theme, logo, colours, seller name, SDK layout/rules, DeloPay-branding
|
|
2441
|
+
* toggle) of a shop. Applied as a whole-object replace of
|
|
2442
|
+
* `payment_link_config`, mirroring the shop-update semantics.
|
|
2443
|
+
*
|
|
2444
|
+
* Gated on the dedicated `CheckoutBranding` permission, so "may restyle
|
|
2445
|
+
* the checkout" can be granted without full account/shop write.
|
|
2446
|
+
*
|
|
2447
|
+
* `POST /shops/{merchantId}/{shopId}/checkout-branding`
|
|
2448
|
+
*
|
|
2449
|
+
* @param merchantId - The merchant account ID.
|
|
2450
|
+
* @param shopId - The shop (business profile) ID to restyle.
|
|
2451
|
+
* @param params - The new `payment_link_config` blob (full replacement).
|
|
2452
|
+
* @returns The updated business profile.
|
|
2453
|
+
*/
|
|
2454
|
+
async updateCheckoutBranding(merchantId, shopId, params, options) {
|
|
2455
|
+
return this.request(
|
|
2456
|
+
"POST",
|
|
2457
|
+
`/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/checkout-branding`,
|
|
2458
|
+
{ body: params, ...options }
|
|
2459
|
+
);
|
|
2460
|
+
}
|
|
2375
2461
|
};
|
|
2376
2462
|
|
|
2377
2463
|
// src/resources/stripeConnect.ts
|
|
@@ -3237,6 +3323,283 @@ var Subscriptions = class {
|
|
|
3237
3323
|
...options
|
|
3238
3324
|
});
|
|
3239
3325
|
}
|
|
3326
|
+
/**
|
|
3327
|
+
* Resolve which of the given payments were raised by a subscription.
|
|
3328
|
+
* `POST /subscriptions/payments/lookup`
|
|
3329
|
+
*
|
|
3330
|
+
* The linkage exists in one direction only — an invoice points at the payment
|
|
3331
|
+
* it settled, and nothing is stamped on the payment — so this is the only way
|
|
3332
|
+
* to tell a subscription charge from a one-off one when you are holding a
|
|
3333
|
+
* page of payments. In particular, do not use `off_session` or the presence
|
|
3334
|
+
* of a mandate: an ordinary saved-card charge sets those identically.
|
|
3335
|
+
*
|
|
3336
|
+
* Ids that belong to no subscription are **absent** from `links` rather than
|
|
3337
|
+
* returned as an error, so match on presence:
|
|
3338
|
+
*
|
|
3339
|
+
* ```ts
|
|
3340
|
+
* const { links } = await subscriptions.lookupPayments(
|
|
3341
|
+
* { payment_ids: page.map((p) => p.payment_id) },
|
|
3342
|
+
* { headers: { 'X-Profile-Id': profileId } },
|
|
3343
|
+
* );
|
|
3344
|
+
* const bySubscription = new Map(links.map((l) => [l.payment_id, l]));
|
|
3345
|
+
* ```
|
|
3346
|
+
*
|
|
3347
|
+
* Profile-scoped like every other subscription route, and that matters more
|
|
3348
|
+
* here than elsewhere: a `payment_id` is merchant-supplied and only unique
|
|
3349
|
+
* within a merchant, so the shop is part of the question, not an
|
|
3350
|
+
* optimisation. Pass the profile that owns **the payments** — for a list
|
|
3351
|
+
* spanning several shops, group the ids by shop and call once per group.
|
|
3352
|
+
*
|
|
3353
|
+
* At most 200 ids per call.
|
|
3354
|
+
*/
|
|
3355
|
+
async lookupPayments(params, options) {
|
|
3356
|
+
return this.request("POST", "/subscriptions/payments/lookup", { body: params, ...options });
|
|
3357
|
+
}
|
|
3358
|
+
};
|
|
3359
|
+
|
|
3360
|
+
// src/resources/settlement.ts
|
|
3361
|
+
var Settlement = class {
|
|
3362
|
+
constructor(request) {
|
|
3363
|
+
this.request = request;
|
|
3364
|
+
}
|
|
3365
|
+
/**
|
|
3366
|
+
* Per-shop settlement rollup for the host merchant: unpaid totals and the
|
|
3367
|
+
* running current period, one row per shop.
|
|
3368
|
+
*
|
|
3369
|
+
* `GET /settlement/overview`
|
|
3370
|
+
*/
|
|
3371
|
+
async overview(params, options) {
|
|
3372
|
+
return this.request("GET", "/settlement/overview", {
|
|
3373
|
+
query: { test_mode: params.test_mode },
|
|
3374
|
+
...options
|
|
3375
|
+
});
|
|
3376
|
+
}
|
|
3377
|
+
/**
|
|
3378
|
+
* Live rollup of the current (not yet statemented) period.
|
|
3379
|
+
*
|
|
3380
|
+
* `GET /settlement/current`
|
|
3381
|
+
*/
|
|
3382
|
+
async current(params, options) {
|
|
3383
|
+
return this.request("GET", "/settlement/current", {
|
|
3384
|
+
query: { test_mode: params.test_mode, profile_id: params.profile_id },
|
|
3385
|
+
...options
|
|
3386
|
+
});
|
|
3387
|
+
}
|
|
3388
|
+
/**
|
|
3389
|
+
* List generated settlement statements, newest first.
|
|
3390
|
+
*
|
|
3391
|
+
* `GET /settlement/statements`
|
|
3392
|
+
*/
|
|
3393
|
+
async listStatements(params, options) {
|
|
3394
|
+
return this.request("GET", "/settlement/statements", {
|
|
3395
|
+
query: {
|
|
3396
|
+
test_mode: params.test_mode,
|
|
3397
|
+
profile_id: params.profile_id,
|
|
3398
|
+
limit: params.limit,
|
|
3399
|
+
offset: params.offset
|
|
3400
|
+
},
|
|
3401
|
+
...options
|
|
3402
|
+
});
|
|
3403
|
+
}
|
|
3404
|
+
/**
|
|
3405
|
+
* One statement with its per-connector/currency breakdown.
|
|
3406
|
+
*
|
|
3407
|
+
* `GET /settlement/statements/{statementId}`
|
|
3408
|
+
*/
|
|
3409
|
+
async retrieveStatement(statementId, options) {
|
|
3410
|
+
return this.request(
|
|
3411
|
+
"GET",
|
|
3412
|
+
`/settlement/statements/${encodeURIComponent(statementId)}`,
|
|
3413
|
+
options
|
|
3414
|
+
);
|
|
3415
|
+
}
|
|
3416
|
+
/**
|
|
3417
|
+
* Generate (or regenerate) the statement for one shop and calendar month.
|
|
3418
|
+
*
|
|
3419
|
+
* `POST /settlement/statements/generate`
|
|
3420
|
+
*/
|
|
3421
|
+
async generateStatement(params, options) {
|
|
3422
|
+
return this.request("POST", "/settlement/statements/generate", {
|
|
3423
|
+
body: params,
|
|
3424
|
+
...options
|
|
3425
|
+
});
|
|
3426
|
+
}
|
|
3427
|
+
/**
|
|
3428
|
+
* Record payout progress on a statement (`unpaid` / `partial` / `paid`).
|
|
3429
|
+
*
|
|
3430
|
+
* `POST /settlement/statements/{statementId}/payout`
|
|
3431
|
+
*/
|
|
3432
|
+
async updateStatementPayout(statementId, params, options) {
|
|
3433
|
+
return this.request(
|
|
3434
|
+
"POST",
|
|
3435
|
+
`/settlement/statements/${encodeURIComponent(statementId)}/payout`,
|
|
3436
|
+
{ body: params, ...options }
|
|
3437
|
+
);
|
|
3438
|
+
}
|
|
3439
|
+
/**
|
|
3440
|
+
* Export a statement as PDF. Returns the raw PDF bytes as a `Blob`, with
|
|
3441
|
+
* the same auth, retries and error handling as every other call — persist
|
|
3442
|
+
* or object-URL it caller-side.
|
|
3443
|
+
*
|
|
3444
|
+
* `GET /settlement/statements/{statementId}/pdf`
|
|
3445
|
+
*
|
|
3446
|
+
* @example
|
|
3447
|
+
* ```typescript
|
|
3448
|
+
* const pdf = await delopay.settlement.downloadStatementPdf('stmt_1', {
|
|
3449
|
+
* currency: 'EUR',
|
|
3450
|
+
* include_transactions: true,
|
|
3451
|
+
* });
|
|
3452
|
+
* const url = URL.createObjectURL(pdf);
|
|
3453
|
+
* ```
|
|
3454
|
+
*/
|
|
3455
|
+
async downloadStatementPdf(statementId, params, options) {
|
|
3456
|
+
return this.request("GET", `/settlement/statements/${encodeURIComponent(statementId)}/pdf`, {
|
|
3457
|
+
query: {
|
|
3458
|
+
currency: params?.currency,
|
|
3459
|
+
include_transactions: params?.include_transactions
|
|
3460
|
+
},
|
|
3461
|
+
responseType: "blob",
|
|
3462
|
+
...options
|
|
3463
|
+
});
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* The individual settled attempts of one shop's calendar month.
|
|
3467
|
+
*
|
|
3468
|
+
* `GET /settlement/lines`
|
|
3469
|
+
*/
|
|
3470
|
+
async listLines(params, options) {
|
|
3471
|
+
return this.request("GET", "/settlement/lines", {
|
|
3472
|
+
query: {
|
|
3473
|
+
profile_id: params.profile_id,
|
|
3474
|
+
year: params.year,
|
|
3475
|
+
month: params.month,
|
|
3476
|
+
test_mode: params.test_mode,
|
|
3477
|
+
limit: params.limit,
|
|
3478
|
+
offset: params.offset
|
|
3479
|
+
},
|
|
3480
|
+
...options
|
|
3481
|
+
});
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* The fee schedules that currently apply to a shop.
|
|
3485
|
+
*
|
|
3486
|
+
* `GET /settlement/fee-config`
|
|
3487
|
+
*/
|
|
3488
|
+
async feeConfig(params, options) {
|
|
3489
|
+
return this.request("GET", "/settlement/fee-config", {
|
|
3490
|
+
query: { profile_id: params.profile_id },
|
|
3491
|
+
...options
|
|
3492
|
+
});
|
|
3493
|
+
}
|
|
3494
|
+
/**
|
|
3495
|
+
* Enqueue a settlement-line backfill over historical attempts. Attempts
|
|
3496
|
+
* already covered by a line are always skipped.
|
|
3497
|
+
*
|
|
3498
|
+
* `POST /settlement/backfill`
|
|
3499
|
+
*/
|
|
3500
|
+
async backfill(params, options) {
|
|
3501
|
+
return this.request("POST", "/settlement/backfill", { body: params, ...options });
|
|
3502
|
+
}
|
|
3503
|
+
/**
|
|
3504
|
+
* Toggle whether a shop's owner can see their own settlement figures.
|
|
3505
|
+
*
|
|
3506
|
+
* `POST /settlement/shops/visibility`
|
|
3507
|
+
*/
|
|
3508
|
+
async setShopVisibility(params, options) {
|
|
3509
|
+
return this.request("POST", "/settlement/shops/visibility", {
|
|
3510
|
+
body: params,
|
|
3511
|
+
...options
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
/**
|
|
3515
|
+
* Manual adjustments recorded on a statement.
|
|
3516
|
+
*
|
|
3517
|
+
* `GET /settlement/statements/{statementId}/adjustments`
|
|
3518
|
+
*/
|
|
3519
|
+
async listStatementAdjustments(statementId, options) {
|
|
3520
|
+
return this.request(
|
|
3521
|
+
"GET",
|
|
3522
|
+
`/settlement/statements/${encodeURIComponent(statementId)}/adjustments`,
|
|
3523
|
+
options
|
|
3524
|
+
);
|
|
3525
|
+
}
|
|
3526
|
+
/**
|
|
3527
|
+
* Add a manual adjustment to a statement. Positive `amount_usd` charges
|
|
3528
|
+
* the shop (reducing their payout); negative credits them.
|
|
3529
|
+
*
|
|
3530
|
+
* `POST /settlement/statements/{statementId}/adjustments`
|
|
3531
|
+
*/
|
|
3532
|
+
async createStatementAdjustment(statementId, params, options) {
|
|
3533
|
+
return this.request(
|
|
3534
|
+
"POST",
|
|
3535
|
+
`/settlement/statements/${encodeURIComponent(statementId)}/adjustments`,
|
|
3536
|
+
{ body: params, ...options }
|
|
3537
|
+
);
|
|
3538
|
+
}
|
|
3539
|
+
/**
|
|
3540
|
+
* Remove a manual adjustment from a statement.
|
|
3541
|
+
*
|
|
3542
|
+
* `DELETE /settlement/statements/{statementId}/adjustments/{adjustmentId}`
|
|
3543
|
+
*/
|
|
3544
|
+
async deleteStatementAdjustment(statementId, adjustmentId, options) {
|
|
3545
|
+
return this.request(
|
|
3546
|
+
"DELETE",
|
|
3547
|
+
`/settlement/statements/${encodeURIComponent(statementId)}/adjustments/${encodeURIComponent(adjustmentId)}`,
|
|
3548
|
+
options
|
|
3549
|
+
);
|
|
3550
|
+
}
|
|
3551
|
+
};
|
|
3552
|
+
|
|
3553
|
+
// src/resources/operationLimits.ts
|
|
3554
|
+
var OperationLimits = class {
|
|
3555
|
+
constructor(request) {
|
|
3556
|
+
this.request = request;
|
|
3557
|
+
}
|
|
3558
|
+
/**
|
|
3559
|
+
* List the merchant's limit rules, optionally for one operation.
|
|
3560
|
+
*
|
|
3561
|
+
* `GET /operation-limits/rules`
|
|
3562
|
+
*/
|
|
3563
|
+
async listRules(params, options) {
|
|
3564
|
+
return this.request("GET", "/operation-limits/rules", {
|
|
3565
|
+
query: { operation: params?.operation },
|
|
3566
|
+
...options
|
|
3567
|
+
});
|
|
3568
|
+
}
|
|
3569
|
+
/**
|
|
3570
|
+
* Create or replace the limit rule for one target. Full-replace upsert:
|
|
3571
|
+
* absent limit fields clear that dimension.
|
|
3572
|
+
*
|
|
3573
|
+
* `PUT /operation-limits/rules`
|
|
3574
|
+
*/
|
|
3575
|
+
async upsertRule(params, options) {
|
|
3576
|
+
return this.request("PUT", "/operation-limits/rules", { body: params, ...options });
|
|
3577
|
+
}
|
|
3578
|
+
/**
|
|
3579
|
+
* Delete a limit rule.
|
|
3580
|
+
*
|
|
3581
|
+
* `DELETE /operation-limits/rules/{ruleId}`
|
|
3582
|
+
*/
|
|
3583
|
+
async deleteRule(ruleId, options) {
|
|
3584
|
+
return this.request("DELETE", `/operation-limits/rules/${encodeURIComponent(ruleId)}`, options);
|
|
3585
|
+
}
|
|
3586
|
+
/**
|
|
3587
|
+
* The merchant-level enforcement settings. An untouched merchant gets the
|
|
3588
|
+
* defaults: rolling window, admins not exempt.
|
|
3589
|
+
*
|
|
3590
|
+
* `GET /operation-limits/settings`
|
|
3591
|
+
*/
|
|
3592
|
+
async retrieveSettings(options) {
|
|
3593
|
+
return this.request("GET", "/operation-limits/settings", options);
|
|
3594
|
+
}
|
|
3595
|
+
/**
|
|
3596
|
+
* Update the enforcement settings. Only provided fields change.
|
|
3597
|
+
*
|
|
3598
|
+
* `PUT /operation-limits/settings`
|
|
3599
|
+
*/
|
|
3600
|
+
async updateSettings(params, options) {
|
|
3601
|
+
return this.request("PUT", "/operation-limits/settings", { body: params, ...options });
|
|
3602
|
+
}
|
|
3240
3603
|
};
|
|
3241
3604
|
|
|
3242
3605
|
// src/client.ts
|
|
@@ -3366,6 +3729,8 @@ var Delopay = class {
|
|
|
3366
3729
|
this.relay = new Relay(request);
|
|
3367
3730
|
this.stripeConnect = new StripeConnect(request);
|
|
3368
3731
|
this.threeDsRules = new ThreeDsRules(request);
|
|
3732
|
+
this.settlement = new Settlement(request);
|
|
3733
|
+
this.operationLimits = new OperationLimits(request);
|
|
3369
3734
|
this.subscriptions = new Subscriptions(request);
|
|
3370
3735
|
this.files = new Files(request);
|
|
3371
3736
|
this.export = new Export(request);
|
|
@@ -3489,7 +3854,8 @@ var Delopay = class {
|
|
|
3489
3854
|
method,
|
|
3490
3855
|
headers,
|
|
3491
3856
|
body: serializedBody,
|
|
3492
|
-
signal: combined.signal
|
|
3857
|
+
signal: combined.signal,
|
|
3858
|
+
...options?.keepalive !== void 0 ? { keepalive: options.keepalive } : {}
|
|
3493
3859
|
});
|
|
3494
3860
|
const requestId = response.headers?.get("x-request-id") ?? response.headers?.get("x-trace-id") ?? void 0;
|
|
3495
3861
|
emit("response", { status: response.status, method, path, requestId });
|
|
@@ -3536,6 +3902,12 @@ var Delopay = class {
|
|
|
3536
3902
|
}
|
|
3537
3903
|
throw error;
|
|
3538
3904
|
}
|
|
3905
|
+
if (options?.responseType === "blob") {
|
|
3906
|
+
return await response.blob();
|
|
3907
|
+
}
|
|
3908
|
+
if (options?.responseType === "arraybuffer") {
|
|
3909
|
+
return await response.arrayBuffer();
|
|
3910
|
+
}
|
|
3539
3911
|
const text = await response.text();
|
|
3540
3912
|
return text ? JSON.parse(text) : void 0;
|
|
3541
3913
|
} catch (err) {
|
|
@@ -4779,6 +5151,205 @@ function shadowFor(style) {
|
|
|
4779
5151
|
}
|
|
4780
5152
|
}
|
|
4781
5153
|
|
|
5154
|
+
// src/checkoutSession.ts
|
|
5155
|
+
function withoutCredentialHeaders(extra) {
|
|
5156
|
+
if (!extra) return {};
|
|
5157
|
+
const out = {};
|
|
5158
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
5159
|
+
const lower = key.toLowerCase();
|
|
5160
|
+
if (lower === "api-key" || lower === "authorization") continue;
|
|
5161
|
+
out[key] = value;
|
|
5162
|
+
}
|
|
5163
|
+
return out;
|
|
5164
|
+
}
|
|
5165
|
+
var CheckoutSession = class {
|
|
5166
|
+
constructor(options) {
|
|
5167
|
+
this.merchantId = options.merchantId;
|
|
5168
|
+
this.paymentId = options.paymentId;
|
|
5169
|
+
this.publishableKey = options.publishableKey;
|
|
5170
|
+
this.clientSecret = options.clientSecret;
|
|
5171
|
+
this.client = new Delopay("", {
|
|
5172
|
+
baseUrl: options.baseUrl,
|
|
5173
|
+
sandbox: options.sandbox,
|
|
5174
|
+
timeout: options.timeout,
|
|
5175
|
+
maxRetries: options.maxRetries,
|
|
5176
|
+
debug: options.debug,
|
|
5177
|
+
logger: options.logger
|
|
5178
|
+
});
|
|
5179
|
+
}
|
|
5180
|
+
get linkBase() {
|
|
5181
|
+
return `/payment-link/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`;
|
|
5182
|
+
}
|
|
5183
|
+
/** Headers for the client-secret bearer routes (`/payment-link/*`). */
|
|
5184
|
+
bearerHeaders(extra) {
|
|
5185
|
+
return {
|
|
5186
|
+
...withoutCredentialHeaders(extra),
|
|
5187
|
+
Authorization: `Bearer ${this.requireClientSecret()}`
|
|
5188
|
+
};
|
|
5189
|
+
}
|
|
5190
|
+
/** Headers for the publishable-key routes (`/payments/*`, `/payment-methods`). */
|
|
5191
|
+
pkHeaders(extra) {
|
|
5192
|
+
if (!this.publishableKey) {
|
|
5193
|
+
throw new DelopayError("This call requires the publishable key", {
|
|
5194
|
+
status: 0,
|
|
5195
|
+
code: "MISSING_CREDENTIAL",
|
|
5196
|
+
type: "invalid_request"
|
|
5197
|
+
});
|
|
5198
|
+
}
|
|
5199
|
+
return { ...withoutCredentialHeaders(extra), "api-key": this.publishableKey };
|
|
5200
|
+
}
|
|
5201
|
+
requireClientSecret() {
|
|
5202
|
+
if (!this.clientSecret) {
|
|
5203
|
+
throw new DelopayError("This call requires the payment client secret", {
|
|
5204
|
+
status: 0,
|
|
5205
|
+
code: "MISSING_CREDENTIAL",
|
|
5206
|
+
type: "invalid_request"
|
|
5207
|
+
});
|
|
5208
|
+
}
|
|
5209
|
+
return this.clientSecret;
|
|
5210
|
+
}
|
|
5211
|
+
/**
|
|
5212
|
+
* The Paysepro rail catalog for the buyer's country.
|
|
5213
|
+
*
|
|
5214
|
+
* `GET /payment-link/{merchantId}/{paymentId}/paysepro/methods`
|
|
5215
|
+
*
|
|
5216
|
+
* @param country - Lowercase ISO 3166-1 alpha-2 country code.
|
|
5217
|
+
*/
|
|
5218
|
+
async payseproMethods(country, options) {
|
|
5219
|
+
return this.client.request("GET", `${this.linkBase}/paysepro/methods`, {
|
|
5220
|
+
query: { cc: country },
|
|
5221
|
+
...options,
|
|
5222
|
+
headers: this.bearerHeaders(options?.headers)
|
|
5223
|
+
});
|
|
5224
|
+
}
|
|
5225
|
+
/**
|
|
5226
|
+
* The e-Payouts rail catalog for the buyer's country, plus the set of
|
|
5227
|
+
* countries that have at least one vendor.
|
|
5228
|
+
*
|
|
5229
|
+
* `GET /payment-link/{merchantId}/{paymentId}/epayouts/methods`
|
|
5230
|
+
*
|
|
5231
|
+
* @param country - Lowercase ISO 3166-1 alpha-2 country code.
|
|
5232
|
+
*/
|
|
5233
|
+
async epayoutsMethods(country, options) {
|
|
5234
|
+
return this.client.request("GET", `${this.linkBase}/epayouts/methods`, {
|
|
5235
|
+
query: { cc: country },
|
|
5236
|
+
...options,
|
|
5237
|
+
headers: this.bearerHeaders(options?.headers)
|
|
5238
|
+
});
|
|
5239
|
+
}
|
|
5240
|
+
/**
|
|
5241
|
+
* Record a buyer-side checkout event on the payment's status timeline.
|
|
5242
|
+
*
|
|
5243
|
+
* Telemetry semantics, built in so callers can genuinely fire-and-forget:
|
|
5244
|
+
* the request is sent with `keepalive: true` (it survives the document
|
|
5245
|
+
* navigating away, e.g. right before a `window.open`), and transport or
|
|
5246
|
+
* server failures resolve to `undefined` instead of rejecting — telemetry
|
|
5247
|
+
* must never break a checkout or surface an unhandled rejection. Do not
|
|
5248
|
+
* `await` this in a click handler that must stay synchronous.
|
|
5249
|
+
*
|
|
5250
|
+
* A missing client secret still throws `MISSING_CREDENTIAL`: that is a
|
|
5251
|
+
* wiring bug, not a telemetry failure.
|
|
5252
|
+
*
|
|
5253
|
+
* `POST /payment-link/{merchantId}/{paymentId}/checkout-events`
|
|
5254
|
+
*/
|
|
5255
|
+
async recordEvent(params, options) {
|
|
5256
|
+
const headers = this.bearerHeaders(options?.headers);
|
|
5257
|
+
try {
|
|
5258
|
+
return await this.client.request("POST", `${this.linkBase}/checkout-events`, {
|
|
5259
|
+
body: params,
|
|
5260
|
+
keepalive: true,
|
|
5261
|
+
...options,
|
|
5262
|
+
headers
|
|
5263
|
+
});
|
|
5264
|
+
} catch {
|
|
5265
|
+
return void 0;
|
|
5266
|
+
}
|
|
5267
|
+
}
|
|
5268
|
+
/**
|
|
5269
|
+
* A short-lived VGS Collect session for browser-side card capture.
|
|
5270
|
+
*
|
|
5271
|
+
* A 404 — or a 400 carrying the "shop has no vault" code — means the shop
|
|
5272
|
+
* has no vault configured; other errors must NOT be treated that way (a
|
|
5273
|
+
* refused vault falling back to an unprotected card pane is exactly the
|
|
5274
|
+
* bug this endpoint's error contract exists to prevent).
|
|
5275
|
+
*
|
|
5276
|
+
* `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
|
|
5277
|
+
*/
|
|
5278
|
+
async vaultCollectSession(options) {
|
|
5279
|
+
return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
|
|
5280
|
+
...options,
|
|
5281
|
+
headers: this.bearerHeaders(options?.headers)
|
|
5282
|
+
});
|
|
5283
|
+
}
|
|
5284
|
+
/**
|
|
5285
|
+
* Register the aliased card as a payment method and mint the one-shot
|
|
5286
|
+
* `payment_token` the confirm call spends.
|
|
5287
|
+
*
|
|
5288
|
+
* `POST /payment-link/{merchantId}/{paymentId}/vault/payment-method`
|
|
5289
|
+
*/
|
|
5290
|
+
async registerVaultPaymentMethod(params, options) {
|
|
5291
|
+
return this.client.request("POST", `${this.linkBase}/vault/payment-method`, {
|
|
5292
|
+
body: params,
|
|
5293
|
+
...options,
|
|
5294
|
+
headers: this.bearerHeaders(options?.headers)
|
|
5295
|
+
});
|
|
5296
|
+
}
|
|
5297
|
+
/**
|
|
5298
|
+
* The payment's current state — status polling for redirect/popup rails.
|
|
5299
|
+
*
|
|
5300
|
+
* `GET /payments/{paymentId}` (publishable key + client secret)
|
|
5301
|
+
*/
|
|
5302
|
+
async retrievePayment(options) {
|
|
5303
|
+
return this.client.request("GET", `/payments/${encodeURIComponent(this.paymentId)}`, {
|
|
5304
|
+
query: { client_secret: this.requireClientSecret() },
|
|
5305
|
+
...options,
|
|
5306
|
+
headers: this.pkHeaders(options?.headers)
|
|
5307
|
+
});
|
|
5308
|
+
}
|
|
5309
|
+
/**
|
|
5310
|
+
* Update the payment before confirmation (e.g. persist custom-field
|
|
5311
|
+
* answers as `metadata` on rails that never hit `/confirm`). The client
|
|
5312
|
+
* secret is attached automatically.
|
|
5313
|
+
*
|
|
5314
|
+
* `POST /payments/{paymentId}` (publishable key)
|
|
5315
|
+
*/
|
|
5316
|
+
async updatePayment(params, options) {
|
|
5317
|
+
return this.client.request("POST", `/payments/${encodeURIComponent(this.paymentId)}`, {
|
|
5318
|
+
body: { ...params, client_secret: this.requireClientSecret() },
|
|
5319
|
+
...options,
|
|
5320
|
+
headers: this.pkHeaders(options?.headers)
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5323
|
+
/**
|
|
5324
|
+
* Confirm the payment. The client secret is attached automatically; pass
|
|
5325
|
+
* an `Idempotency-Key` header via `options` to make retries safe.
|
|
5326
|
+
*
|
|
5327
|
+
* `POST /payments/{paymentId}/confirm` (publishable key)
|
|
5328
|
+
*/
|
|
5329
|
+
async confirmPayment(params, options) {
|
|
5330
|
+
return this.client.request("POST", `/payments/${encodeURIComponent(this.paymentId)}/confirm`, {
|
|
5331
|
+
body: { ...params, client_secret: this.requireClientSecret() },
|
|
5332
|
+
...options,
|
|
5333
|
+
headers: this.pkHeaders(options?.headers)
|
|
5334
|
+
});
|
|
5335
|
+
}
|
|
5336
|
+
/**
|
|
5337
|
+
* Payment methods available for this payment.
|
|
5338
|
+
*
|
|
5339
|
+
* `GET /payment-methods` (publishable key + client secret)
|
|
5340
|
+
*
|
|
5341
|
+
* @param params - Optional filters; `country` is the highest-precedence
|
|
5342
|
+
* geo hint, ahead of billing address and IP geolocation.
|
|
5343
|
+
*/
|
|
5344
|
+
async listPaymentMethods(params, options) {
|
|
5345
|
+
return this.client.request("GET", "/payment-methods", {
|
|
5346
|
+
query: { client_secret: this.requireClientSecret(), country: params?.country },
|
|
5347
|
+
...options,
|
|
5348
|
+
headers: this.pkHeaders(options?.headers)
|
|
5349
|
+
});
|
|
5350
|
+
}
|
|
5351
|
+
};
|
|
5352
|
+
|
|
4782
5353
|
// src/nativePanes.ts
|
|
4783
5354
|
var STRIPE_NATIVE_PANE_METHODS = [
|
|
4784
5355
|
{
|
|
@@ -5023,6 +5594,8 @@ export {
|
|
|
5023
5594
|
Regions,
|
|
5024
5595
|
AvailabilityOverrides,
|
|
5025
5596
|
Subscriptions,
|
|
5597
|
+
Settlement,
|
|
5598
|
+
OperationLimits,
|
|
5026
5599
|
Delopay,
|
|
5027
5600
|
leaf,
|
|
5028
5601
|
allOf,
|
|
@@ -5084,6 +5657,7 @@ export {
|
|
|
5084
5657
|
parseImportedBranding,
|
|
5085
5658
|
applyBrandingVariables,
|
|
5086
5659
|
shadowFor,
|
|
5660
|
+
CheckoutSession,
|
|
5087
5661
|
STRIPE_NATIVE_PANE_METHODS,
|
|
5088
5662
|
NATIVE_PANE_ICON_KEYS,
|
|
5089
5663
|
NATIVE_PANE_CATEGORY_KEYS,
|
|
@@ -5096,4 +5670,4 @@ export {
|
|
|
5096
5670
|
focusedCheckoutUrl,
|
|
5097
5671
|
CHECKOUT_EVENT_KINDS
|
|
5098
5672
|
};
|
|
5099
|
-
//# sourceMappingURL=chunk-
|
|
5673
|
+
//# sourceMappingURL=chunk-HSUVEFKO.js.map
|