From 27c85093ade7cf97873fa40e5d03d176ee8e3aea Mon Sep 17 00:00:00 2001 From: CodeAnimal Date: Wed, 28 Mar 2018 20:54:12 +0100 Subject: [PATCH 1/2] Add prorate option to subscription creation options with tests --- types/stripe/index.d.ts | 6 ++++++ types/stripe/stripe-tests.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 361ee4c86b..71396c0183 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -4470,6 +4470,12 @@ declare namespace Stripe { * with month or year intervals, the day of the month for subsequent invoices. */ billing_cycle_anchor?: number; + + /** + * Boolean (default true). Use with a billing_cycle_anchor timestamp to determine whether the customer will be invoiced a prorated amount until + * the anchor date. If false, the anchor period will be free (similar to a trial). + */ + prorate?: boolean; } interface ISubscriptionCreationOptions extends ISubscriptionCustCreationOptions { diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 1e7b47a3c7..3642645118 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -252,7 +252,7 @@ stripe.customers.create({ customer.cards.del("card_17xMvXBoqMA9o2xkq6W5gamx").then(function (confirmation) {}); customer.subscriptions.create({ items: [{ plan: "gold" }], trial_period_days: 7 }).then(function (subscription) { }); - customer.subscriptions.create({ items: [{ plan: "gold" }], trial_end: "now", billing_cycle_anchor: 1516881177 }).then(function (subscription) { }); + customer.subscriptions.create({ items: [{ plan: "gold" }], trial_end: "now", billing_cycle_anchor: 1516881177, prorate: true }).then(function (subscription) { }); customer.subscriptions.create({ items: [{ plan: "gold" }], trial_end: 1516881177, billing: "send_invoice", days_until_due: 7 }).then(function (subscription) { }); customer.subscriptions.create({ items: [{ plan: "gold" }], billing: "charge_automatically" }).then(function (subscription) { }); customer.subscriptions.retrieve("sub_8Eluur5KoIKxuy").then(function (subscription) { From f52ee65b221bfefeb5f209a4e8e4f6cd9444348e Mon Sep 17 00:00:00 2001 From: CodeAnimal Date: Thu, 29 Mar 2018 00:56:19 +0100 Subject: [PATCH 2/2] Add `cancel_at_period_end` option to sub update https://stripe.com/docs/api#update_subscription-cancel_at_period_end --- types/stripe/index.d.ts | 5 +++++ types/stripe/stripe-tests.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 71396c0183..c43e3357a5 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -4562,6 +4562,11 @@ declare namespace Stripe { * String, unchanged (default) or now. This allows you to reset the billing cycle of a subscription. */ billing_cycle_anchor?: "unchanged" | "now"; + + /** + * Boolean indicating whether this subscription should cancel at the end of the current period. + */ + cancel_at_period_end?: boolean; } interface ISubscriptionCancellationOptions extends IDataOptions { diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 3642645118..7a45ee9fca 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -259,7 +259,7 @@ stripe.customers.create({ customer.subscriptions.update("sub_8Eluur5KoIKxuy", { items: [{ id: subscription.items.data[0].id, plan: "silver" }] }).then(function (subscription) { }); }); customer.subscriptions.update("sub_8Eluur5KoIKxuy", { trial_end: "now", billing_cycle_anchor: "now" }); - customer.subscriptions.update("sub_8Eluur5KoIKxuy", { trial_end: 1516881177, billing: "send_invoice", days_until_due: 7, billing_cycle_anchor: "unchanged" }); + customer.subscriptions.update("sub_8Eluur5KoIKxuy", { trial_end: 1516881177, billing: "send_invoice", days_until_due: 7, billing_cycle_anchor: "unchanged", cancel_at_period_end: false }); customer.subscriptions.list().then(function (subscriptions) { }); customer.subscriptions.del("sub_8Eluur5KoIKxuy").then(function (subscription) { }); customer.subscriptions.deleteDiscount("sub_8Eluur5KoIKxuy").then(function (confirmation) { });