b0VIM 9.1XgglenGlens-MacBook-Air-2.local~glen/code/extensionpay/ExtPay/docs/how_subscriptions_work.mdutf-8 3210#"! Utp2Had DC/- & % O N l k   87a`_^FE kjWVP&%\:po } else if (user.subscriptionStatus === 'canceled') { console.log("Your subscription will cancel soon.") } else if (user.subscriptionCancelAt && user.subscriptionCancelAt < new Date()) { extpay.openPaymentPage(); console.log("You need to update your card!"); } else if (user.subscriptionStatus === 'past_due') { console.log("You're paid!") if (user.paid) {extpay.getUser().then(user => {const extpay = ExtPay('my-extension-id');```jsBelow is example code that handles all the states a user's subscription can enter.### Example code that handles all subscription statesUsers who have canceled subscriptions cannot restart their subscriptions. They will have to create a new subscription by paying again.At the end of their billing cycle, `user.subscriptionStatus` will automatically switch to **`canceled`** and `user.paid` will be `false`. `user.subscriptionCancelAt` won't change.However, **`user.subscriptionCancelAt`** is populated with the datetime their subscription will expire.When a user cancels their subscription, it isn't canceled right away. Instead, `user.subscriptionStatus` remains `active` (and `user.paid` is `true`) through the end of the billing cycle.### When a user cancels
Stripe failed payments settings screenshot
Below is a screenshot of recommended Stripe settings for failed payments:Ideally, the customer would be notified in your extension and/or emailed by Stripe ("Send emails when card payments fail" option in the screenshot below) to update their card information when a payment fails.In your [Stripe billing settings](https://dashboard.stripe.com/settings/billing/automatic) you can define what happens after that. By default, Stripe will automatically attempt to charge the user's card a few more times before setting their `subscriptionStatus` to `canceled`.If an automatic subscription payment fails (due to an expired card, insufficient funds, cosmic rays, etc), `user.subscriptionStatus` is set to **`past_due`** and `user.paid` is `false`.### Payment FailuresAt the end of their billiThis will allow you to change the subscription status while testing your extension in development mode. You may also view the user's Stripe subscription management page if you like and test canceling / uncanceling from there.Screenshot of example subscription management page.In development, you will see this page instead:You can open this screen programmatically by running `extpay.openPaymentPage()` after the user has paid. You should allow the user to open this page from within your extension.Screenshot of example subscription management page.When users successfully pay for your extension they will see a screen that looks like this:To charge subscription payments for your extension, [register your extension](https://extensionpay.com/home/register-extension) and choose the subscription payment option.## Setup * [Recommended Stripe Billing Settings](#recommended-stripe-billing-settings) + [Example code that handles all subscription states](#example-code-that-handles-all-subscription-states) + [When a user cancels](#when-a-user-cancels) + [Payment Failures](#payment-failures) * [Subscription Lifecycle](#subscription-lifecycle) * [Setup](#setup)This document explains how browser extension subscriptions work on [ExtensionPay](https://extensionpay.com).======================================How Subscriptions Work in ExtensionPayad$ t ~{wvuNM65t s
screenshot of recommended Stripe Billing settings
Below is a screenshot of all the recommended Stripe settings for subscription payments in ExtensionPay. You should tweak these settings only after you sign up for ExtensionPay and connect a Stripe account. (You can click the image below to view a larger, more readable version.)## Recommended Stripe Billing Settings```}) } console.log("You haven't paid yet :( ") } else { console.log("We hope you enjoyed your subscription!")ad2UTS>= m l P O FED hgR.G  } else if (user.subscriptionStatus === 'canceled') { console.log("Your subscription will cancel soon.") } else if (user.subscriptionCancelAt && user.subscriptionCancelAt < new Date()) { extpay.openPaymentPage(); console.log("You need to update your card!"); } else if (user.subscriptionStatus === 'past_due') { console.log("You're paid!") if (user.paid) {extpay.getUser().then(user => {const extpay = ExtPay('my-extension-id');```jsBelow is example code that handles all the states a user's subscription can enter.### Example code that handles all subscription statesUsers who have canceled subscriptions cannot restart their subscriptions. They will have to create a new subscription by paying again.At the end of their billing cycle, `user.subscriptionStatus` will automatically switch to **`canceled`** and `user.paid` will be `false`. `user.subscriptionCancelAt` won't change.However, **`user.subscriptionCancelAt`** is populated with the datetime their subscription will expire.When a user cancels their subscription, it isn't canceled right away. Instead, `user.subscriptionStatus` remains `active` (and `user.paid` is `true`) through the end of the billing cycle.### When a user cancels
Stripe failed payments settings screenshot
Below is a screenshot of recommended Stripe settings for failed payments:Ideally, the customer would be notified in your extension and/or emailed by Stripe ("Send emails when card payments fail" option in the screenshot below) to update their card information when a payment fails.In your [Stripe billing settings](https://dashboard.stripe.com/settings/billing/automatic) you can define what happens after that. By default, Stripe will automatically attempt to charge the user's card a few more times before setting their `subscriptionStatus` to `canceled`.If an automatic subscription payment fails (due to an expired card, insufficient funds, cosmic rays, etc), `user.subscriptionStatus` is set to **`past_due`** and `user.paid` is `false`.### Payment FailuresAt the end of their billing period (for example, 1 month later), their card will be automatically charged again. If the payment succeeds their `user.subscriptionStatus` will remain `active`.When a user successfully pays for a subscription, their `subscriptionStatus` from [`extpay.getUser()`](../#4-use-extpaygetuser-to-check-a-users-paid-status) is set to **`active`** and `user.paid` is `true`.## Subscription Lifecycle