#irene_92049-php-subs
1 messages ยท Page 1 of 1 (latest)
Hi there ๐ I'd be happy to talk through your question if you can share it. Offhand though, that flow doesn't quite sound right.
Is there a reason you're creating and processing a Payment Intent before creating a Subscription (since Subscriptions create Invoices which create their own Payment Intents)?
what is the correct way for cancel the subscription?
the code that im using for cancel it is
$subscription = Subscription::retrieve($stripeSubscription->id);
$canceledSubscription = $subscription->cancel();
Hm, it looks like you're using the older syntax for our PHP library, which I'm not as familiar with. Is that code that you shared not compiling/running, or is it running but not doing what you're expecting?
es laravel. al parecer no se cancela porque aparece con status activa
I'm sorry, I'm only able to provide assistance here in english. I can't read most of your message, but see you mentioned Laravel. Are you just using the Laravel framework, or are you also using Laravel Cashier, their Stripe abstraction?
sorry, i don't know why i wrote in spanish hehe, the code about cancelation is not working. because in stripe account the subscription s with the status "active"
laravel framework
So the cancel request failed, or it was never made? Can you share the ID of the Subscription that you tried to cancel?
Okay, did you see a corresponding error in the logs for your code?
i didn't receive an error. just it was not canceled. because in stripe account it has "active" status
Okay, so just making sure I'm understanding correctly.
You ran this code on your server:
$canceledSubscription = $subscription->cancel();```
that code did not throw an error, but also did not make a request?
when i ran that code i didn't receive any errors. the request looks like the subscription was canceled correctly.
but when i went to the site it is still with "active" status
What site? What is the ID of the Subscription?
sub_1O71Q9KkaR3aGqDYMlwNu7k3
I don't see a request being made to cancel that Subscription, the closest thing I see is a request being made to update the Subscription:
https://dashboard.stripe.com/test/logs/req_6JUwtpL2el5nPi
That one doesn't cancel the Subscription because it's using cancel_at_period_end: true, which causes the Subscription to cancel at the end of the billing period rather than immediately, so it's expected for the Subscription to still have a status of active there.
could you provide me the correct code for cancel a subscription?
Double checking with a teammate what that is, since it looks like you're using the older syntax I'm not as familiar with. Our API ref contains sample code using the newer syntax:
https://stripe.com/docs/api/subscriptions/cancel?lang=php
@split harness can you add clear logs before/after each of those lines to make sure they are running as expected?
I don't see you even retrieving that Subscription id in the past 4 hours so my guess is your call to retrieve is not working
yes, one second
ah I see the retrieve calls now, but yeah if you can add clear logs before/after each line and share the exact code that will help
irene_92049-php-subs
ya he encontrado el problema. el objeto que se debe usar el $subscription = Subscription::retrieve($stripeSubscription->id);
$canceledSubscription = $subscription->delete();
@split harness Can you switch back to english?
it sounds like you found the problem?
sorry, omg. I found the issue, the "->cancel()" method doesn't exist. so, de correct one mush be "->delete()"
๐