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.
08.
Centralize your Stripe Code
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.
4 Comments
I'm getting the following error when running a payemnt:
No API key provided. (HINT: set your API key using "Stripe::setApiKey(<api-key>)". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.
StripeClient.php
public function construct__($secretKey, EntityManager $em)
{
$this->em = $em;
\Stripe\Stripe::setApiKey($secretKey);
}
Services.yml
stripe_client:
class: AppBundle\StripeClient
autowire: true
arguments: ['%stripe_secret_key%']
Thanks!
Hey Danny Avery!
Look's like you have those "underscores" inverted, try changing them at the begining "__construct()"
Have a nice day!
Wow! Thanks Diego!
PHP was thinking that "construct__" was a custom function of your class instead of the real constructor, and that's why you didn't have the API key defined :)
"Houston: no signs of life"
Start the conversation!