#sarvesh3742

1 messages ยท Page 1 of 1 (latest)

vale heathBOT
soft sparrow
#

๐Ÿ‘‹

sly ice
#

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?

soft sparrow
#

What is the error that you are getting when you run that code?

sly ice
#

let me create and send you

#

Received unknown parameter: cancellation_details[reason]

#

sub_1OOhouHbAvQl6CwuDho1R0ZG

soft sparrow
#

Ah, it looks like the paramter is named feedback not reason

#

Can you try again but with feedback?

sly ice
#

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?

soft sparrow
#

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

sly ice
#

ok got it, so instead of $subscription->cancel() can be done with update call

soft sparrow
#

Exactly

sly ice
#

ok, another question regarding upgrading/downgrading the subscription. how to switch to other plan?

soft sparrow
#

Do you want to switch immediately or schedule a future change?

sly ice
#

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?

sly ice
#

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

vale heathBOT
sly ice
#

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

soft sparrow
#

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]
);```
sly ice
#

$subscription = $stripe->subscriptions->update($stripe_subscription_id, [
'cancel_at_period_end' => true,
'cancellation_details' => $cancellationReason
]);

#

yes similar way it is done

soft sparrow
#

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.

sly ice
#

it reaches to them but could NOT reached to project url routte

sick badge
#

๐Ÿ‘‹ 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

sly ice
#

maybe, in docker-compose we have mentioned ports

ports:
- "81:80"
- "444:443"
- "587:587"

#

and I tried to ngrok http 444 to point ngrok URL to my project. Stripe POST request reaches to ngrok but ngrok shows 302 moved temporarily.

#

while reaching to project route