gembapay 1.6.0 → 1.6.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog — `gembapay` (npm)
2
2
 
3
+ ## 1.6.1 — 2026-12-06
4
+
5
+ Types and README only — no runtime change.
6
+
7
+ **Changed**
8
+ - `SubscriptionEvent`: `interval` and `intervalCount` (sent on every `subscription.plan_changed` /
9
+ `subscription.plan_change_scheduled` variant), `testMode` (dashboard "Send test" samples carry it next to
10
+ `test: true`), documented `proratedRef` (null when nothing was charged).
11
+ - `reason` on `subscription.payment` (`cycle` | `plan_change`) is sent on Stripe and PayPal; it is absent only on
12
+ older deliveries (Stripe before 2026-10-29, PayPal before 2026-12-06). README shows how to branch on it.
13
+ - There is no `webhook.test` event: "Send test" sends a sample of a real event marked `"test": true`
14
+ (the SDK never listed `webhook.test`; nothing to change in code).
15
+
3
16
  ## 1.6.0 — 2026-12-04
4
17
 
5
18
  **Added**
package/README.md CHANGED
@@ -121,7 +121,9 @@ V2 header do they fall back to the legacy `X-GembaPay-Signature` (bare hex over
121
121
  with `express.raw({ type: 'application/json' })` so the SDK sees the exact bytes that were signed
122
122
  (a parsed `express.json()` body is re-serialized as a fallback, which is less reliable).
123
123
  Subscription cycles arrive as `subscription.payment` (flat payload, no `orderId`), not
124
- `payment.completed`. Each `payment.completed` also carries `payment.paymentMethod`
124
+ `payment.completed`. Its `reason` is `cycle` (a renewal — extend access by one period) or `plan_change`
125
+ (the prorated difference of an upgrade — money, not a period); it is absent only on older deliveries
126
+ (Stripe before 2026-10-29, PayPal before 2026-12-06), treat those as `cycle`. Each `payment.completed` also carries `payment.paymentMethod`
125
127
  (`card`, `apple_pay`, `google_pay`, `link`, or `null` for PayPal).
126
128
 
127
129
  ```javascript
@@ -165,9 +167,11 @@ each event: [docs/webhooks.md](https://github.com/ivanovslavy/gembapay/blob/main
165
167
  ```javascript
166
168
  app.post('/webhooks/gembapay', express.raw({ type: 'application/json' }),
167
169
  gembapay.webhookHandler(async (event) => {
168
- if (event.test) return; // dashboard "Send test"
170
+ if (event.test) return; // dashboard "Send test" (a sample of a real event)
169
171
  switch (event.event) {
170
172
  case 'payment.completed': return markPaid(event.payment.orderId);
173
+ case 'subscription.payment':
174
+ return event.reason === 'plan_change' ? recordUpgradeCharge(event) : extendSubscription(event.subscriptionId);
171
175
  case 'payment.refunded': return recordRefund(event.refund, event.payment.fullyRefunded);
172
176
  case 'payment.expired': return cancelIfUnpaid(event.payment.orderId);
173
177
  case 'dispute.created': return holdOrder(event.dispute.orderId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gembapay",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "GembaPay — unified payment gateway for Stripe card payments and PayPal. Funds settle directly to the merchant.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -214,18 +214,31 @@ declare module 'gembapay' {
214
214
  amount?: number;
215
215
  currency?: string;
216
216
  paymentMethod?: PaymentMethod | null;
217
- /** subscription.payment: 'cycle' (renewal) or 'plan_change' (prorated upgrade difference) */
217
+ /**
218
+ * subscription.payment: 'cycle' (renewal) or 'plan_change' (prorated upgrade difference - money, not a
219
+ * period). Sent on Stripe and PayPal; absent only on older deliveries (Stripe before 2026-10-29,
220
+ * PayPal before 2026-12-06) - treat absent as 'cycle'.
221
+ */
218
222
  reason?: 'cycle' | 'plan_change' | (string & {});
219
223
  /** plan-change events */
220
224
  fromPlanToken?: string | null;
221
225
  toPlanToken?: string | null;
222
226
  fromAmount?: number | null;
223
227
  toAmount?: number | null;
228
+ /** plan-change events: billing interval of the plan (every variant) */
229
+ interval?: 'day' | 'week' | 'month' | 'year' | (string & {});
230
+ /** plan-change events: number of intervals per cycle (every variant) */
231
+ intervalCount?: number;
232
+ /** subscription.plan_changed: prorated difference charged (0 when applied at a period end) */
224
233
  prorated?: number | null;
234
+ /** subscription.plan_changed: provider reference of the prorated charge, null when nothing was charged */
225
235
  proratedRef?: string | null;
226
236
  scheduled?: boolean;
227
237
  effectiveAt?: string | null;
238
+ /** true only for dashboard "Send test" samples (eventId 'evt_test_…') - never act on them */
228
239
  test?: boolean;
240
+ /** Send-test samples also carry testMode: true; real subscription events use isTestMode */
241
+ testMode?: boolean;
229
242
  timestamp: string;
230
243
  }
231
244