@delopay/sdk 0.140.0 → 0.141.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/README.md CHANGED
@@ -211,9 +211,14 @@ const opts = { headers: { 'X-Profile-Id': profileId } };
211
211
  **Browse plans and estimate cost** before creating anything:
212
212
 
213
213
  ```typescript
214
- // List purchasable plans (or addons) with their prices
214
+ // List plans (or addons) with their prices. An item the processor lists but
215
+ // cannot sell right now comes back with `available: false` and no prices;
216
+ // skip it rather than offering it.
215
217
  const plans = await delopay.subscriptions.getItems({ item_type: 'plan' }, opts);
216
- const priceId = plans[0]?.price_id[0]?.price_id;
218
+ const priceId = plans.find((item) => item.available)?.price_id[0]?.price_id;
219
+ if (!priceId) {
220
+ throw new Error('No purchasable plan on this shop');
221
+ }
217
222
 
218
223
  // Preview what the customer will be charged
219
224
  const estimate = await delopay.subscriptions.getEstimate({ item_price_id: priceId }, opts);
@@ -3664,6 +3664,9 @@ var Verification = class {
3664
3664
  };
3665
3665
 
3666
3666
  // src/resources/webhooks.ts
3667
+ function isSubscriptionLifecycleWebhook(object) {
3668
+ return typeof object.transition_id === "string";
3669
+ }
3667
3670
  function hexToBytes(hex) {
3668
3671
  if (hex.length === 0 || hex.length % 2 !== 0) return null;
3669
3672
  const bytes = new Uint8Array(hex.length / 2);
@@ -7949,6 +7952,7 @@ export {
7949
7952
  DelopayError,
7950
7953
  DelopayAuthenticationError,
7951
7954
  Search,
7955
+ isSubscriptionLifecycleWebhook,
7952
7956
  Webhooks,
7953
7957
  Analytics,
7954
7958
  AnalyticsDashboard,
@@ -8115,4 +8119,4 @@ export {
8115
8119
  decodeNativePanes,
8116
8120
  encodeNativePanes
8117
8121
  };
8118
- //# sourceMappingURL=chunk-WW33CCSB.js.map
8122
+ //# sourceMappingURL=chunk-YZABVF2X.js.map