This course is archived!
This tutorial uses an older version of Symfony of the stripe-php SDK. The majority of the concepts are still valid, though there *are* differences. We've done our best to add notes & comments that describe these changes.
10.
Building the Custom Checkout Form
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
10 Comments
Hi
Thanks for you awesome tutorial.
Hello!
Do yo know where I can find the documentation about the custom form on Stripe documentation website?
Thx!
Hey be_tnt
I found these two pages
https://stripe.com/en-mx/pa...
https://stripe.com/docs/pay...
I hope it helps.Cheers!
Hello,
I am trying to follow the tutoriel but with Symfony 4 and new checkout Stripe form... So I have a question please.
Is create a Stripe session is mandatory ?
https://stripe.com/docs/payments/checkout/server#integrate
`// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_Ag");
$session = \Stripe\Checkout\Session::create([ 'payment_method_types' => ['card'],
'line_items' => [[
]],
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
]);`
Thank you.
Hey Camille,
I suppose so, it's required in case you're going to use this Checkout feature from Stripe: https://stripe.com/docs/pay...
Cheers!
what happens if it is the existing customer that we are charging but their card on stripe has been expired? i am assuming stripe will send back an error asking to update their card? then we will ask the customer to provide updated card information send that to stripe to charge? will that change the customer id?
Hey Shairyar!
It depends :). We've built the site so that we *always* ask the user for a new credit card. But, you *could* update your app so that you don't require an existing user to provide a credit card. In this case, if their card fails (e.g. because its expired), you'll actually get the same error we talk about here: https://knpuniversity.com/s...
Also, though we haven't published it yet, we go even a little bit *further* with error handling in part 2: https://knpuniversity.com/s...
Let me know if this clarifies!
Ya it done, thanks.
the official docs at https://stripe.com/docs/cus... say that it is no longer safe...
"This method of using Stripe.js to collect card information using a custom payment form has been deprecated. When creating a payment form to collect card information, use Stripe Elements—our pre-built UI components. Check out our Elements migration guide to learn how to migrate your checkout flow to Elements."
what can i do ? :P
Hey Blueblazer172!
Ah, you're right! This is the first I've heard of this deprecation :/. So, first, I'm chatting with Stripe to find out more about this. My guess is that they simply think that their new system is a bit less error-prone - I don't think there's any security problem with the old system (except, perhaps, that it's a bit easier to make a security mistake, like give your fields name attributes, which would cause them to be submitted to your server). I'll let you know if (hopefully when) I hear back from them!
Until then, my best guess is: using a custom checkout form is *fine* still. And Stripe has a great history of keeping old versions of the API available for a LONG time... years. That being said, I'll definitely look into the new system, and see if we need to update the tutorial. It looks fairly straightforward: a new stripe.js v3 file, and some extra JavaScript in place of physically creating the fields. But, that's just on first glance.
If I were you, I would checkout the new Elements system, and see if you can figure it out. Ultimately, it will give you back a token, just like the old system... then everything else is the same. But, if it's tricky, I think you're fine with the old system.
Thanks for pointing this out! Cheers!
"Houston: no signs of life"
Start the conversation!