arman
arman

Reputation: 504

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

?>

Upvotes: 6

Views: 5230

Answers (2)

ivan.sim
ivan.sim

Reputation: 9268

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

Upvotes: 7

arman
arman

Reputation: 504

I found the correct solution to be:

$cu->subscriptions->retrieve("$SUBSCRIPTION_ID")->cancel(
     array("at_period_end" => true ));

Upvotes: 15

Related Questions