Chapters
35 Chapters
|
3:22:53
|
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.
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.5.9, <7.4
Subscribe to download the code!Compatible PHP versions: >=5.5.9, <7.4
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
21.
Webhook: Payment Failed!
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
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.
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.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.5.9, <7.4",
"symfony/symfony": "3.1.*", // v3.1.10
"doctrine/orm": "^2.5", // v2.7.2
"doctrine/doctrine-bundle": "^1.6", // 1.6.8
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.0
"symfony/swiftmailer-bundle": "^2.3", // v2.6.2
"symfony/monolog-bundle": "^2.8", // v2.12.1
"symfony/polyfill-apcu": "^1.0", // v1.3.0
"sensio/distribution-bundle": "^5.0", // v5.0.22
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.26
"incenteev/composer-parameter-handler": "^2.0", // v2.1.2
"friendsofsymfony/user-bundle": "~2.0.1", // v2.0.1
"stof/doctrine-extensions-bundle": "^1.2", // v1.2.2
"stripe/stripe-php": "^3.15", // v3.23.0
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.2.1
"phpunit/phpunit": "^5.5", // 5.7.20
"composer/package-versions-deprecated": "^1.11" // 1.11.99
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.4
"symfony/phpunit-bridge": "^3.0", // v3.3.0
"hautelook/alice-bundle": "^1.3", // v1.4.1
"doctrine/data-fixtures": "^1.2" // v1.2.2
}
}
2 Comments
Hey guys,
maybe you can help me :) At the moment I do setup my webhooks, and I'm following this lecture.
I understand the logic that we query only for invoices where actually a subscription was involved.
But why do we look for $stripeEvent->data->object->subscription?
In Stripe I created a test webhook and it returned at this field a value of null. Contrary, it returned within the invoice items array a subscription item.
This is just an excerpt of the line item's array
And further below in the invoice event:
When I look into the API https://stripe.com/docs/api#invoice_object I don't understand the field description of event.data.object.subscription: 'The subscription that this invoice was prepared for, if any.'
According to our setup the subscription filter would not trigger, although within the line Items there is a subscription.
Hey Chris,
Stripe prepare an upcoming invoices for subscriptions before each renew. And I believe that's where that subscription field is set, and that's what "The subscription that this invoice was prepared for, if any" means. But you somehow created a *test* webhook and it returned at this field a value of null that makes sense, i.e. this invoice wasn't prepared automatically by Stripe. I believe that's the root problem why subscription is null. I think you can try to successfully subscribe in test mode, then entering test credit card credentials - the subscription will be created and invoice will be paid. Then you can remove the credit card in the customer and on the next renewal I think you will get an "invoice.payment_failed" webhook and subscription won't be null.
I hope this helps, otherwise, I think you can contact Stripe support directly.
Cheers!
"Houston: no signs of life"
Start the conversation!