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!
09.
Reactivate/Un-cancel my Subscription!
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
}
}
6 Comments
Hello, for me, the reactivateSubscription() doesn't work. There is no changements on Stripe. So I follow this link (actual Stripe version) : https://stripe.com/docs/billing/subscriptions/canceling-pausing#reactivating-canceled-subscriptions
And now it works with :
I made it even simpler like this but essentially you're right, the code of this section didn't work for me either:
`\Stripe\Subscription::update($subscription->getStripeSubscriptionId(),[
]);`
Hey Kiuega!
Thanks for sharing! You're right that in the newer version of the API, they make reactivating easier / more natural then it was before. I like the change.
Cheers!
Hi,
when i click on reactivate it throws this exception:
No such subscription: sub_AF9bUobPfZHKz9
500 Internal Server Error - InvalidRequest
why is that so ?
btw is there a way to let the user only activate or reactivate for 3 times so that they can't spam the server ?
Hey Blueblazer172!
Hmm. When you get this error, can you go find this subscription in your Stripe dashboard? As far as I know, subscriptions are never deleted (they can become "cancelled" but you can still find them - you can even filter for "canceled" subscriptions in Stripe). That would be step 1 - see if you can find that subscription! My initial instinct is that something went weird while testing. Did you possible reset your Stripe data on the dashboard? Or switch from test to live mode? Let me know!
About reactivating only 3 times, I think that would need to be handled in your code. For example, if this were important to you, I might add a field to my user - reactivateCount - which would default to 0. Each them they reactivate, increment this by 1. Then, check to see if this value is 3 before allowing them to reactivate. You could even reset this back to 0 after each renewal if you wanted (this would happen when handling webhooks!).
Cheers!
i actually removed the subscriptions by myself in stripe xD so silly that i didn't see that
thanks for the hint for the reactivating :) i'm going to reproduce it like this:)
"Houston: no signs of life"
Start the conversation!