#BidBird®
1 messages · Page 1 of 1 (latest)
Do you already have a payment method saved?
Or are you just trying to create a PI that only takes card payments?
Well, in this case I continue to receive this error "status": "requires_payment_method",
No payment method is saved.
I thought that PaymentIntent automatically set the payment method. However, I am using stripeElements new API
I suppose, for this form using card only is ok.
That bit of code above is used when the payment page is requested. It creates the PI, and then makes it available to the form, which is later updated.
I think we may need to take a step back here. Can you tell me more about what this page is trying to do?
sure. So we have this form:
Are you making a page that can either pay with new card details or use saved payment method details?
it's possible there are saved details, but I think just to get this going lets focus on new card details only.
I'm migrating from the 2018 api stripe elements
When the page renders I can see the $stripeIntent variable has this data:
"payment_method_options": { "card": { "installments": null, "mandate_options": null, "network": null, "request_three_d_secure": "automatic" } }, "payment_method_types": [ "card" ],
So, that's why it's confusing the "id": "pi_3MeL5ZKT8fxib8XB0IUEKtis", gives this error "status": "requires_payment_method",
requires_payment_method is actually the default status of payment intents https://stripe.com/docs/payments/intents
It is expected unless you pass it the ID of an already saved payment method when creating the intent
ahh, so don't be concerned?
Are you able to confirm the intent with your page? Or is it giving you some other error?
confirm the intent?
Correct, payment_method_types is what defines what kinds of payment methods can be used. requires_payment_method is referring to an actual payment method object to charge via the payment intent
Confirm is our verb for "attempt to charge"
ahh, yes, for instance the PI are created on Stripe dashboard. but they are all incomplete
Yeah, that is also just the default state. A lot of integrations will have many Incomplete payments unless they make sure to clean up unused ones after some time
Or rather that is how the default state will show up in the dashboard
ahh, we need a garbage collector!
After submitting the form,
$payment_method =
\Stripe\PaymentMethod::retrieve($stripeIntent);
$payment_method->attach(['customer' => $stripeIntent]);
Where are the payment methods stored? Isn't this a session based object?
I'm trying to submit the $stripeIntent with the form, so that these methods used. Is that correct?
cool!
So you are trying to attach a PaymentMethod after confirming a PaymentIntent?
Is there a reason you aren't just passing a Customer ID to the PaymentIntent?
Then it will be attached automatically on confirm
And no separate request necessary
ok, well, I'm not sure of the simplest way to make a charge
So I'd like to just have a customer choose the number of credits and charge them. Where would you create the customer in that simple flow?
maybe create a customer prior to the payment intent?
Yep
a lot of the docs have great stuff, but we need numerous pages and sometimes i get confused as to what's really needed... So if I should ditch the attach->customer code, that's fine
Yeah I would create the Customer just before the PaymentIntent
ok, let me give that a go.
@twilit ice so, would this be the guide you would use? https://stripe.com/docs/payments/save-during-payment?platform=web#web-create-a-customer
Yep
My question then is should I be saving this on our db?
ha
But that depends on your flow
How are you handling authentication?
Like you are going to need to know when that user logs in in the future right?
So you need that Customer ID in your Database for that at the very least
Or some association that you can rely on
We have an email based login.
ok, I have a table, looks like it was for stripe_ach_customers Is there a need for it to be ach? for example the table has our unique user_id and the stripeId
I may change the name, if the stripeId is all we need for many payment types
Yep no need for ach
ok, I'll ditch that
I'd assume that is in reference to the fact that you were only taking ach payments in the past?
Dunno
well, I'm upgrading from the 2018 elements. That didn't need a customer_id for stripe elements. But ach did. However it seems like it changed. with the new api
ok I'll try and wire this up real quick. please keep this open. thank you ~
Sure let me know
so, ok, got the db renamed. I'm wondering is this enough info on the stripeCustomer?
if (! auth()->user()->stripeCustomer()) { $stripeCustomer = \Stripe\Customer::create();
\App\Models\StripeCustomer::create([
'user_id' => auth()->user()->id,
'stripeId' => $stripeCustomer
]);
}
$stripeIntent = \Stripe\PaymentIntent::create([ 'setup_future_usage' => 'off_session',
'amount' => 500,
'currency' => 'usd',
'customer' => $stripeCustomer,],
['api_key' => $this->apiKey]);
Meaning, should I store more info on the customer at our db?
As long as you can retrieve the Customer based on your UUID then you are good in terms of making future payments for that Customer
Up to you if you want to record more info like their attached PaymentMethod or if you just want to retrieve that stuff at time of future payment
so, when the customer is created will stripe save that automatically at stripes servers with this line: $stripeCustomer = \Stripe\Customer::create();
or is that only saved by stripe with the paymentIntent
Yep that automatically creates the Customer regardless of the PaymentIntent
ahh, ok
The PaymentMethod will only be attached to the Customer if the PaymnetIntent is successfully confirmed.
interesting. What info would you recommend to save on our end? Or if we have the stripeId will that automatically pull up the customer info?