@delopay/sdk 0.234.0 → 0.238.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/internal.cjs CHANGED
@@ -3243,6 +3243,44 @@ var Refunds = class {
3243
3243
  return this.request("POST", "/refunds/list", { body: params });
3244
3244
  }
3245
3245
  // --- OLAP extensions (Task 4.3) ---
3246
+ /**
3247
+ * Refund requests buyers raised from the customer portal, newest first.
3248
+ * Limited to the caller's shop when the caller is scoped to one.
3249
+ * `GET /refund-requests`
3250
+ */
3251
+ async listRequests(params) {
3252
+ return this.request("GET", "/refund-requests", {
3253
+ query: params
3254
+ });
3255
+ }
3256
+ /**
3257
+ * Approve a buyer's refund request with a refund of its payment that has
3258
+ * succeeded, made with `create()` after the buyer asked. Approving records
3259
+ * the decision and moves no money. A refund that is still `pending` or in
3260
+ * `review` is refused: check it again later with `retrieve()` under the same
3261
+ * refund ID and approve once it has succeeded, rather than creating another
3262
+ * refund. `POST /refund-requests/{id}/approve`
3263
+ *
3264
+ * @example
3265
+ * ```typescript
3266
+ * const refund = await delopay.refunds.create({ payment_id: request.payment_id, amount: request.amount });
3267
+ * if (refund.status === 'succeeded') {
3268
+ * await delopay.refunds.approveRequest(request.id, { refund_id: refund.refund_id });
3269
+ * }
3270
+ * // Otherwise keep refund.refund_id, check it with retrieve() and approve once it has succeeded.
3271
+ * ```
3272
+ */
3273
+ async approveRequest(requestId, params) {
3274
+ return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/approve`, {
3275
+ body: params
3276
+ });
3277
+ }
3278
+ /** Decline a buyer's refund request. The buyer sees the reply. `POST /refund-requests/{id}/decline` */
3279
+ async declineRequest(requestId, params) {
3280
+ return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/decline`, {
3281
+ body: params
3282
+ });
3283
+ }
3246
3284
  /** List refunds (profile-scoped). `POST /refunds/profile/list` */
3247
3285
  async listByProfile(params) {
3248
3286
  return this.request("POST", "/refunds/profile/list", { body: params });
@@ -7007,6 +7045,29 @@ var BuyerPortal = class {
7007
7045
  async getSession(options) {
7008
7046
  return this.request("GET", "/buyer-portal/session", { ...options });
7009
7047
  }
7048
+ /** The buyer's contact and billing details, and what they may change. */
7049
+ async getProfile(options) {
7050
+ return this.request("GET", "/buyer-portal/profile", { ...options });
7051
+ }
7052
+ /**
7053
+ * Change the buyer's contact and billing details. Fields left out stay as
7054
+ * they are; the merchant decides whether buyers may change them at all.
7055
+ */
7056
+ async updateProfile(params, options) {
7057
+ return this.request("POST", "/buyer-portal/profile", { body: params, ...options });
7058
+ }
7059
+ /**
7060
+ * Ask the shop for a refund of one of the buyer's purchases, named by its
7061
+ * `id` from `listPurchases()`. Nothing is refunded until the shop approves
7062
+ * the request with a refund.
7063
+ */
7064
+ async createRefundRequest(purchaseId, params, options) {
7065
+ return this.request(
7066
+ "POST",
7067
+ `/buyer-portal/purchases/${encodeURIComponent(purchaseId)}/refund-requests`,
7068
+ { body: params, ...options }
7069
+ );
7070
+ }
7010
7071
  async listInvoices(params, options) {
7011
7072
  return this.request("GET", "/buyer-portal/invoices", {
7012
7073
  query: params,
@@ -11585,6 +11646,21 @@ function withoutCredentialHeaders(extra) {
11585
11646
  }
11586
11647
  return out;
11587
11648
  }
11649
+ function vaultFormQuery(params) {
11650
+ const look = params?.appearance;
11651
+ return {
11652
+ locale: params?.locale,
11653
+ form_surface: look?.surface,
11654
+ form_text: look?.text,
11655
+ form_border: look?.border,
11656
+ form_accent: look?.accent,
11657
+ form_danger: look?.danger,
11658
+ form_font: look?.font,
11659
+ form_radius: look?.radius,
11660
+ form_size: look?.size,
11661
+ form_labels: look?.labels
11662
+ };
11663
+ }
11588
11664
  function withoutHeader(headers, name) {
11589
11665
  const out = {};
11590
11666
  for (const [key, value] of Object.entries(headers)) {
@@ -12004,21 +12080,31 @@ var CheckoutSession = class {
12004
12080
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
12005
12081
  */
12006
12082
  async vaultCollectSession(options, params) {
12007
- const look = params?.appearance;
12008
12083
  return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
12009
12084
  ...options,
12010
- query: {
12011
- locale: params?.locale,
12012
- form_surface: look?.surface,
12013
- form_text: look?.text,
12014
- form_border: look?.border,
12015
- form_accent: look?.accent,
12016
- form_danger: look?.danger,
12017
- form_font: look?.font,
12018
- form_radius: look?.radius,
12019
- form_size: look?.size,
12020
- form_labels: look?.labels
12021
- },
12085
+ query: vaultFormQuery(params),
12086
+ headers: this.bearerHeaders(options?.headers)
12087
+ });
12088
+ }
12089
+ /**
12090
+ * The saved cards the buyer of this payment can pay with, on a shop whose
12091
+ * vault keeps the security code itself (Enigma Vault): the cards of the
12092
+ * payment's own customer that the shop's vault holds, most recently used
12093
+ * first. A payment without a customer answers an empty list.
12094
+ *
12095
+ * Draw saved cards from this list, not from the customer's payment-method
12096
+ * list: that one also carries cards the security-code form cannot open.
12097
+ * To pay with one, mint its form with {@link vaultSecurityCodeSession},
12098
+ * and confirm with its `payment_token` once the form reports the code
12099
+ * stored.
12100
+ *
12101
+ * A shop without a vault, and a VGS shop, answer `400`.
12102
+ *
12103
+ * `GET /payment-link/{merchantId}/{paymentId}/vault/saved-cards`
12104
+ */
12105
+ async vaultSavedCards(options) {
12106
+ return this.client.request("GET", `${this.linkBase}/vault/saved-cards`, {
12107
+ ...options,
12022
12108
  headers: this.bearerHeaders(options?.headers)
12023
12109
  });
12024
12110
  }
@@ -12028,15 +12114,24 @@ var CheckoutSession = class {
12028
12114
  * vault's own form, so it never reaches the checkout; confirm with the saved
12029
12115
  * card's `payment_token` once the form reports it stored.
12030
12116
  *
12031
- * `paymentToken` is the saved card's token from the payment-method list. A
12117
+ * `paymentToken` is the saved card's token from {@link vaultSavedCards}. A
12032
12118
  * VGS shop answers `400`: VGS re-collects the code with Collect.
12033
12119
  *
12120
+ * `params.appearance` asks for a form styled to match the page, as on
12121
+ * {@link vaultCollectSession}. The styled form is the security-code field
12122
+ * alone, with no label: draw the label beside the frame, and size the frame
12123
+ * to the answer's `height`. `labels` is ignored. If the vault refuses the
12124
+ * styled form the answer is the plain one, without `height`.
12125
+ *
12126
+ * The form stores one code and then disables itself. After a failed
12127
+ * payment, mint a new form before the buyer tries again.
12128
+ *
12034
12129
  * `GET /payment-link/{merchantId}/{paymentId}/vault/security-code-session`
12035
12130
  */
12036
- async vaultSecurityCodeSession(paymentToken, options) {
12131
+ async vaultSecurityCodeSession(paymentToken, options, params) {
12037
12132
  return this.client.request("GET", `${this.linkBase}/vault/security-code-session`, {
12038
12133
  ...options,
12039
- query: { payment_token: paymentToken },
12134
+ query: { payment_token: paymentToken, ...vaultFormQuery(params) },
12040
12135
  headers: this.bearerHeaders(options?.headers)
12041
12136
  });
12042
12137
  }