One click (1-click) subscription upgrade
Overview
Avangate supports 1-click manual subscription upgrades for returning customers who paid for their previous orders with Credit/Debit cards.
In this scenario, you can facilitate subscription upgrades for subscribers by enabling them to use card on file information to pay for the upgrade.
How does this work?
- Identify returning customers.
- Identify valid upgrade options and costs.
- Create a tokenized manual subscription upgrade 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 upgrades.
Requirements
- Configure the upgrade product / subscription plan in your Control Panel.
- 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 upgrade flow
Identify returning customers
You particularly need either the Avangate customer reference or the external customer reference you control.
Use customer information
| 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
| 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).
|
Validate upgrade options and costs
| Retrieve the possible upgrade options for a subscription.
Retrieve information about the costs a customer incurs when upgrading a specific subscription |
Create the manual upgrade link
To build custom upgrade links you need the following two elements:
1. The main upgrade path: https://secure.avangate.com/order/upgrade.php? or https://YourStore.com/order/upgrade.php? if you use a custom domain with Avangate.
2. The unique subscription identifier from the Avangate system: LICENSE=1234567.
The simplest upgrade link you can build is https://secure.avangate.com/order/upgrade.php?LICENSE=1234567
Attach the payment token to the manual Upgrade link
| 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 $host = "https://api.avangate.com"; $client = new SoapClient($host . "/soap/3.0/?wsdl", array( 'location' => $host . "/soap/3.0/", "stream_context" => stream_context_create(array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false ) )) )); function hmac($key, $data) { $b = 64; // byte length for md5 if (strlen($key) > $b) { $key = pack("H*", md5($key)); } $key = str_pad($key, $b, chr(0x00)); $ipad = str_pad('', $b, chr(0x36)); $opad = str_pad('', $b, chr(0x5c)); $k_ipad = $key ^ $ipad; $k_opad = $key ^ $opad; return md5($k_opad . pack("H*", md5($k_ipad . $data))); } $merchantCode = "YOUR_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 = "YOUR_SECRET_KEY";// your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php $now = date('Y-m-d H:i:s'); //date_default_timezone_set('UTC') $string = strlen($merchantCode) . $merchantCode . strlen($now) . $now; $hash = hmac($key, $string); try { $sessionID = $client->login($merchantCode, $now, $hash); } catch (SoapFault $e) { echo "Authentication: " . $e->getMessage(); exit; } $SubscriptionSearch = new stdClass(); $SubscriptionSearch->CustomerEmail = null; $SubscriptionSearch->DeliveredCode = '___TEST___CODE____123'; $SubscriptionSearch->AvangateCustomerReference = '449686020'; $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->RenewedAfter = null; $SubscriptionSearch->RenewedBefore = null; $SubscriptionSearch->NotificationAfter = null; $SubscriptionSearch->NotificationBefore = null; $SubscriptionSearch->LifetimeSubscription = null; $SubscriptionSearch->Type = 'regular'; //'trial', 'regular', 'regularfromtrial' $SubscriptionSearch->TestSubscription = null; // true, false, null = both(default) $SubscriptionSearch->Page = 1; $SubscriptionSearch->Limit = 10; try { $allsubscriptions = $client->searchSubscriptions($sessionID, $SubscriptionSearch); } catch (SoapFault $e) { echo "allsubscriptions: " . $e->getMessage(); exit; } $subscriptionReference = $allsubscriptions[0]->SubscriptionReference; //retrieve all the upgrade options for a subscription try { $optionsforUpgrade = $client->getProductUpgradeOptions($sessionID, $subscriptionReference); } catch (SoapFault $e) { echo "optionsforUpgrade: " . $e->getMessage(); exit; } //retrieve information about the costs a customer incurs when upgrading a specific subscription $productCode = $optionsforUpgrade[1]->ProductInfo->ProductCode; $Currency = 'usd'; $Options = 'emailsupport'.';'.'oneuser1'; try { $upgradeOptions = $client->getProductUpgradeOptionsPrice($sessionID, $subscriptionReference, $productCode, $Currency, $Options); } catch (SoapFault $e) { echo "upgradeOptions: " . $e->getMessage(); exit; } var_dump("upgradeOptions", $upgradeOptions); try { $upgradadebleProduct = $client->getProductByCode($sessionID, $productCode); } catch (SoapFault $e) { echo "upgradadebleProduct: " . $e->getMessage(); exit; } $upgradadebleProductID = $upgradadebleProduct->AvangateId; $Options = 'emailsupport'.','.'oneuser1';//Replace the ; separator with , for use with query strings //$upgradelink = "https://secure.avangate.com/order/upgrade.php?LICENSE=".$subscriptionReference; //This is the simplest upgrade link you can build and use to generate a tokenized upgrade checkout URL $upgradelink = "https://store.avancart.com/order/upgrade.php?LICENSE=".$subscriptionReference."&UPGRADEPROD=".$upgradadebleProductID."&UPGRADEOPT=".$Options; //make sure to use your custom domain or secure.avangate.com otherwise $IdCustomer = $allsubscriptions[0]->AvangateCustomerReference; $CustomerType = 'AvangateCustomerReference'; $Url = $upgradelink; $ValidityTime = 10; $ValidationIp = null; try { $upgradeSSOURL = $client->getSingleSignOnInCart($sessionID, $IdCustomer, $CustomerType, $Url, $ValidityTime, $ValidationIp); } catch (SoapFault $e) { echo "ssoLINK: " . $e->getMessage(); exit; } header("Location: $upgradeSSOURL");