#bilalahmer

1 messages ยท Page 1 of 1 (latest)

open flameBOT
wary wigeon
#

Hi! Let me help you with this.

#

Why do you need to recreate SetupIntents?

calm cliff
#

Sorry , What do you mean by recreate SetupIntents?

wary wigeon
#

When you say you're moving to SetupIntents, what are you trying to achieve?

calm cliff
#

I already had stripe integrated in my site but most of the apis are depreciated and also i want to use google & aple pay thats why I'm moving to setup & payment intent.

#

So in the existing code before we were using data = Stripe::Charge.create(amount: value, currency: 'cad', customer: @id, description: description).to_hash
to charge the client.

#

So yesterday you guys suggested that dont use charge api anymore so to move from charge api I'm using paymentIntent .
PaymentIntent is asking for payment method.

#

So I'm getting the payment method by this code
Stripe::PaymentMethod.retrieve(Biller.from(@id).customer.default_source)

wary wigeon
#

That's right. Do you want to charge a saved Payment Method or collect a new one from the customer?

#

The status requires_payment_method means you can display the Payment Element to the customer and ask them to provide details.

calm cliff
#

But as I mentioned I will be moving to setupIntent and in setupIntent we are getting the payment method through Stripe::Checkout::Session.retrieve .

#

So my question is cant i use one API call to get the payment method ?
Regardless the user have saved his credit card into with old api or setupIntent api ?

wary wigeon
#

The Payment Method must be associated with a Customer to be reusable. If you know your Customer ID, you can retrieve it and reuse it to instantly confirm a new PaymentIntent. But you don't need that for SetupIntents. SetupIntents are designed to collect new Payment Methods for future use: https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements

calm cliff
#

whats the differenece between these two ?
Stripe::PaymentMethod.retrieve(Biller.from(@id).customer.default_source)
and
Stripe::Checkout::Session.retrieve.
They both are for getting payment method ?

wary wigeon
#

No, the second one retrieves the Checkout Session object.

calm cliff
#

Got it.

#

One more question

#

data = Stripe::PaymentIntent.create({ amount: value, automatic_payment_methods: {enabled: true }, currency: 'cad', description: description, customer: @id, }, stripe_version: '2022-11-15' )

Stripe::PaymentIntent.confirm(data.id, {payment_method: pm['data'][0]['id'] , return_url: 'https://example.com'})
In this they ask for return_url but i read in the documention it is optional but they still ask for it if i remove it .

wary wigeon
#

Could you please share the exact error message.

calm cliff
#

Surre

#

You must provide a return_url when confirming a PaymentIntent using automatic_payment_methods[enabled] set to true and automatic_payment_methods[allow_redirects] set to always.

wary wigeon
#

Yes, it's required then.

#

You can set automatic_payment_methods[allow_redirects] to if_required but then you might loose some payment method types.

calm cliff
#

Yeah got it, Thankyou ๐Ÿ™‚
Can we use setupIntent with stripe element ?
and later I can move it to PaymentElement .

wary wigeon
#

Yes, you can use SetupIntents with Payment Element

calm cliff
#

Got it, Thanks alot ๐Ÿ™‚

wary wigeon
#

Happy to help!