#Adaman

1 messages · Page 1 of 1 (latest)

hidden groveBOT
reef marsh
#

Hi there

#

How can I help?

pastel kestrel
#

Hi @reef marsh

#

Got a few questions for you if that's cool, sorry I'm new to stripe

reef marsh
#

Sure thing

pastel kestrel
#

So I'm trying to set up elements on my site and I'm using dynamic pricing. Having looked at the docs I'm meant to set up a paymentIntent on page load. I can do that, but I need to be able to update it based on what the user enters in the form in order to get the correct pricing.

In essence what I need to know is:

#
  1. should I create the paymentIntent on page load or when I am ready to take payment and if on page load is there a way to update them?
#
  1. Is there a way of creating line items within a payment intent? (I watched the great dynamic pricing video on yt but that seems to be for checkout)
#

sorry for the long winded explaination

reef marsh
#

1/ Either way is fine really. You can update a PaymentIntent before it is confirmed. However I would mostly recommend just waiting until the customer is ready for payment otherwise you will end up with a lot of incomplete PaymentIntents (which is fine but will just cause some Dashboard clutter) and then you will make less updates.
2/ No line items aren't supported with PaymentIntents. You basically just want to track your line items in your own database, or you could add them as metadata to your PaymentIntent.

pastel kestrel
#
  1. Perfect thanks
  2. That's fine, so the invoice would just be a total amount unless I override it or create my own one?
reef marsh
#

There are no invoices associated with PaymentIntents if you create PaymentIntents directly. You could instead create Invoices (which does involve line items) and then the Invoice will create a PaymentIntent when it is finalized.

#

You would need to create new Invoices though if there are updates

pastel kestrel
#

Ok I'll take a look into that, while I've got you I have another quick question.

#

I know you pass a return_url, is there a way instead of calling a javascript function when a payment is successfully completed?

reef marsh
#

Well yeah you can run a function when your return_url is hit

#

Sorry I don't quite understand that question

pastel kestrel
#

No worries,
So I want to stay on the same page (not call a new url) once the payment succeeds as I have further functions I need to perform after payment.

#

So I guess I need to listen for a success message from stripe?

reef marsh
#

Then you won't have a redirect for paymnet method types that don't require one

#

And you wait for the confirmPayment promise to resolve successfully then you run your next logic

pastel kestrel
#

Ahh brill, think you've solved it. So a redirect based payment method would normally be bank account yeah?

reef marsh
#

Yep it would be a bank redirect

#

Where they have to get redirected to their bank for authentication

#

As well as certain wallet payment methods

#

Like WeChat

#

If you want to support that

pastel kestrel
#

Yeah I get it. So to minimise the chance of a redirect primarily stick to apple/google/card?

reef marsh
#

Bank debits should be fine as well

pastel kestrel
#

Great

#

Thanks so much for all your help mate.

#

You've got me out of a right pickle