public function cancelSubscription($subscription_id, $cancellation_message, $format = 'XML')
 {
     $chargify_subscription = new ChargifySubscription(null, $this->test_mode);
     $chargify_subscription->cancellation_message = $cancellation_message;
     return $this->requestCancelSubscription($subscription_id, $chargify_subscription->getXML());
 }
示例#2
0
$card->last_name = "Smith";
// 1 is used in test mode for a vald credit card.
$card->full_number = '1';
$card->cvv = '123';
$card->expiration_month = "02";
$card->expiration_year = "2011";
$card->billing_address = "123 any st";
$card->billing_city = "Anytown";
$card->billing_state = "CA";
$card->billing_zip = "55555";
$card->billing_country = 'US';
// Get a list of products. The first one will be used.
$product = new ChargifyProduct(NULL, $test);
$products = $product->getAllProducts();
// Build subscription.
$subscription = new ChargifySubscription(NULL, $test);
$subscription->customer_attributes = $customer;
$subscription->credit_card_attributes = $card;
// Uses the first exising product. Replace with a product handle string.
$subscription->product_handle = $products[0]->handle;
echo '<h2>Cancel a new subscription</h2>';
try {
    // Save a new subscription.
    $new_subscription = $subscription->create();
    try {
        // Delete the newly saved subscription with a message.
        $deleted_subscription = $new_subscription->cancel('Subscription canceled');
        var_dump($deleted_subscription);
    } catch (ChargifyValidationException $cve) {
        // Error handling code.
        echo $cve->getMessage();