#irene_92049-php-subs

1 messages ยท Page 1 of 1 (latest)

frigid lilyBOT
little hill
#

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)?

split harness
#

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();

little hill
#

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?

split harness
#

es laravel. al parecer no se cancela porque aparece con status activa

little hill
#

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?

split harness
#

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

little hill
#

So the cancel request failed, or it was never made? Can you share the ID of the Subscription that you tried to cancel?

split harness
#

im using test account.

#

it was never made

little hill
#

Okay, did you see a corresponding error in the logs for your code?

split harness
#

i didn't receive an error. just it was not canceled. because in stripe account it has "active" status

little hill
#

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?
split harness
#

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

little hill
#

What site? What is the ID of the Subscription?

split harness
#

sub_1O71Q9KkaR3aGqDYMlwNu7k3

little hill
#

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.

split harness
#

could you provide me the correct code for cancel a subscription?

little hill
gleaming bough
#

@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

split harness
#

yes, one second

frigid lilyBOT
gleaming bough
#

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

tulip flower
#

irene_92049-php-subs

split harness
#

ya he encontrado el problema. el objeto que se debe usar el $subscription = Subscription::retrieve($stripeSubscription->id);
$canceledSubscription = $subscription->delete();

tulip flower
#

@split harness Can you switch back to english?

#

it sounds like you found the problem?

split harness
#

sorry, omg. I found the issue, the "->cancel()" method doesn't exist. so, de correct one mush be "->delete()"

tulip flower
#

๐Ÿ‘