function updateCardHostedPage() { /* * Calling the ChargeBee Update Card Hosted Page API to update card for * a customer by passing the particular customers' customer id. * * Note : To use this API return url for Update Card API's page must be set. */ $hostUrl = getHostUrl(); $result = ChargeBee_HostedPage::updatePaymentMethod(array("customer" => array("id" => $_GET['customer_id']), "embed" => "false", "redirectUrl" => $hostUrl . "/update_payment_method/redirect_handler", "cancelUrl" => $hostUrl . "/update_payment_method/profile?customer_id=" . urlencode($_GET['customer_id']))); $url = $result->hostedPage()->url; header("Location: {$url}"); }
function updateCard() { $hostUrl = getHostUrl(); $customerId = getCustomerId(); try { $result = ChargeBee_HostedPage::updatePaymentMethod(array("customer" => array("id" => $customerId), "redirect_url" => $hostUrl . "/ssp-php/redirect_handler", "cancel_url" => $hostUrl . "/ssp-php/subscription", "embed" => "false")); $url = $result->hostedPage()->url; header("Location: " . $url); } catch (ChargeBee_InvalidRequestException $e) { error_log($e->getMessage()); $errorResponse = array(); if ($e->getParam() != null && $e->getApiErrorCode() == "resource_not_found" && $e->getParam() == "customer[id]") { customError404($e); } else { customError400($e); } } catch (ChargeBee_APIError $e) { error_log($e->getMessage()); customError400($e); } catch (Exception $e) { error_log($e->getMessage()); customError500($e); } }