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();
?>
Canceling your subscription before it expires means you'll finish your current subscription period without receiving money back.
On your Android device, go to your subscriptions in Google Play. Select the subscription you want to cancel. Tap Cancel 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.
When canceled, all future billing will be disabled and you will no longer be charged on the billing date set by your plan.
I found the correct solution to be:
$cu->subscriptions->retrieve("$SUBSCRIPTION_ID")->cancel(
array("at_period_end" => true ));
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With