#Zigi - Mobile App
1 messages · Page 1 of 1 (latest)
Hello! Can you tell me more about your app? What language are you writing it in? What platforms does it support?
Yes sure, I am using react native
It is a classic e-commerce flow
Customer chooses a product, sends to the server, my BE creates a paymentIntent, retrieves secret to customer
Customer then renders the react native widget with the payment intent client secret
Are you using our React Native SDK? https://github.com/stripe/stripe-react-native
yes
In that case there should be no need to redirect the customer out of your app except in some cases where they need to provide authentication directly to their bank/card issuer. Is that what you're asking about?
I am not sure, I am asking if paymentIntent is the correct way to go
Or maybe, what is the best practice for doing this flow?
Customer selects item -> BE receives the ID -> calls stripe with item + fees + tax and such -> customer pays -> customer gets detailed invoice
I am not sure that paymentIntent is the way to go as it does not work with "line items"
So maybe the correct way is using the checkout object?
If you need line items and you want to avoid redirecting the user out of your app you may want to use one-off Invoices: https://stripe.com/docs/invoicing
Okay, and after creating the invoice, what should I return to the customer in order for the app to render the correct card payment form?
Is it finalized on the spot? And creates a payment intent on the spot?
"About an hour after creation, Stripe finalizes the invoice. (You can no longer make any changes to it.)"
Saw this on the doc - invoice lifecycle
You can finalize them via the API. Invoices do create Payment Intents, yes.
I see
So create an invoice in the draft state, finalize it, send payment intent secret to customer
After the customer pays, an invoice receipt will be sent to them
A payment receipt will be sent if you have that configured, yeah. If you want to send them the actual Invoice you need to handle that on your end if you're not using send_invoice: https://stripe.com/docs/api/invoices/create#create_invoice-collection_method
Backing up a bit, what's your overall goal?
Will try that
Enable the customer to pay inside the mobile app, get a detailed invoice upon payment
The full amount needs to be added with service fee on the BE
How do you want them to get the detailed Invoice? Email?
Yea
Okay, so you can do this with Invoices, but you need to handle the after-payment emails on your end. Invoices have an invoice_pdf property that point to the Invoice PDF; you can send your customer an email pointing to that PDF: https://stripe.com/docs/api/invoices/object#invoice_object-invoice_pdf
You can also do this with Payment Intents directly, but you would need to handle the line items/emails entirely on your end.
I see,
Okay thanks
Just 2 questions:
- After creating the invoice, is there a way not to send it to the customer before the payment? Only after receipt? The payment is done on my native app, I do not need to send it before customer completed payment
- How do I get the payment intent client secret to pass to the client after creating the invoice?
By pulling the payment intent via the API?
If you don't set collection_method to send_invoice Stripe won't send the Invoice to the Customer.
Yeah, the Invoice will create a Payment Intent which you can access via the Invoice's payment_intent property: https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent
You would then get and use the client secret from the Payment Intent the same way you would if you weren't using Invoices.
Oh okay great