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.
06.
We <3 Creating Stripe Customers
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.
17 Comments
hmm, I'm a little confused, why is:
$customer->source = $token;only run when retrieving the customer and not also when creating the customer - wouldn't it make sense to add the token incase their payment details have changed and so stripe has access to ALL purchase tokens from the past? confused face
solved. please disregard this.
Hey Cameron,
Happy to hear you were able to solve this yourself!
Cheers!
okay i found it, try these:
Hey Simon,
I suppose this comment relates to this thread: https://symfonycasts.com/sc...
I'm glad you were able to find the solution!
Cheers!
I am unable to update the source with:
<br />$customer = \Stripe\Customer::retrieve($user->getStripeCustomerId());<br />$customer->source = $token;<br />$customer->save();<br />I have also tried with $customer->sources and $customer->default_source which are the new fields available since https://stripe.com/docs/upgrades#2015-02-18
This is what I am doing to update the Customer's source:
`
Customer::update(
);
`
Hey apphancer!
Hmmm. Sorry about that! Thanks for posting - it's on my list to add some notes through the tutorial so that people are aware of changes. It looks like (but this is just a guess) this change might be due to a newer version of the SDK.
Cheers!
I found something like this:
but it gives: You cannot use a Stripe token more than once: tok_1HrSZUJuuOs5oDxUiHqfsdfsdfsdf
i dont know what happening source dont work:
https://ibb.co/Wp0h492
Sources:
https://ibb.co/FVM8knd
And default source:
https://ibb.co/gjBL6Vv
what should i do? nothin works
Hey Szymon Z.!
Sorry for the SUPER slow reply - we got to SymfonyWorld virtual conference week... and everything falls apart :p.
Ok, so, as you can see from the error, you can't use that token twice. So we need to make sure that the ONE time we pass that token up to Stripe that it is the "way that works". But unfortunately, this API is showing its age BIG time - as the Stripe API has changed quite a lot :/. Looking at the docs, unless you're using an old API, i'm not exactly sure how to do this now. You may need to create a "card" object first, then attach that to the customer... but to be honest, it's not clear and I'm not sure (we're quite a few API versions behind on SymfonyCasts).
So, my apologies for not being able to offer more info on this specific spot. Really, we need to upgrade this tutorial to the much newer "flow" of handling checkout :/.
Cheers!
The Customer entity in Stripe, at least the one I have, doesn't have the 'source' field, but the 'default_source' (and the 'sources' field as well).
Hey Carlos M.!
You're totally right. Stripe has since updated their API and doesn't have a
sourcefield anymore. I believe the change is from this API upgrade - https://stripe.com/docs/upgrades#2015-02-18 - I believe that "source" is (as you said) now effectively default_source.I hope that helps! The tutorial, unfortunately, is starting to show it's age - it's on my list to update or deprecate it officially.
Cheers!
I ended up using the 'sources' field, assigning to the first position the new token.
I don't think the tutorial should be removed or deprecated. Simply updated. Aside from this, and the other comment (which I'll answer you now), the rest has worked like a charm. It's the best tutorial to implement Stripe payments over Symfony (although it isn't a requirement and most of it could be used in other PHP framework).
Thanks for the tutorial, by the way :)
Hi Carlos M.!
Thank you for that feedback - it's super useful to know that the bulk of the tutorial is still working. That makes me lean towards getting some well-placed notes in those few area that need updates. And thanks for the kind word - it's *most* important to me that the tutorials are saving people time ❤️
Cheers!
I have to come back, and inform you that the 'source' field is working fine. I was using an old Stripe PHP package (4.x). Now with the 7.x works like a charm.
Sorry for the misunderstanding.
Thanks for the update Carlos M. - I appreciate it - these notes will help me with any updates or notes we need to add :).
Cheers!
i have 7.66 and it doesn't have it
"Houston: no signs of life"
Start the conversation!