is there any way to change Automated Recurring Billing (ARB) subscription status inactive to active using authorize node.js sdk.
A canceled subscription cannot be reactivated. However, if you use ARBGetSubscriptionRequest for the cancelled subscription, the response will include a customer profile which you can use to create a new subscription.
Related
First time using Stripe's API. What Stripe Webhook events should I use to ensure a user subscription is active and paid for and how should I store it in my database?
I was thinking to set up a Webhook for invoice.paid and then inserting the period_end datetime into my database and running something like
if ( $period_end < date('Y-m-d H:i:s') ) {
//treat subscription as inactive
} else {
//treat subscription as active
}
Is that an advisable way to ensure a subscription is active (paid for)?
You should use
customer.subscription.updated
invoice.payment_failed
invoice.payment_succeeded
You need to use customer.subscription.updated event to handle the case when first time user subscribes to your product.
then use of invoice.payment_failed will inform you about the successful payment of auto payment for subscription and use of invoice.payment_failed will inform you that auto payment for your subscription is failed.
If you want to check if your subscription is active then you can use stripe.checkout.sessions.retrieve(session_id);
Background:
When creating subscriptions through the Stripe API, you can use payment_behavior: error_if_incomplete when you want Stripe to return an HTTP 402 status code in case a subscription’s first invoice cannot be paid. In this case Stripe does not create a subscription at all if the payment fails.
Question:
Is there a way to achieve the same behavior when using Stripe Checkout?
My experience is that even if the payment fails, Stripe creates a subscription with status: incomplete which is then expired if no successful payment is made within 23 hours. I've checked the parameters for creating Checkout Sessions but found no option to set payment_behavior there.
Sources:
https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
https://stripe.com/docs/api/checkout/sessions/create
Bad News
Unfortunately this is not something that can be configured presently. When Checkout creates a subscription, all the parameters not provided directly are set to the Subscription default. The default payment_behavior for a Subscription is default_incomplete.
Good News
You can achieve this behavior using Webhooks. You would listen for the invoice.payment_failed event, check the billing_reason property of the invoice is subscription_create (identifies the first invoice of a new subscription), and then cancel the related subscription.
If you are using Subscriptions and Invoices, it is recommended you use webhooks anyway to keep track of changes in status.
We are currently using Stripe to offer a subscription service with 30 days free trial. Since we don't want the customer to be able to start the free trial without authorizing one payment method we use the SetupIntent of the created Subscription to present a card input to our client. Now the issue is that even before the customer is shown the card input the subscription is already created and "paid" for because it is a free trial.
This means that we cannot listen to the initial invoice.paid Webhook to activate the account, but instead need to listen to setup_intent.succeeded. This seems a bit odd and requires us to link the SetupIntent to a Subscription. It also means that when a customer cancels the subscription process before entering their card details, that Stripe still has created an active Subscription in trial.
Is there something we can do differently, or should we just accept that the subscriptions where the SetupIntent was aborted will be inactive on the Stripe side once it tries to pay for the next (non-trial) invoices?
Stripe's docs use the Setup Intent that's created with a trialing Subscription to collect a customer's Payment Method, but for your use case it may make more sense to create your own Setup Intent up front and not create the Subscription unless the Setup Intent it successful. It'd go something like this:
Create the Setup Intent
Confirm the Setup Intent after collecting details
If successful, create the trialing Subscription
Alternatively, you could try using Checkout which does require users to submit a Payment Method even from trialing Subscriptions
I am trying to create a subscription system with PayPal for a user subscribe to a course. So far I have already made the billing agreement and this has no problems, but the problem is that I want each month or each time the subscription is paid, the user is automatically reenrolled, otherwise if it is not possible to charge (maximum 2 attempts) the subscription is canceled and they no longer have access to the course. This last part I have no idea how I could do it, basically I don't know how I can check the status of the agreement and cancel when it is not paid.
The current version of PayPal Subscriptions does not use "billing agreements". If you have integrated with billing agreements, that is the previous version of PayPal Subscriptions and you should discard that deprecated implementation and read the current documentation, which only uses: Products, Plans, and Subscriptions.
(Do not use Billing Agreements, and do not use the deprecated PayPal-Node-SDK. Use the Subscriptions API directly)
To receive notifications of when a Subscription is paid for or its status otherwise changes, integrate Webhooks.
Some other possibly useful information: How do you know if a user has paid for a subscription
How do I manage subscription using Stripe.js.
Basically, I need to create a subscription, change a subscription, delete a subscription and check if a subscription is active.
The demos and examples on the Stripe site only use PHP, Node.js, Ruby etc. They do not show how to do it using javascript and Strip.js.
Stripe.js can only be used to create a card or a bank account token in the browser. Once this is done you need to send it to your server where you would create a charge or a subscription.
The same would go to update or cancel and existing subscription and this can only happen on the server. You would offer a button in your UI for example so that your customer can cancel his subscription but you would just post to your server where you effectively cancel it.
You could also look at the list of third-party services that integrate Stripe and offer recurring payments such as Charge Rabbit or Recurly.