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.
Related
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
Currently, I working with Stripe gateway service. In my integration use only one Dashboard Stripe Account (one Publishable key + Secret key). I intend that my system create charges in two diferrentes Dashboard Stripe Account, depending others conditions.
I have analysed the "Connected accounts" using only one Dashboard Stripe Account, but is not usefull for me. I intend that each billing company have their Dashboard Stripe Account access (without mistake).
Is there any alternative beyond create customers / payment methods in both Dashboard Stripe Accounts?
pic1:
pic2:
You can build your application to manage two separate sets of keys based on the business logic for when to use one account or the other, but outside of Connect there is no other native support for something like this from Stripe. But you can absolutely do it manually. Yes, you would need to create any customers in both accounts, but this is true in a platform-connected account arrangement, too.
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
i want to implement SCA in my project.i would like to know whether SCA forces the user to complete 2 factor authentication while update,cancel,resume subscription.so i can handle the code accordingly.so far stripe didn't ask me.Thanks in advance.
SDA comes into play for authenticating online card payments. Stripe Billing has been updated to support SCA requirements.
You won't necessarily need to authenticate for all subscription changes (such as cancel or update) but you could for scenarios like a subscription signup, a card change on a subscription, or on a recurring charge on a subscription.
The following link describes the scenarios and tools you would leverage for Stripe Billing + SCA: https://stripe.com/docs/billing/migration/strong-customer-authentication#upgrading-integration
I have a subscription, I collect card details on signup with a 7 day trial, after which the subscription bills monthly.
From what I understand the subscription API is not SCA compliant. Instead
An off_session payment Intent must first be setup when collecting card details.
At the end of each month a scheduler must be triggered to attempt to charge the registered card.
Is this the case? Am I now responsible for scheduling payments?
Update
For those who want some starter code, I created a working playground here with subscriptions, frontend (react) and backend (express) on glitch.
It's not true that Stripe's Subscription API is not SCA-ready, it is, and you don't have to set up your own scheduling like that. The docs you linked to are generally aimed at processing one-off payments(like saving a customer's details and then allowing them to use them again when they re-visit your site to purchase something new, for example) as opposed to recurring ones.
https://stripe.com/docs/billing/subscriptions/payment describes how to set up a subscription in a way that is SCA-ready. While the customer is on-session on your payment page, you collect card details and create a subscription for the customer, which will generally attempt a payment for the first billing period. You then check the status of the subscription after it's created, and handle the outcomes:
the subscription is active and the payment was successful, so you can proceed with provisioning your service to the customer.
the subscription is incomplete — for SCA purposes, let's say this is because 3D Secure authentication was required for that first payment. In this case, the latest_invoice of the subscription exposes a PaymentIntent property, and you use that PaymentIntent in conjunction with your frontend code using stripe.js to walk the customer through authenticating the payment, and that activates the subscription.
the subscription is trialing — if the subscription doesn't involve an initial payment, like when using a trial period for example, you can also check if the subscription has a pending_setup_intent. You can use this on your frontend to have the customer complete a 3D Secure authentication, so that future payments(like the first one after the trial) are more likely to successfully claim an exemption and not require having the user authenticate at that point.
You can also instead use Stripe Checkout to easily collect payment details and set up a customer and subscription for you, while also handling any initial authentication that's needed : https://stripe.com/docs/payments/checkout/server#create-subscriptions
As for the recurring payments, Billing can handle that for you. You can configure you settings to automatically email the customer to complete 3D Secure if it's encountered on a recurring payment. So you can absolutely build an SCA-ready solution with the subscriptions API on Stripe.