#Max1414
1 messages · Page 1 of 1 (latest)
It's not working. I talked with a developer I hired to look into this, and told me that it doesn't work. Stripe doesn't receive the request. Could this be a bug from Stripe?
`$stripe->subscriptionSchedules->create([
'from_subscription' => $sub_id,
]);
$stripe->subscriptionSchedules->update(
$event->data->object->schedule,
[
'phases' => [
[ 'items' => [
[
'price' => 'price_1MYJnhCx0zdgDXMaoqEwUg2A',
'quantity' => 1,
],
],
'start_date' => $event->data->object->current_period_start,
'end_date' => $event->data->object->current_period_end,
],
[
'items' => [
[
'price' => 'price_1MYJnhCx0zdgDXMaoqEwUg2A',
'quantity' => 1,
],
],
'iterations' => 2,
],
],
'end_behavior' => 'cancel'
]);`
That is just code with variables. Do you have a request ID? Did you see an error message?
I promise you this is possible and it is almost certainly just an issue with your code but I can't tell that from the above.
req_JcJebffqQoBmNq this is the request ID from the first line of code
But I don't get a request ID from the second line of code to update the subscriptionSchedule
There's no error/ Stripe for some reason seems to not be working to update the subscriptionSchedule
I see a bunch of errors occurring on your initial Sub Schedule request which is likely the issue
You really want to set a variable here to be used
It seems like you are trying to re-use the same Sub ID. See: https://dashboard.stripe.com/test/logs/req_ThoHBvbA6P1FTo
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
- Am I able to create a subscription schedule from a subscription?
$stripe->subscriptionSchedules->create([ 'from_subscription' => $sub_id, ]);
Yes.
You have a successful example of that above: https://dashboard.stripe.com/test/logs/req_JcJebffqQoBmNq
So do $subSchedule = $stripe->subscriptionSchedules->create([ 'from_subscription' => $sub_id, ]);
So the problem is updating the created SubscriptionSchedule
Then try:
$subSchedule->id
[
'phases' => [
[ 'items' => [
[
'price' => 'price_1MYJnhCx0zdgDXMaoqEwUg2A',
'quantity' => 1,
],
],
'start_date' => $event->data->object->current_period_start,
'end_date' => $event->data->object->current_period_end,
],
[
'items' => [
[
'price' => 'price_1MYJnhCx0zdgDXMaoqEwUg2A',
'quantity' => 1,
],
],
'iterations' => 2,
],
],
'end_behavior' => 'cancel'
]);```
Then log out $updateSub
Also going to need to change your $$event->data->object->current_period_start
$event->data->object->schedule, is likely the issue though overall
Like schedule isn't something you get from a Stripe webhook
Which I assume is what you are trying to rely on there?
Not sure why tbh
To update a subscriptionSchedule is necessary to pass the subscriptionSchedule ID
Yes, I already read and tested what's on the Stripe API
Is $event->data->object->schedule the subscriptionSchedule ID?
No
First off, it depends on what event that is to begin with
Are you listening for subscription_schedule.created?
If so, then it would be $event->data->object->id
Since that event returns you a Subscription Schedule object
- I create a normal monthly subscription.
- This triggers a webhook:
2.1) Create a subscription schedule
2.2) Update the subscription schedule
Yep
So see what I did above
When you create your Sub Schedule
Set a variable
Don't use the Webhook
Then pass that variable for updating the Schedule
(I actually have it wrong above and you need $subSchedule->id)
In the webhook I'm listening for customer.subscription.created
So, do I need to create a separate webhook for this?
Nope.
The issue is that you are currently passing the Subscription ID to the SubscriptionSchedule update API
So, what should I use intead of $event->data->object->schedule?
You need the SubscriptionSchedule ID
No, please read what I wrote above.
When you create your Subscription Schedule
You want to set a variable
For that Schedule
So like this: ```$subSchedule = $stripe->subscriptionSchedules->create([
'from_subscription' => $sub_id,
]);
No the Subscription Schedule object is initialized within $subSchedule
Next step is to update the Subscription Schedule. You can access the ID of that Schedule now via $subSchedule -> id
So your update request should look like:
$subSchedule->id
[
'phases' => [
[ 'items' => [
[
'price' => 'price_1MYJnhCx0zdgDXMaoqEwUg2A',
'quantity' => 1,
],
],
'start_date' => $event->data->object->current_period_start,
'end_date' => $event->data->object->current_period_end,
],
[
'items' => [
[
'price' => 'price_1MYJnhCx0zdgDXMaoqEwUg2A',
'quantity' => 1,
],
],
'iterations' => 2,
],
],
'end_behavior' => 'cancel'
]);```
So basically, I should use the latest two code blocks you shared intead of mine and it should work?
When I store the subscriptionSchedule in a variable, does this create the subscriptionSchedule in the subscription?
Or do I need to call the function again?