@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.
@@ -2963,6 +2963,44 @@ var Refunds = class {
2963
2963
  return this.request("POST", "/refunds/list", { body: params });
2964
2964
  }
2965
2965
  // --- OLAP extensions (Task 4.3) ---
2966
+ /**
2967
+ * Refund requests buyers raised from the customer portal, newest first.
2968
+ * Limited to the caller's shop when the caller is scoped to one.
2969
+ * `GET /refund-requests`
2970
+ */
2971
+ async listRequests(params) {
2972
+ return this.request("GET", "/refund-requests", {
2973
+ query: params
2974
+ });
2975
+ }
2976
+ /**
2977
+ * Approve a buyer's refund request with a refund of its payment that has
2978
+ * succeeded, made with `create()` after the buyer asked. Approving records
2979
+ * the decision and moves no money. A refund that is still `pending` or in
2980
+ * `review` is refused: check it again later with `retrieve()` under the same
2981
+ * refund ID and approve once it has succeeded, rather than creating another
2982
+ * refund. `POST /refund-requests/{id}/approve`
2983
+ *
2984
+ * @example
2985
+ * ```typescript
2986
+ * const refund = await delopay.refunds.create({ payment_id: request.payment_id, amount: request.amount });
2987
+ * if (refund.status === 'succeeded') {
2988
+ * await delopay.refunds.approveRequest(request.id, { refund_id: refund.refund_id });
2989
+ * }
2990
+ * // Otherwise keep refund.refund_id, check it with retrieve() and approve once it has succeeded.
2991
+ * ```
2992
+ */
2993
+ async approveRequest(requestId, params) {
2994
+ return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/approve`, {
2995
+ body: params
2996
+ });
2997
+ }
2998
+ /** Decline a buyer's refund request. The buyer sees the reply. `POST /refund-requests/{id}/decline` */
2999
+ async declineRequest(requestId, params) {
3000
+ return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/decline`, {
3001
+ body: params
3002
+ });
3003
+ }
2966
3004
  /** List refunds (profile-scoped). `POST /refunds/profile/list` */
2967
3005
  async listByProfile(params) {
2968
3006
  return this.request("POST", "/refunds/profile/list", { body: params });
@@ -6727,6 +6765,29 @@ var BuyerPortal = class {
6727
6765
  async getSession(options) {
6728
6766
  return this.request("GET", "/buyer-portal/session", { ...options });
6729
6767
  }
6768
+ /** The buyer's contact and billing details, and what they may change. */
6769
+ async getProfile(options) {
6770
+ return this.request("GET", "/buyer-portal/profile", { ...options });
6771
+ }
6772
+ /**
6773
+ * Change the buyer's contact and billing details. Fields left out stay as
6774
+ * they are; the merchant decides whether buyers may change them at all.
6775
+ */
6776
+ async updateProfile(params, options) {
6777
+ return this.request("POST", "/buyer-portal/profile", { body: params, ...options });
6778
+ }
6779
+ /**
6780
+ * Ask the shop for a refund of one of the buyer's purchases, named by its
6781
+ * `id` from `listPurchases()`. Nothing is refunded until the shop approves
6782
+ * the request with a refund.
6783
+ */
6784
+ async createRefundRequest(purchaseId, params, options) {
6785
+ return this.request(
6786
+ "POST",
6787
+ `/buyer-portal/purchases/${encodeURIComponent(purchaseId)}/refund-requests`,
6788
+ { body: params, ...options }
6789
+ );
6790
+ }
6730
6791
  async listInvoices(params, options) {
6731
6792
  return this.request("GET", "/buyer-portal/invoices", {
6732
6793
  query: params,
@@ -11305,6 +11366,21 @@ function withoutCredentialHeaders(extra) {
11305
11366
  }
11306
11367
  return out;
11307
11368
  }
11369
+ function vaultFormQuery(params) {
11370
+ const look = params?.appearance;
11371
+ return {
11372
+ locale: params?.locale,
11373
+ form_surface: look?.surface,
11374
+ form_text: look?.text,
11375
+ form_border: look?.border,
11376
+ form_accent: look?.accent,
11377
+ form_danger: look?.danger,
11378
+ form_font: look?.font,
11379
+ form_radius: look?.radius,
11380
+ form_size: look?.size,
11381
+ form_labels: look?.labels
11382
+ };
11383
+ }
11308
11384
  function withoutHeader(headers, name) {
11309
11385
  const out = {};
11310
11386
  for (const [key, value] of Object.entries(headers)) {
@@ -11724,21 +11800,31 @@ var CheckoutSession = class {
11724
11800
  * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`
11725
11801
  */
11726
11802
  async vaultCollectSession(options, params) {
11727
- const look = params?.appearance;
11728
11803
  return this.client.request("GET", `${this.linkBase}/vault/collect-session`, {
11729
11804
  ...options,
11730
- query: {
11731
- locale: params?.locale,
11732
- form_surface: look?.surface,
11733
- form_text: look?.text,
11734
- form_border: look?.border,
11735
- form_accent: look?.accent,
11736
- form_danger: look?.danger,
11737
- form_font: look?.font,
11738
- form_radius: look?.radius,
11739
- form_size: look?.size,
11740
- form_labels: look?.labels
11741
- },
11805
+ query: vaultFormQuery(params),
11806
+ headers: this.bearerHeaders(options?.headers)
11807
+ });
11808
+ }
11809
+ /**
11810
+ * The saved cards the buyer of this payment can pay with, on a shop whose
11811
+ * vault keeps the security code itself (Enigma Vault): the cards of the
11812
+ * payment's own customer that the shop's vault holds, most recently used
11813
+ * first. A payment without a customer answers an empty list.
11814
+ *
11815
+ * Draw saved cards from this list, not from the customer's payment-method
11816
+ * list: that one also carries cards the security-code form cannot open.
11817
+ * To pay with one, mint its form with {@link vaultSecurityCodeSession},
11818
+ * and confirm with its `payment_token` once the form reports the code
11819
+ * stored.
11820
+ *
11821
+ * A shop without a vault, and a VGS shop, answer `400`.
11822
+ *
11823
+ * `GET /payment-link/{merchantId}/{paymentId}/vault/saved-cards`
11824
+ */
11825
+ async vaultSavedCards(options) {
11826
+ return this.client.request("GET", `${this.linkBase}/vault/saved-cards`, {
11827
+ ...options,
11742
11828
  headers: this.bearerHeaders(options?.headers)
11743
11829
  });
11744
11830
  }
@@ -11748,15 +11834,24 @@ var CheckoutSession = class {
11748
11834
  * vault's own form, so it never reaches the checkout; confirm with the saved
11749
11835
  * card's `payment_token` once the form reports it stored.
11750
11836
  *
11751
- * `paymentToken` is the saved card's token from the payment-method list. A
11837
+ * `paymentToken` is the saved card's token from {@link vaultSavedCards}. A
11752
11838
  * VGS shop answers `400`: VGS re-collects the code with Collect.
11753
11839
  *
11840
+ * `params.appearance` asks for a form styled to match the page, as on
11841
+ * {@link vaultCollectSession}. The styled form is the security-code field
11842
+ * alone, with no label: draw the label beside the frame, and size the frame
11843
+ * to the answer's `height`. `labels` is ignored. If the vault refuses the
11844
+ * styled form the answer is the plain one, without `height`.
11845
+ *
11846
+ * The form stores one code and then disables itself. After a failed
11847
+ * payment, mint a new form before the buyer tries again.
11848
+ *
11754
11849
  * `GET /payment-link/{merchantId}/{paymentId}/vault/security-code-session`
11755
11850
  */
11756
- async vaultSecurityCodeSession(paymentToken, options) {
11851
+ async vaultSecurityCodeSession(paymentToken, options, params) {
11757
11852
  return this.client.request("GET", `${this.linkBase}/vault/security-code-session`, {
11758
11853
  ...options,
11759
- query: { payment_token: paymentToken },
11854
+ query: { payment_token: paymentToken, ...vaultFormQuery(params) },
11760
11855
  headers: this.bearerHeaders(options?.headers)
11761
11856
  });
11762
11857
  }
@@ -12611,4 +12706,4 @@ export {
12611
12706
  decodeNativePanes,
12612
12707
  encodeNativePanes
12613
12708
  };
12614
- //# sourceMappingURL=chunk-3NOAX6WN.js.map
12709
+ //# sourceMappingURL=chunk-H7EC7OQF.js.map