-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Stripe subscription without a payment method #1522
Comments
Heya. No this isn't possible with Cashier at the time but it's simply not needed. Cashier internally handles the confirmation for you. You can simply call the newSubscrition and create method and it'll:
If there's an error with confirming the payment like a 3D secure check then Cashier will throw an IncompletePayment exception which you can handle like: https://laravel.com/docs/10.x/billing#handling-failed-payments Hope that helps? |
Hi, yeah I know newSubscription + create does the work for you, which is great; but you have to have collected a payment method before that, right? So what I'm doing currently is (for a decoupled app, Nextjs frontend):
What I'd like to do (to follow Stripe's guide) is:
This would be easier, as you would have to only do one thing on the server. I was just wondering if this is currently possible with Cashier, otherwise it would be nice to have it in the future :) |
Heya, thank you for your explanation. This was actually possible before but since we introduced the handling of automatic payment confirmation it's no longer possible. I've sent in a PR to ignore incomplete payments when creating new subscriptions so you can get back the subscription and do the payment handling on the front end side: #1524 |
Great, thanks! |
Hello again, so I am working on this again after
I'm working around this by calling |
@grazianodev so the reason for this is because you're getting back a Cashier subscription, not a Stripe subscription. You can't use |
Okay, thanks for the explanation. |
I have a question about this. Indeed, it allows you to follow Stripe's recommendation in the integration for a subscription. Once the payment has been made, everything is OK on the Stripe Dashboard, but the subscription is not activated in the base because it has not been processed. Am I missing something, or is Cashier taking the decision of not managing the subscription when the payment is successful from this particular case ? |
Or maybe manage the subscription status from the webhook event to the DB |
@LucasLaurens yes the webhook will handle all state change to the subscription. You always need at all times a working webhook. |
Okay, thanks for your answer. I'm going to use the subscription payment method : |
I'm trying to create a Stripe subscription integration by following this Stripe guide, which I can see has been referenced in this pull request.
From what I understand, the guide basically instructs to create a customer, then create a subscription before even displaying the form to collect payment information, with the
payment_behavior
option set todefault_incomplete
(which sets the subscription's status toincomplete
), and thesave_default_payment_method
option set toon_subscription
(which means the payment method will be saved once the payment is confirmed and the subscription activated); then, when the user submits his payment information, theconfirmPayment
method offered by Stripe's JS SDK is used on the frontend to confirm the payment (which sets the subscription's status toactive
).In other words, you create the subscription on the server as incomplete without a payment method; then confirming the payment + activating the subscription + saving the payment method is all performed on the frontend using
confirmPayment
.So, I tried to create a subscription using Cashier without providing a payment method, like so:
And I can see that the subscription is actually saved to the database as
incomplete
, however I never get back the subscription object because anIncompletePayment
exception is thrown since no payment method was provided.So my question is, is there a way to create a subscription without providing a payment method?
The text was updated successfully, but these errors were encountered: