One click (1-click) subscription renewal
Overview
Avangate supports 1-click manual subscription renewals for returning customers who paid for their previous orders with Credit/Debit cards.
In this scenario, you can facilitate subscription renewals for subscribers who opted out of auto-renewal (recurring billing).
How does this work?
- Identify returning customers.
- Generate the manual renewal link.
- Create a tokenized manual subscription renewal link and serve it to the returning customer.
- Customers using the link land a hosted shopping cart, chose one of their credit cards they previously used for purchases from your account/store and place the order.
What do shoppers see in the cart?
Availability
Please contact Avangate to start using one click (1-click) subscription renewals.
Requirements
- Make sure that the subscription is eligible:
- Status needs to be Active or Past Due
- Subscription cannot be evergreen
- Email address must match that from the initial order. If shoppers change the email they need to re-enter the payment details.
Flow comparison
|
|
|
|
Detailed 1-click subscription renewal flow
Identify returning customers
You particularly need either the Avangate customer reference or the external customer reference you control.
Use customer information
getCustomerSubscriptions
|
If customers log into your system and you’ve mapped unique identifiers into the Avangate platform you can easily extract their subscription information.
|
Use subscription information
searchSubscriptions
|
You can also use subscription information to extract customer references, based on a set of filters. Validate the status of the subscription (needs to be Active or Past Due).
|
Create the manual renewal link
getRenewalDetails |
Retrieve information regarding subscription renewals based on Avangate Subscription References:
|
Attach the payment token to the manual renewal link
getSingleSignOnInCart
|
Avangate attaches a unique token to links, designed to identify the returning shoppers and support the automatic extraction of payment data and billing information from the Avangate system.
|
Example
<?php function callRPC($Request, $hostUrl, $Debug = true) { $curl = curl_init($hostUrl); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_SSLVERSION, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json')); $RequestString = json_encode($Request); curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString); if ($Debug) { $RequestString; } $ResponseString = curl_exec($curl); if ($Debug) { $ResponseString; } if (!empty($ResponseString)) { $Response = json_decode($ResponseString); if (isset($Response->result)) { return $Response->result; } if (!is_null($Response->error)) { var_dump($Request->method, $Response->error); } } else { return null; } } $host = 'https://api.avangate.com/rpc/3.0/'; $merchantCode = "MERCHANT_CODE";// your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php $key = "SECRET_KEY";// your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php $string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s'); $hash = hash_hmac('md5', $string, $key); $i = 1; // counter for API calls // call login $jsonRpcRequest = new stdClass(); $jsonRpcRequest->jsonrpc = '2.0'; $jsonRpcRequest->method = 'login'; $jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash); $jsonRpcRequest->id = $i++; $sessionID = callRPC($jsonRpcRequest, $host); var_dump($sessionID); $SubscriptionSearch = new stdClass(); $SubscriptionSearch->CustomerEmail = null; $SubscriptionSearch->DeliveredCode = '___TEST___CODE____123'; $SubscriptionSearch->AvangateCustomerReference = '123456789'; $SubscriptionSearch->ExternalCustomerReference = null; $SubscriptionSearch->Aggregate = false; $SubscriptionSearch->SubscriptionEnabled = null; //true false null $SubscriptionSearch->RecurringEnabled = null; // true - autorenewal, false - manual renewal, null = both(default) $SubscriptionSearch->ProductCodes = null; //array('Product_Code1', 'Product_Code2'); $SubscriptionSearch->CountryCodes = null;//array ('au') $SubscriptionSearch->PurchasedAfter = null; $SubscriptionSearch->PurchasedBefore = null; $SubscriptionSearch->ExpireAfter = null; $SubscriptionSearch->ExpireBefore = null; $SubscriptionSearch->LifetimeSubscription = null; $SubscriptionSearch->Type = 'regular'; //'trial', 'regular', 'regularfromtrial' $SubscriptionSearch->TestSubscription = null; // true, false, null = both(default) $SubscriptionSearch->Page = 1; $SubscriptionSearch->Limit = 10; $jsonRpcRequest = array ( 'method' => 'searchSubscriptions', 'params' => array($sessionID, $SubscriptionSearch), 'id' => $i++, 'jsonrpc' => '2.0'); $allsubscriptions = callRPC((Object)$jsonRpcRequest, $host, true); $subscriptionReference = $allsubscriptions[0]->SubscriptionReference; $jsonRpcRequest = array ( 'method' => 'getRenewalDetails', 'params' => array($sessionID, $subscriptionReference), 'id' => $i++, 'jsonrpc' => '2.0'); $manualrenewallink = callRPC((Object)$jsonRpcRequest, $host, true); $IdCustomer = $allsubscriptions[0]->AvangateCustomerReference; $CustomerType = 'AvangateCustomerReference'; $Url = $manualrenewallink->ManualRenewalLink; $ValidityTime = 999; $ValidationIp = null; $jsonRpcRequest = array ( 'method' => 'getSingleSignOnInCart', 'params' => array($sessionID, $IdCustomer, $CustomerType, $Url, $ValidityTime, $ValidationIp), 'id' => $i++, 'jsonrpc' => '2.0'); var_dump (callRPC((Object)$jsonRpcRequest, $host, true));