function addShippingAddress($subscription, $customer) { /* * Adding address to the subscription for shipping product to the customer. * Sends request to the ChargeBee server and adds the shipping address * for the given subscription Id. */ $result = ChargeBee_Address::update(array("subscription_id" => $subscription->id, "label" => "shipping_address", "first_name" => $customer->firstName, "last_name" => $customer->lastName, "addr" => $_POST['addr'], "extended_addr" => $_POST['extended_addr'], "city" => $_POST['city'], "state" => $_POST['state'], "zip" => $_POST['zip_code'])); $address = $result->address(); return $address; }
function getShippingAddress($subscriptionId) { $addressReqParams = array("subscriptionId" => $subscriptionId, "label" => "shipping_address"); $shippingAddress = null; try { $result = ChargeBee_Address::retrieve($addressReqParams); return $result->address(); } catch (ChargeBee_APIError $e) { $jsonError = $e->getJsonObject(); if ($jsonError['error_code'] != "resource_not_found") { throw $e; } return null; } }
function addShippingAddress($subscriptionId, $customer) { ChargeBee_Address::update(array("label" => "shipping_address", "subscriptionId" => $subscriptionId, "firstName" => $customer->firstName, "lastName" => $customer->lastName, "addr" => $_POST['addr'], "extended_addr" => $_POST['extended_addr'], "city" => $_POST['city'], "state" => $_POST['state'], "zip" => $_POST['zip_code'])); }
<?php require_once '../partials/header.php'; require_once dirname(__FILE__) . '/../php_src/Util.php'; $result = ChargeBee_Address::retrieve(array("subscription_id" => $_GET["subscription_id"], "label" => "Shipping Address")); $address = $result->address(); ?> <h1 class="text-center" style="font-size: 50px; margin: 40px;"> Thank You </h1> <div class="col-sm-8 col-sm-offset-2"> <h4> Your comics will be shipped to the following address each month:</h4> <div class="form-horizontal"> <div class="form-group"> <label class="text-muted control-label col-sm-3">Address</label> <span class="col-sm-9 form-control-static"> <?php echo esc($address->addr) . ", " . esc($address->extendedAddr == null ? "" : $address->extendedAddr . ","); ?> </span> </div> <div class="form-group"> <label class="text-muted control-label col-sm-3">City</label> <span class="col-sm-9 form-control-static"> <?php echo esc($address->city) . ","; ?> </span> </div> <div class="form-group"> <label class="text-muted control-label col-sm-3">State </label> <span class="col-sm-9 form-control-static"> <?php echo esc($address->state) . ",";
function addShippingAddress($subscriptionId, $result) { $passThru = $result->hostedPage()->passThruContent; $shippingAddress = json_decode($passThru, true); $result = ChargeBee_Address::update(array("label" => "Shipping Address", "subscriptionId" => $subscriptionId, "addr" => $shippingAddress['address'], "extended_addr" => $shippingAddress['extended_addr'], "city" => $shippingAddress['city'], "state" => $shippingAddress['state'], "zip" => $shippingAddress['zip_code'])); }