#shoryyy-custom-payment-flow
1 messages · Page 1 of 1 (latest)
I see for paymentintent there are a lot of different types of codes in your documentation. I'm am confused which exact codes I have to copy and what else I have to add to the code?
Gotcha.
And to clarify, you have decided on using Elements (where you embed a payment form into your website) versus using Stripe Checkout (where you redirect to a hosted payment page)?
Yes
Which one?
Like which payment element?
Specifically sounds like you want Payment Element, and not Checkout correct?
Yes
Okay so you would start by following the docs here: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
You specifically need to create a PaymentIntent on page-load when using Payment Element since you need the client secret from the PaymentIntent in order to render the Payment Element.
Yes. And when I was trying to create the payment intent and looking through your documentations I see there is a lot of different types of codes available. So I am unsure which code I should use
Well the code is the same for each one, it is just different languages
Which language do you plan to write your code in?
Okay so if you are looking for a good code example to start with then I'd recommend our quickstart: https://stripe.com/docs/payments/quickstart
You can flip this to PHP
That is the recommended basic code to use for Payment Element
I copied all the code in all the files
What is this for: <?php
$intent = # ... Create or retrieve the PaymentIntent
echo json_encode(array('client_secret' => $intent->client_secret));
?>
and am I supposed to add a specific code to the define the $intent variable
That is how you are passing the client secret from your server to your client
The $intent variable is initialized based on the response from hitting the Stripe API to create a PaymentIntent
So would I define the variable just as: $intent = $response?
Nope, look at the code above:
'amount' => calculateOrderAmount($jsonObj->items),
'currency' => 'usd',
'automatic_payment_methods' => [
'enabled' => true,
],
]);```
Ohh ok
Would I also need to add something like $stripe->paymentIntents->retrieve(
'pi_1EUmy5285d61s2cIUDDd7XEQ',
[]
); with my create paymentintent code?
no
The code bismarck gave you creates a PaymentIntent and stores the response in the variable $paymentIntent
Oh ok thank you!
let me know if you have more questions!
I also see that there is a payment_intent.succeeded, payment_intent.processing, and payment_intent.payment_failed code. So how would I implement those?
https://stripe.com/docs/webhooks/quickstart we have detailed docs for all of this!
Are these required or optional codes?
A webhook handler is required when using PaymentIntents.