@delopay/sdk 0.248.0 → 0.261.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.
@@ -963,11 +963,92 @@ var Connectors = class {
963
963
  { body: params }
964
964
  );
965
965
  }
966
+ /**
967
+ * Every webhook the connector's payment provider lists for its credentials
968
+ * in one environment: Delopay's own, other connector accounts', former
969
+ * addresses' and other integrations'.
970
+ * `GET /account/{merchantId}/connectors/webhooks/{connectorId}/provider`
971
+ *
972
+ * Available for Stripe, PayPal, Airwallex, Whop and Adyen. Destinations are
973
+ * masked; `capabilities` says which changes the provider allows and
974
+ * `editable` whether the caller may make them.
975
+ */
976
+ async listProviderWebhooks(merchantId, connectorId, environment) {
977
+ return this.request("GET", providerWebhooksPath(merchantId, connectorId), {
978
+ query: { environment }
979
+ });
980
+ }
981
+ /**
982
+ * Create a webhook at the provider for the merchant's own systems.
983
+ * `POST /account/{merchantId}/connectors/webhooks/{connectorId}/provider`
984
+ *
985
+ * The URL must be `https` and outside Delopay; Delopay's own webhook is
986
+ * registered with `registerWebhook`. A returned `signing_secret` is not kept
987
+ * by Delopay and cannot be read again.
988
+ */
989
+ async createProviderWebhook(merchantId, connectorId, params) {
990
+ return this.request("POST", providerWebhooksPath(merchantId, connectorId), { body: params });
991
+ }
992
+ /**
993
+ * Change one webhook at the provider.
994
+ * `PATCH /account/{merchantId}/connectors/webhooks/{connectorId}/provider/{webhookId}`
995
+ *
996
+ * Refused once the webhook changed since `fingerprint`, and for Delopay's
997
+ * own webhooks.
998
+ */
999
+ async updateProviderWebhook(merchantId, connectorId, webhookId, params) {
1000
+ return this.request(
1001
+ "PATCH",
1002
+ `${providerWebhooksPath(merchantId, connectorId)}/${encodeURIComponent(webhookId)}`,
1003
+ { body: params }
1004
+ );
1005
+ }
1006
+ /**
1007
+ * Delete one webhook at the provider.
1008
+ * `POST /account/{merchantId}/connectors/webhooks/{connectorId}/provider/{webhookId}/delete`
1009
+ *
1010
+ * Refused once the webhook changed since `fingerprint`. Deleting Delopay's
1011
+ * own webhook needs `confirm_managed: true`; another connector account's is
1012
+ * never deleted from here.
1013
+ */
1014
+ async deleteProviderWebhook(merchantId, connectorId, webhookId, params) {
1015
+ return this.request(
1016
+ "POST",
1017
+ `${providerWebhooksPath(merchantId, connectorId)}/${encodeURIComponent(webhookId)}/delete`,
1018
+ { body: params }
1019
+ );
1020
+ }
1021
+ /**
1022
+ * What "replace all" would delete and keep. Nothing is changed.
1023
+ * `GET /account/{merchantId}/connectors/webhooks/{connectorId}/provider/replace`
1024
+ */
1025
+ async previewProviderWebhookReplace(merchantId, connectorId, environment) {
1026
+ return this.request("GET", `${providerWebhooksPath(merchantId, connectorId)}/replace`, {
1027
+ query: { environment }
1028
+ });
1029
+ }
1030
+ /**
1031
+ * Keep only Delopay's webhook: delete exactly the confirmed webhooks of the
1032
+ * preview, after registering Delopay's own unless `sequence` is
1033
+ * `delete_first`.
1034
+ * `POST /account/{merchantId}/connectors/webhooks/{connectorId}/provider/replace`
1035
+ *
1036
+ * A list that changed since the preview answers `scope_changed` and deletes
1037
+ * nothing. A second replacement while one runs is refused as busy (`HE_00`).
1038
+ */
1039
+ async replaceProviderWebhooks(merchantId, connectorId, params) {
1040
+ return this.request("POST", `${providerWebhooksPath(merchantId, connectorId)}/replace`, {
1041
+ body: params
1042
+ });
1043
+ }
966
1044
  /** List available payment methods. `GET /account/payment-methods` */
967
1045
  async listPaymentMethods() {
968
1046
  return this.request("GET", "/account/payment-methods");
969
1047
  }
970
1048
  };
1049
+ function providerWebhooksPath(merchantId, connectorId) {
1050
+ return `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/provider`;
1051
+ }
971
1052
 
972
1053
  // src/resources/customers.ts
973
1054
  function toQuery(params) {
@@ -2140,6 +2221,44 @@ var PaymentMethods = class {
2140
2221
  query: params
2141
2222
  });
2142
2223
  }
2224
+ /**
2225
+ * The shop's payment buttons as the hosted checkout draws them: order,
2226
+ * labels in the shop's or caller's language, artwork, and what selecting
2227
+ * each one does. For rendering payment buttons on your own site without a
2228
+ * local table of provider names and icons.
2229
+ *
2230
+ * With a secret key, name the shop (`profile_id`) and optionally the
2231
+ * environment and a buyer context; the answer may be reused for
2232
+ * `cache.max_age_seconds` — {@link PresentationCache} does that. With a
2233
+ * publishable key, pass the payment's `client_secret` (or use
2234
+ * `CheckoutSession.paymentMethodPresentation`); that answer is never reused.
2235
+ *
2236
+ * A displayed entry is not a promise: the payment is confirmed against the
2237
+ * current configuration.
2238
+ *
2239
+ * `GET /account/payment-methods/presentation`
2240
+ *
2241
+ * @example
2242
+ * ```typescript
2243
+ * const buttons = await delopay.paymentMethods.presentation({
2244
+ * profile_id: 'pro_123',
2245
+ * country: 'DE',
2246
+ * currency: 'EUR',
2247
+ * amount: 4999,
2248
+ * locale: 'de',
2249
+ * });
2250
+ * for (const entry of buttons.entries) {
2251
+ * if (entry.kind === 'heading') renderHeading(entry.label);
2252
+ * else renderButton(entry.label, entry.sublabel, presentationIconSrc(entry));
2253
+ * }
2254
+ * ```
2255
+ */
2256
+ async presentation(params, options) {
2257
+ return this.request("GET", "/account/payment-methods/presentation", {
2258
+ query: params,
2259
+ ...options
2260
+ });
2261
+ }
2143
2262
  /**
2144
2263
  * List all saved payment methods for a customer, optionally filtered.
2145
2264
  *
@@ -5434,6 +5553,73 @@ var BuyerBlocklist = class {
5434
5553
  }
5435
5554
  };
5436
5555
 
5556
+ // src/resources/buyerConversations.ts
5557
+ var BuyerConversations = class {
5558
+ constructor(request) {
5559
+ this.request = request;
5560
+ }
5561
+ /**
5562
+ * One page of the inbox, the latest message first, filtered by shop,
5563
+ * status, assignee, mode or buyer. `GET /buyer-conversations`
5564
+ */
5565
+ async list(params) {
5566
+ return this.request("GET", "/buyer-conversations", {
5567
+ query: params
5568
+ });
5569
+ }
5570
+ /**
5571
+ * Starts the conversation with a buyer at one shop, or adds to the one that
5572
+ * exists, with a first message. `POST /buyer-conversations`
5573
+ */
5574
+ async start(params) {
5575
+ return this.request("POST", "/buyer-conversations", { body: params });
5576
+ }
5577
+ /**
5578
+ * One conversation and its newest messages, oldest first; `before` pages
5579
+ * back. `GET /buyer-conversations/{id}`
5580
+ */
5581
+ async retrieve(id, params) {
5582
+ return this.request("GET", `/buyer-conversations/${encodeURIComponent(id)}`, {
5583
+ query: params
5584
+ });
5585
+ }
5586
+ /**
5587
+ * A team member's answer. A closed conversation refuses it.
5588
+ * `POST /buyer-conversations/{id}/messages`
5589
+ */
5590
+ async reply(id, params) {
5591
+ return this.request("POST", `/buyer-conversations/${encodeURIComponent(id)}/messages`, {
5592
+ body: params
5593
+ });
5594
+ }
5595
+ /**
5596
+ * The team has read the conversation up to its last accepted message.
5597
+ * `POST /buyer-conversations/{id}/read`
5598
+ */
5599
+ async markRead(id) {
5600
+ return this.request("POST", `/buyer-conversations/${encodeURIComponent(id)}/read`);
5601
+ }
5602
+ /**
5603
+ * Hands the conversation to a team member, to the caller with `me`, or to
5604
+ * nobody with `null`. `POST /buyer-conversations/{id}/assign`
5605
+ */
5606
+ async assign(id, params) {
5607
+ return this.request("POST", `/buyer-conversations/${encodeURIComponent(id)}/assign`, {
5608
+ body: params
5609
+ });
5610
+ }
5611
+ /**
5612
+ * Closes or reopens the conversation. Closing moves no money and decides
5613
+ * no case; it stops new messages until reopened.
5614
+ * `POST /buyer-conversations/{id}/status`
5615
+ */
5616
+ async setStatus(id, params) {
5617
+ return this.request("POST", `/buyer-conversations/${encodeURIComponent(id)}/status`, {
5618
+ body: params
5619
+ });
5620
+ }
5621
+ };
5622
+
5437
5623
  // src/resources/checkoutRecovery.ts
5438
5624
  var CheckoutRecovery = class {
5439
5625
  constructor(request) {
@@ -6982,7 +7168,7 @@ var BuyerAccount = class {
6982
7168
  constructor(request) {
6983
7169
  this.request = request;
6984
7170
  }
6985
- /** Whether buyers can sign in by email on this platform, and how. */
7171
+ /** Whether buyers can sign in on this platform, and which methods are offered. */
6986
7172
  async availability(options) {
6987
7173
  return this.request("GET", "/buyer-account/availability", { ...options });
6988
7174
  }
@@ -7019,6 +7205,108 @@ var BuyerAccount = class {
7019
7205
  ...options
7020
7206
  });
7021
7207
  }
7208
+ /**
7209
+ * The shops the buyer has purchases at, once each and by name. Pass a
7210
+ * shop's `shop` to `listPurchases` to list only that shop's purchases.
7211
+ */
7212
+ async listShops(options) {
7213
+ return this.request("GET", "/buyer-account/shops", { ...options });
7214
+ }
7215
+ /**
7216
+ * The buyer's subscriptions across shops, newest first. A record the buyer
7217
+ * has not confirmed shows what a receipt carries, without its period or
7218
+ * cancellation.
7219
+ */
7220
+ async listSubscriptions(query, options) {
7221
+ return this.request("GET", "/buyer-account/subscriptions", {
7222
+ query,
7223
+ ...options
7224
+ });
7225
+ }
7226
+ /**
7227
+ * The issued invoices of the records the buyer has confirmed through a
7228
+ * shop's own link, newest first. `unconfirmed_records` says when records
7229
+ * were left out.
7230
+ */
7231
+ async listInvoices(query, options) {
7232
+ return this.request("GET", "/buyer-account/invoices", {
7233
+ query,
7234
+ ...options
7235
+ });
7236
+ }
7237
+ /** The refund requests of the records the buyer has confirmed, newest first, with the shop's decision. */
7238
+ async listRefundRequests(query, options) {
7239
+ return this.request("GET", "/buyer-account/refund-requests", {
7240
+ query,
7241
+ ...options
7242
+ });
7243
+ }
7244
+ /**
7245
+ * The cases of the records the buyer has confirmed: the refund requests
7246
+ * they sent and the disputes about their purchases, newest first, with
7247
+ * where each stands, who acts next, the outcome and the recorded steps.
7248
+ */
7249
+ async listCases(query, options) {
7250
+ return this.request("GET", "/buyer-account/cases", {
7251
+ query,
7252
+ ...options
7253
+ });
7254
+ }
7255
+ /**
7256
+ * The conversations of the records the buyer has confirmed, the latest
7257
+ * message first. `unconfirmed_records` says when other records were left out.
7258
+ */
7259
+ async listConversations(query, options) {
7260
+ return this.request("GET", "/buyer-account/conversations", {
7261
+ query,
7262
+ ...options
7263
+ });
7264
+ }
7265
+ /**
7266
+ * The conversation of a confirmed record with one shop, and its newest
7267
+ * messages, oldest first; `before` pages back. `shop` is required here.
7268
+ */
7269
+ async listRecordMessages(record, query, options) {
7270
+ return this.request("GET", `/buyer-account/records/${encodeURIComponent(record)}/messages`, {
7271
+ query,
7272
+ ...options
7273
+ });
7274
+ }
7275
+ /**
7276
+ * A message from a confirmed record to one of its shops. Sending again with
7277
+ * the same `client_message_id` returns the message the first send stored.
7278
+ */
7279
+ async sendRecordMessage(record, message, options) {
7280
+ return this.request("POST", `/buyer-account/records/${encodeURIComponent(record)}/messages`, {
7281
+ body: message,
7282
+ ...options
7283
+ });
7284
+ }
7285
+ /**
7286
+ * The buyer has read a record's conversation with one shop up to its last
7287
+ * accepted message. Answers with the buyer's conversations as they now stand.
7288
+ */
7289
+ async markRecordMessagesRead(record, query, options) {
7290
+ return this.request(
7291
+ "POST",
7292
+ `/buyer-account/records/${encodeURIComponent(record)}/messages/read`,
7293
+ {
7294
+ query,
7295
+ ...options
7296
+ }
7297
+ );
7298
+ }
7299
+ /**
7300
+ * What the buyer spent in a period: paid purchases summed per currency,
7301
+ * never converted, for the whole period, per day, week or month, per shop
7302
+ * and per kind of purchase.
7303
+ */
7304
+ async analytics(query, options) {
7305
+ return this.request("GET", "/buyer-account/analytics", {
7306
+ query,
7307
+ ...options
7308
+ });
7309
+ }
7022
7310
  /**
7023
7311
  * Confirm the record of a shop's customer portal link for the signed-in
7024
7312
  * buyer. The link's customer must carry the address the buyer signed in
@@ -7047,6 +7335,48 @@ var BuyerPortal = class {
7047
7335
  async getSession(options) {
7048
7336
  return this.request("GET", "/buyer-portal/session", { ...options });
7049
7337
  }
7338
+ /**
7339
+ * The buyer's cases at the shop: the refund requests they sent and the
7340
+ * disputes about their purchases, newest first, with where each stands, who
7341
+ * acts next, the outcome and the recorded steps.
7342
+ */
7343
+ async listCases(options) {
7344
+ return this.request("GET", "/buyer-portal/cases", { ...options });
7345
+ }
7346
+ /**
7347
+ * The buyer's conversations with the shop, the latest message first. A
7348
+ * portal link for the whole merchant lists one per shop and mode.
7349
+ */
7350
+ async listConversations(options) {
7351
+ return this.request("GET", "/buyer-portal/conversations", { ...options });
7352
+ }
7353
+ /**
7354
+ * The conversation with one shop and its newest messages, oldest first;
7355
+ * `before` pages back. A link issued for one shop may leave `shop` out.
7356
+ */
7357
+ async listMessages(query, options) {
7358
+ return this.request("GET", "/buyer-portal/messages", {
7359
+ query,
7360
+ ...options
7361
+ });
7362
+ }
7363
+ /**
7364
+ * A message to the shop. Sending again with the same `client_message_id`
7365
+ * returns the message the first send stored; a closed conversation refuses it.
7366
+ */
7367
+ async sendMessage(message, options) {
7368
+ return this.request("POST", "/buyer-portal/messages", { body: message, ...options });
7369
+ }
7370
+ /**
7371
+ * The buyer has read the conversation with the shop up to its last accepted
7372
+ * message. Answers with the buyer's conversations as they now stand.
7373
+ */
7374
+ async markMessagesRead(query, options) {
7375
+ return this.request("POST", "/buyer-portal/messages/read", {
7376
+ query,
7377
+ ...options
7378
+ });
7379
+ }
7050
7380
  /** The buyer's contact and billing details, and what they may change. */
7051
7381
  async getProfile(options) {
7052
7382
  return this.request("GET", "/buyer-portal/profile", { ...options });
@@ -8174,6 +8504,7 @@ var Delopay = class {
8174
8504
  this.availabilityOverrides = new AvailabilityOverrides(request);
8175
8505
  this.sellToRestrictions = new SellToRestrictions(request);
8176
8506
  this.buyerBlocklist = new BuyerBlocklist(request);
8507
+ this.buyerConversations = new BuyerConversations(request);
8177
8508
  this.checkoutRecovery = new CheckoutRecovery(request);
8178
8509
  this.costRules = new CostRules(request);
8179
8510
  this.externalRecords = new ExternalRecords(request);
@@ -12370,7 +12701,195 @@ var CheckoutSession = class {
12370
12701
  headers: this.pkHeaders(options?.headers)
12371
12702
  });
12372
12703
  }
12704
+ /**
12705
+ * This payment's checkout buttons, as the hosted checkout draws them: order,
12706
+ * labels, artwork, and what selecting each one does. The shop, environment,
12707
+ * currency and amount are the payment's. Ask again when the cart changes;
12708
+ * an answer is never reused for another payment.
12709
+ *
12710
+ * `GET /account/payment-methods/presentation` (publishable key + client secret)
12711
+ *
12712
+ * @param params - `country` outranks the billing address and IP
12713
+ * geolocation; `locale` names the language of the labels.
12714
+ */
12715
+ async paymentMethodPresentation(params, options) {
12716
+ return this.client.request("GET", "/account/payment-methods/presentation", {
12717
+ query: {
12718
+ client_secret: this.requireClientSecret(),
12719
+ country: params?.country,
12720
+ locale: params?.locale,
12721
+ contract_version: params?.contract_version
12722
+ },
12723
+ ...options,
12724
+ headers: this.pkHeaders(options?.headers)
12725
+ });
12726
+ }
12727
+ };
12728
+
12729
+ // src/paymentPresentation.ts
12730
+ var PRESENTATION_CONTRACT_VERSION = 1;
12731
+ var BUILTIN_PAYMENT_ICON_KEYS = [
12732
+ "wallet",
12733
+ "card",
12734
+ "bank",
12735
+ "apple",
12736
+ "google",
12737
+ "bnpl",
12738
+ "cash",
12739
+ "paypal",
12740
+ "klarna",
12741
+ "crypto"
12742
+ ];
12743
+ var SVG_OPEN = '<svg xmlns="http://www.w3.org/2000/svg"';
12744
+ function glyph(key, color) {
12745
+ const line = (body) => `${SVG_OPEN} viewBox="0 0 24 24" fill="none" stroke="${color}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`;
12746
+ switch (key) {
12747
+ case "card":
12748
+ return line('<rect x="2" y="5" width="20" height="14" rx="2"/><path d="M2 10h20"/>');
12749
+ case "bank":
12750
+ return line(
12751
+ '<path d="M3 10h18"/><path d="m12 3 9 5H3l9-5Z"/><path d="M6 10v7M10 10v7M14 10v7M18 10v7"/><path d="M3 20h18"/>'
12752
+ );
12753
+ case "bnpl":
12754
+ return line(
12755
+ '<rect x="2" y="6" width="20" height="12" rx="2"/><path d="M6 12h4"/><path d="M14 10v4"/><path d="M18 10v4"/>'
12756
+ );
12757
+ case "cash":
12758
+ return line(
12759
+ '<rect x="2" y="6" width="20" height="12" rx="2"/><circle cx="12" cy="12" r="2.5"/><path d="M6 12h.01M18 12h.01"/>'
12760
+ );
12761
+ case "apple":
12762
+ return `${SVG_OPEN} viewBox="0 0 384 512" fill="${color}"><path d="M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"/></svg>`;
12763
+ case "google":
12764
+ return `${SVG_OPEN} viewBox="0 0 48 48"><path fill="#4285F4" d="M45.12 24.5c0-1.56-.14-3.06-.4-4.5H24v8.51h11.84c-.51 2.75-2.06 5.08-4.39 6.64v5.52h7.11c4.16-3.83 6.56-9.47 6.56-16.17z"/><path fill="#34A853" d="M24 46c5.94 0 10.92-1.97 14.56-5.33l-7.11-5.52c-1.97 1.32-4.49 2.1-7.45 2.1-5.73 0-10.58-3.87-12.31-9.07H4.34v5.7C7.96 41.07 15.4 46 24 46z"/><path fill="#FBBC05" d="M11.69 28.18C11.25 26.86 11 25.45 11 24s.25-2.86.69-4.18v-5.7H4.34C2.85 17.09 2 20.45 2 24s.85 6.91 2.34 9.88l7.35-5.7z"/><path fill="#EA4335" d="M24 10.75c3.23 0 6.13 1.11 8.41 3.29l6.31-6.31C34.91 4.18 29.93 2 24 2 15.4 2 7.96 6.93 4.34 14.12l7.35 5.7c1.73-5.2 6.58-9.07 12.31-9.07z"/></svg>`;
12765
+ case "paypal":
12766
+ return `${SVG_OPEN} viewBox="0 0 32 32"><path d="M9 4h7.2c3.4 0 6 2.4 5.6 5.8-.4 3.6-3.5 6-7.1 6h-3.2L10.4 23H6.7L9 4z" fill="#003087"/><path d="M13 8.5h7.2c3.4 0 6 2.4 5.6 5.8-.4 3.6-3.5 6-7.1 6h-3.2L14.4 27.5H10.7L13 8.5z" fill="#009cde"/></svg>`;
12767
+ case "klarna":
12768
+ return `${SVG_OPEN} viewBox="0 0 24 24"><rect width="24" height="24" rx="6" fill="#FFA8CD"/><path fill="#0B051D" d="M8 6h2.7v12H8V6zm6.5 0h2.5c-.4 2.7-1.5 5-3 6.6 1.6 1.6 2.7 3.6 3.2 5.4h-2.7c-.5-1.6-1.4-3-2.7-4.2v4.2H10V12c2.1-1 3.8-3.2 4.5-6z"/></svg>`;
12769
+ case "crypto":
12770
+ return `${SVG_OPEN} viewBox="0 0 64 64"><path fill="#F7931A" d="m63.033,39.744c-4.274,17.143-21.637,27.576-38.782,23.301-17.138-4.274-27.571-21.638-23.295-38.78,4.272-17.145,21.635-27.579,38.775-23.305,17.144,4.274,27.576,21.64,23.302,38.784z"/><path fill="#FFF" d="m46.103,27.444c0.637-4.258-2.605-6.547-7.038-8.074l1.438-5.768-3.511-0.875-1.4,5.616c-0.923-0.23-1.871-0.447-2.813-0.662l1.41-5.653-3.509-0.875-1.439,5.766c-0.764-0.174-1.514-0.346-2.242-0.527l0.004-0.018-4.842-1.209-0.934,3.75s2.605,0.597,2.55,0.634c1.422,0.355,1.679,1.296,1.636,2.042l-1.638,6.571c0.098,0.025,0.225,0.061,0.365,0.117-0.117-0.029-0.242-0.061-0.371-0.092l-2.296,9.205c-0.174,0.432-0.615,1.08-1.609,0.834,0.035,0.051-2.552-0.637-2.552-0.637l-1.743,4.019,4.569,1.139c0.85,0.213,1.683,0.436,2.503,0.646l-1.453,5.834,3.507,0.875,1.439-5.772c0.958,0.26,1.888,0.5,2.798,0.726l-1.434,5.745,3.511,0.875,1.453-5.823c5.987,1.133,10.489,0.676,12.384-4.739,1.527-4.36-0.076-6.875-3.226-8.515,2.294-0.529,4.022-2.038,4.483-5.155zm-8.022,11.249c-1.085,4.36-8.426,2.003-10.806,1.412l1.928-7.729c2.38,0.594,10.012,1.77,8.878,6.317zm1.086-11.312c-0.99,3.966-7.1,1.951-9.082,1.457l1.748-7.01c1.982,0.494,8.365,1.416,7.334,5.553z"/></svg>`;
12771
+ case "wallet":
12772
+ return line(
12773
+ '<path d="M3 7a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2"/><rect x="3" y="7" width="18" height="12" rx="2"/><path d="M16 13h3"/>'
12774
+ );
12775
+ }
12776
+ }
12777
+ function isBuiltinKey(key) {
12778
+ return BUILTIN_PAYMENT_ICON_KEYS.includes(key);
12779
+ }
12780
+ function builtinPaymentIconSvg(key, color = "#1f2937") {
12781
+ return glyph(isBuiltinKey(key) ? key : "wallet", color);
12782
+ }
12783
+ function builtinPaymentIconDataUri(key, color) {
12784
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(builtinPaymentIconSvg(key, color))}`;
12785
+ }
12786
+ function presentationIconDataUri(icon, color) {
12787
+ return icon.type === "svg" ? icon.data_uri : builtinPaymentIconDataUri(icon.key, color);
12788
+ }
12789
+ function presentationIconSrc(entry, color) {
12790
+ if (entry.icon) return presentationIconDataUri(entry.icon, color);
12791
+ if (entry.fallback_icon) return builtinPaymentIconDataUri(entry.fallback_icon, color);
12792
+ return null;
12793
+ }
12794
+ function isSupportedPresentation(response) {
12795
+ return response.contract_version === PRESENTATION_CONTRACT_VERSION;
12796
+ }
12797
+ function presentationTiers(response) {
12798
+ const out = { express: [], normal: [], alternative: [] };
12799
+ for (const entry of response.entries) {
12800
+ if (entry.tier === "express") {
12801
+ const row = entry.row ?? 0;
12802
+ while (out.express.length <= row) out.express.push([]);
12803
+ out.express[row]?.push(entry);
12804
+ } else {
12805
+ out[entry.tier].push(entry);
12806
+ }
12807
+ }
12808
+ out.express = out.express.filter((row) => row.length > 0);
12809
+ return out;
12810
+ }
12811
+ function selectableEntries(response) {
12812
+ return response.entries.filter((entry) => entry.action !== void 0);
12813
+ }
12814
+ var PresentationCache = class _PresentationCache {
12815
+ constructor(options) {
12816
+ this.slots = /* @__PURE__ */ new Map();
12817
+ this.load = options.load;
12818
+ this.now = options.now ?? Date.now;
12819
+ this.maxEntries = options.maxEntries ?? 500;
12820
+ }
12821
+ /** The key two requests share exactly when DeloPay would answer them alike. */
12822
+ static keyOf(params) {
12823
+ return JSON.stringify([
12824
+ params.profile_id ?? null,
12825
+ params.environment ?? "live",
12826
+ params.locale?.toLowerCase() ?? null,
12827
+ params.country?.toUpperCase() ?? null,
12828
+ params.currency ?? null,
12829
+ params.amount ?? null,
12830
+ params.contract_version ?? PRESENTATION_CONTRACT_VERSION
12831
+ ]);
12832
+ }
12833
+ async get(params) {
12834
+ const request = {
12835
+ ...params,
12836
+ contract_version: params.contract_version ?? PRESENTATION_CONTRACT_VERSION
12837
+ };
12838
+ if (request.client_secret) {
12839
+ return { response: await this.load(request, {}), stale: false };
12840
+ }
12841
+ const key = _PresentationCache.keyOf(request);
12842
+ const slot = this.slots.get(key);
12843
+ const now = this.now();
12844
+ if (slot && now - slot.fetchedAt < slot.response.cache.max_age_seconds * 1e3) {
12845
+ return { response: slot.response, stale: false };
12846
+ }
12847
+ try {
12848
+ const response = await this.load(
12849
+ request,
12850
+ slot ? { headers: { "If-None-Match": `"${slot.response.revision}"` } } : {}
12851
+ );
12852
+ this.store(key, response, now);
12853
+ return { response, stale: false };
12854
+ } catch (error) {
12855
+ if (slot && error instanceof DelopayError && error.status === 304) {
12856
+ this.store(key, slot.response, now);
12857
+ return { response: slot.response, stale: false };
12858
+ }
12859
+ const policy = slot?.response.cache;
12860
+ const usableUntil = slot ? slot.fetchedAt + ((policy?.max_age_seconds ?? 0) + (policy?.stale_if_error_seconds ?? 0)) * 1e3 : 0;
12861
+ if (slot && isUnavailable(error) && now < usableUntil) {
12862
+ return { response: slot.response, stale: true };
12863
+ }
12864
+ if (slot && isRefusal(error)) this.slots.delete(key);
12865
+ throw error;
12866
+ }
12867
+ }
12868
+ /** Forget every answer, e.g. after the merchant changes the checkout editor. */
12869
+ clear() {
12870
+ this.slots.clear();
12871
+ }
12872
+ store(key, response, now) {
12873
+ if (response.cache.max_age_seconds <= 0) {
12874
+ this.slots.delete(key);
12875
+ return;
12876
+ }
12877
+ this.slots.delete(key);
12878
+ this.slots.set(key, { response, fetchedAt: now });
12879
+ while (this.slots.size > this.maxEntries) {
12880
+ const oldest = this.slots.keys().next().value;
12881
+ if (oldest === void 0) break;
12882
+ this.slots.delete(oldest);
12883
+ }
12884
+ }
12373
12885
  };
12886
+ function isRefusal(error) {
12887
+ return error instanceof DelopayError && error.status >= 400 && error.status < 500 && error.status !== 429;
12888
+ }
12889
+ function isUnavailable(error) {
12890
+ if (!(error instanceof DelopayError)) return false;
12891
+ return error.status === 0 || error.status === 429 || error.status >= 500;
12892
+ }
12374
12893
 
12375
12894
  // src/panes.ts
12376
12895
  var PANE_VISIBILITIES = ["always", "embedded_only", "external_only"];
@@ -12799,6 +13318,7 @@ export {
12799
13318
  AvailabilityOverrides,
12800
13319
  SellToRestrictions,
12801
13320
  BuyerBlocklist,
13321
+ BuyerConversations,
12802
13322
  CheckoutRecovery,
12803
13323
  CostRules,
12804
13324
  ExternalRecords,
@@ -12991,6 +13511,16 @@ export {
12991
13511
  applyBrandingVariables,
12992
13512
  shadowFor,
12993
13513
  CheckoutSession,
13514
+ PRESENTATION_CONTRACT_VERSION,
13515
+ BUILTIN_PAYMENT_ICON_KEYS,
13516
+ builtinPaymentIconSvg,
13517
+ builtinPaymentIconDataUri,
13518
+ presentationIconDataUri,
13519
+ presentationIconSrc,
13520
+ isSupportedPresentation,
13521
+ presentationTiers,
13522
+ selectableEntries,
13523
+ PresentationCache,
12994
13524
  paneViewVisibility,
12995
13525
  STRIPE_FALLBACK_PANE_METHODS,
12996
13526
  STRIPE_FALLBACK_PANE_CATALOG,
@@ -13020,4 +13550,4 @@ export {
13020
13550
  decodeNativePanes,
13021
13551
  encodeNativePanes
13022
13552
  };
13023
- //# sourceMappingURL=chunk-RPPCA42D.js.map
13553
+ //# sourceMappingURL=chunk-BPDN5AIB.js.map