@dineway-ai/plugin-payment 0.2.9 → 0.2.10
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/package.json
CHANGED
|
@@ -121,7 +121,11 @@ export function subscriptionProjection(
|
|
|
121
121
|
priceId: item.price.id,
|
|
122
122
|
status: subscription.pause_collection ? "paused" : subscription.status,
|
|
123
123
|
periodEnd: item.current_period_end,
|
|
124
|
-
|
|
124
|
+
// The customer portal can schedule cancellation with cancel_at alone.
|
|
125
|
+
cancelAtPeriodEnd:
|
|
126
|
+
subscription.cancel_at_period_end ||
|
|
127
|
+
(subscription.cancel_at === item.current_period_end &&
|
|
128
|
+
!["canceled", "incomplete_expired"].includes(subscription.status)),
|
|
125
129
|
verifiedAt: now,
|
|
126
130
|
lastError: null,
|
|
127
131
|
purchaseReference: purchase?.reference ?? null,
|
|
@@ -332,7 +332,7 @@ export class PaymentSubscriptionService {
|
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
334
|
const subscription = await this.stripe.subscriptions.retrieve(purchase.subscriptionId);
|
|
335
|
-
subscriptionProjection(
|
|
335
|
+
const state = subscriptionProjection(
|
|
336
336
|
subscription,
|
|
337
337
|
await store.plans(),
|
|
338
338
|
this.options.scope,
|
|
@@ -356,7 +356,7 @@ export class PaymentSubscriptionService {
|
|
|
356
356
|
{ invoice_now: false, prorate: false },
|
|
357
357
|
request,
|
|
358
358
|
);
|
|
359
|
-
else if (!
|
|
359
|
+
else if (!state.cancelAtPeriodEnd)
|
|
360
360
|
await this.stripe.subscriptions.update(
|
|
361
361
|
subscription.id,
|
|
362
362
|
{ cancel_at_period_end: true },
|