$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(); } } catch (ChargifyValidationException $cve) { // Error handling code. echo $cve->getMessage(); } ?> </body> </html>