#shoryyy-custom-payment-flow

1 messages · Page 1 of 1 (latest)

honest blade
#

Hi there!

#

What are you confused about exactly?

trim chasm
#

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?

honest blade
#

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)?

trim chasm
#

Yes

honest blade
#

Which one?

trim chasm
#

Like which payment element?

honest blade
#

Specifically sounds like you want Payment Element, and not Checkout correct?

trim chasm
#

Yes

honest blade
#

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.

trim chasm
#

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

honest blade
#

Well the code is the same for each one, it is just different languages

#

Which language do you plan to write your code in?

trim chasm
#

php

#

And JavaScript

honest blade
#

You can flip this to PHP

#

That is the recommended basic code to use for Payment Element

trim chasm
#

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

honest blade
#

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

trim chasm
#

So would I define the variable just as: $intent = $response?

honest blade
#

Nope, look at the code above:

        'amount' => calculateOrderAmount($jsonObj->items),
        'currency' => 'usd',
        'automatic_payment_methods' => [
            'enabled' => true,
        ],
    ]);```
trim chasm
#

Ohh ok

#

Would I also need to add something like $stripe->paymentIntents->retrieve(
'pi_1EUmy5285d61s2cIUDDd7XEQ',
[]
); with my create paymentintent code?

vital urchin
#

no

#

The code bismarck gave you creates a PaymentIntent and stores the response in the variable $paymentIntent

trim chasm
#

Oh ok thank you!

vital urchin
#

let me know if you have more questions!

trim chasm
#

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?

vital urchin
trim chasm
#

Are these required or optional codes?

vital urchin
#

A webhook handler is required when using PaymentIntents.