#sarvesh3742
1 messages ยท Page 1 of 1 (latest)
๐
Hi
$cancellationReason = [
'reason' => $cancelReason,
'comment' => $cancelComment
];
$subscription = $stripe->subscriptions->retrieve($stripe_subscription_id);
$canceledSubscription = $subscription->cancel([
'cancellation_details' => $cancellationReason
]);
it gives an error. How to passs reason and comment for cancel subscription request from user?
What is the error that you are getting when you run that code?
Can you send me the ID for the request where you got that error? https://stripe.com/docs/api/request_ids
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
let me create and send you
Received unknown parameter: cancellation_details[reason]
sub_1OOhouHbAvQl6CwuDho1R0ZG
Ah, it looks like the paramter is named feedback not reason
Can you try again but with feedback?
yes it works now for sub_1OOhouHbAvQl6CwuDho1R0ZG
where it will be visible in Stripe in the subscription ID details?
yes, it is visible undet the Cancellation details section
thank you for your suppport
have 1 more question for cancellation, now If I cancel it today but my next payment date is 1st day of each month.
so how I can set the user to keep access on until next payment date?
In that case you would make an update call and would set cancel_at_period_end to true along with setting the cancellation details
https://stripe.com/docs/api/subscriptions/update#update_subscription-cancel_at_period_end
https://stripe.com/docs/api/subscriptions/update#update_subscription-cancellation_details
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok got it, so instead of $subscription->cancel() can be done with update call
Exactly
ok, another question regarding upgrading/downgrading the subscription. how to switch to other plan?
Do you want to switch immediately or schedule a future change?
immidately
send me both way so I will check with client feedback
$canceledSubscription = $subscription->update([
'cancel_at_period_end' => true,
'cancellation_details' => $cancellationReason,
]);
is this correct? getting error Fatal error: Uncaught TypeError: urlencode(): Argument #1 ($string) must be of type string, array given
it needs subscription Id as first string param?
$subscription = $stripe->subscriptions->retrieve($stripe_subscription_id);
$canceledSubscription = $subscription->update([
'cancel_at_period_end' => true,
'cancellation_details' => $cancellationReason,
]);
is this correct? getting error Fatal error: Uncaught TypeError: urlencode(): Argument #1 ($string) must be of type string, array given
it needs subscription Id as first string param?
what is wrong here?
it worked with some modifications in code, thank you, error resolved
sub_1OOiDAHbAvQl6Cwuj0WXaXRG
how to receive webhook events on local docker project URL?
docker with nginix
Nice! Can you send the update code that worked? I was having trouble finding docs that use that syntax. For our PHP library we typically reccommend using a stripe client like so
$stripe->subscriptions->update(
'sub_67890',
['cancellation_details' => $cancellationReason]
);```
$subscription = $stripe->subscriptions->update($stripe_subscription_id, [
'cancel_at_period_end' => true,
'cancellation_details' => $cancellationReason
]);
yes similar way it is done
Unfortunately we don't know much about setting up docker servers to have a public URL like that. That would be something you will need to look to docker/nginx support and documentation for. From the stripe side, our requirements for webhook endpoints are that you have a public HTTPS that we can reach and that it response with a HTTP 200 success code when you succesfully receive an event.
ok, I tried with couple of public services like Ngrok and https://my.webhookrelay.com/ but still no luck
it reaches to them but could NOT reached to project url routte
๐ you are likely missing some IP/port mappings in your docker config file that maps the exposed IP/ports to the internal services
As my colleague mentioned, we don't know much about it so you'd likely want to look around (google) for tutorials/guidance on this