Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel Subscription At Period End

QUESTION:

How does one append the "at_period_end" argument to the following PHP function in accordance with the relevant Stripe documentation ?

DOCUMENTATION:

STRIPE: cancel subscription

CODE:

<?php

require_once('./lib/Stripe.php');
Stripe::setApiKey("$APIKEY");

$cu = Stripe_Customer::retrieve("$CUSTOMER_ID");
$cu->subscriptions->retrieve("$SUBSCRIPTION_ID")->cancel();

?>
like image 774
arman Avatar asked Sep 10 '14 06:09

arman


People also ask

What happens if you cancel a subscription before it expires?

Canceling your subscription before it expires means you'll finish your current subscription period without receiving money back.

How do I cancel my subscription immediately?

On your Android device, go to your subscriptions in Google Play. Select the subscription you want to cancel. Tap Cancel subscription.

What to say to cancel a subscription?

State your intention directly. It is not necessary, but you may wish to explain the reason for canceling. Give enough information such as an account number, membership number, or data from a mailing label so there will be no question about who is canceling what.

What does it mean when a subscription is Cancelled?

When canceled, all future billing will be disabled and you will no longer be charged on the billing date set by your plan.


2 Answers

I found the correct solution to be:

$cu->subscriptions->retrieve("$SUBSCRIPTION_ID")->cancel(
     array("at_period_end" => true ));
like image 123
arman Avatar answered Sep 24 '22 15:09

arman


Try specify the argument as an array like this:

$at_period_end = true;
$cu->subscriptions->retrieve("$SUBSCRIPTION_ID")->cancel(
     array("at_period_end" => $at_period_end));
like image 44
ivan.sim Avatar answered Sep 23 '22 15:09

ivan.sim