Skip to main content

Retrieve upgrade price

Overview

Use the getProductUpgradeOptionsPrice method to retrieve information about the costs a customer incurs when upgrading a specific subscription. Retrieve information about the costs a customer incurs when upgrading a specific subscription.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. Avangate throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

subscriptionReference

Required (string)

 

Unique, system-generated subscription identifier.

productCode

Required (string)

 

Unique identifier of the target product for the subscription upgrade process. You control the product code and can set it up in the Control Panel.

currency

Required (string)

 

ISO 4217 code.

options

Required (string)

 

Pricing options of the target product for the subscription upgrade process.

 

String - ';' separated list of 'OptionValue' returned by getProductUpgradeOptions function.

If the pricing options groups is "scale" (interval), the Options parameter should be sent like this: [option group unique code] + "=" + value

e.g. Users=7

Response

Parameters Type/Description

UpgradePrice

Object

    Details below.
  BillingPrice Int
    Net billing price available for  the upgrade process.
  BillingGrossPrice Int
    Gross billing price available for  the upgrade process.
  BillingCurrency String
    Billing currency available for the upgrade process.
  Quantity String
    Quantity available for the upgrade process.
  DisplayPrice Int
    Net display price available for the upgrade process.
  DisplayGrossPrice Int
    Gross display price available for the upgrade process.
  DisplayCurrency String
    Display currency available for the upgrade process.
  Discount Float
    Applied discounts
  DiscountedProratedPrice Float
    Prorated net price for the upgrade with applied discounts
  DiscountedProratedGrossPrice Float
    Prorated gross price for the upgrade with applied discounts
  DiscountedBillingPrice Float
    Net billing price available for  the upgrade process with applied discounts
  DiscountedBillingGrossPrice Float
    Gross billing price available for  the upgrade process with applied discounts
  DisplayDiscount Float
    Discount displayed for the upgrade process
  DiscountedDisplayPrice Float
    Net display price available for the upgrade process with applied discounts
  DiscountedDisplayGrossPrice Float
    Gross display price available for the upgrade process with applied discounts

The response returns details about the upgrade price for a single product. For multiple products, the user needs to calculate the value using the quantity x upgradePrice (the value from the returned response) parameters.

Request

<?php

require ('PATH_TO_AUTH');

$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$productCode = 'my_subscription_123';
$currency = 'usd';
$options = 'emailsupport;oneuser1';

$jsonRpcRequest = array (
'method' => 'getProductUpgradeOptionsPrice',
'params' => array($sessionID, $subscriptionReference, $productCode, $currency, $options),
'id' => $i++,
'jsonrpc' => '2.0');

var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

JSON-RPC code samples

Overview

  1. Working code samples for JSON-RPC and SOAP are available in PHP for each documented method, including the clients you need to make API calls. You need to replace the dummy Merchant Code and Secret Key with those available in your Merchant Control Panel.
  2. Working code samples for REST are available for each documented scenario and method. Check out the REST reference for examples. To access code samples, select any scenario and click on the "Working example" link. Working code samples:

 

  • cURL
  • Java
  • JavaScript
  • Node.js
  • Perl
  • Python
  • PHP
  • Ruby
  • Go
  • C#
  • Visual Basic
  • Groovy
  • Objective-C
  • Swift

 

 

Use Alipay

Overview

Alipay is a third-party online payment solution, allowing customers to make and receive payments on the Internet. Alipay's market share of online payments exceeds 54% in China.

Supported currencies

Alipay supports USD and CNY transactions.

Workflow

  1. Shoppers select Alipay as a payment option in the checkout interface you provide to them.
  2. Create the order object. Use “ALIPAY” as the type of the PaymentDetails object.
  3. Use the placeOrder method to send the data to 2Checkout.
  4. Once you place the order, 2Checkout logs it into the system. At this point, the status of the order is PENDING.
  5. 2Checkout returns an Order object as the output of the placeOrder method. 
  6. Use the Redirect Object in the PaymentMethod object of the response to create a redirect URL for your shoppers. Using the provided URL, make a request using the provided method (usually a GET request) and add the parameters (located in the Params object) as key-value pairs to URL of the request. 

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

See code sample for more details. 

Request Example

<?php

require ('PATH_TO_AUTH');


$defaultCountry = "cn";
$Currency = "USD";

$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = $Currency ;
// $Order->Currency = 'ron' ;
$Order->Country = $defaultCountry;
$Order->Language = 'EN';
$Order->CustomerIP = '10.5.22.197';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = $productCode;
$Order->Items[0]->Quantity = $productQuantity;
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false;
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.



$Order->BillingDetails = new stdClass();
$Order->BillingDetails->IsCompany = false;
$Order->BillingDetails->Address1 = 'Xian Jing Blvd 77';
$Order->BillingDetails->Address2 = 'floor 1';
$Order->BillingDetails->City = 'Shanghai';
$Order->BillingDetails->State = '';
$Order->BillingDetails->CountryCode = 'CN';
$Order->BillingDetails->Phone = '010-6552-9988';
$Order->BillingDetails->Email = 'hujianbing@336699.cn';
$Order->BillingDetails->FirstName = 'Hu';
$Order->BillingDetails->LastName = 'Jianbing';
$Order->BillingDetails->Zip = '334321';


$Order->DeliveryDetails = new stdClass();
$Order->DeliveryDetails->Address1 = 'Xian Jing Blvd 77';
$Order->DeliveryDetails->Address2 = 'floor 1';
$Order->DeliveryDetails->City = 'Shanghai';
$Order->DeliveryDetails->State = $state;
$Order->DeliveryDetails->CountryCode = 'CN';
$Order->DeliveryDetails->Phone = '010-6552-9988';
$Order->DeliveryDetails->Email = 'hujianbing@336699.cn';
$Order->DeliveryDetails->FirstName = 'Hu';
$Order->DeliveryDetails->LastName = 'Jianbing';
$Order->DeliveryDetails->Zip = '334321';
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'ALIPAY';
$Order->PaymentDetails->Currency = $Currency ;
$Order->PaymentDetails->HadPayPalToken = false;
$Order->PaymentDetails->CustomerIP = '10.5.22.197';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->PaymentMethod->ReturnURL = 'https://yourreturnurl.com';
$Order->PaymentDetails->PaymentMethod->CancelURL= 'https://yourcancelurl.com ';


$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'placeOrder';
$jsonRpcRequest->params = array($sessionID, $Order);
$jsonRpcRequest->id = $i++;

var_dump (callRPC($jsonRpcRequest, $host, true));

Response Parameters

Parameter Type/Description

Order information

Object

  Object containing order information.

 

Response Example

{
    "RefNo": "189698901",
    "OrderNo": 0,
    "ExternalReference": null,
    "ShopperRefNo": null,
    "Status": "PENDING",
    "ApproveStatus": "WAITING",
    "VendorApproveStatus": "OK",
    "MerchantCode": "251772850506",
    "Language": "en",
    "OrderDate": "2022-08-23 14:32:21",
    "FinishDate": null,
    "Source": "testAPI.com",
    "WSOrder": null,
    "Affiliate": {
        "AffiliateCode": null,
        "AffiliateSource": null,
        "AffiliateName": null,
        "AffiliateUrl": null
    },
    "HasShipping": true,
    "BillingDetails": {
        "FiscalCode": null,
        "TaxOffice": null,
        "Phone": "010-6552-9988",
        "FirstName": "John",
        "LastName": "Doe",
        "Company": null,
        "Email": "test@verifone.com",
        "Address1": "Test Address",
        "Address2": null,
        "City": "Shanghai",
        "Zip": "35005",
        "CountryCode": "cn",
        "State": null
    },
    "DeliveryDetails": {
        "Phone": "010-6552-9988",
        "FirstName": "John",
        "LastName": "Doe",
        "Company": null,
        "Email": "test@verifone.com",
        "Address1": "Test Address",
        "Address2": null,
        "City": "Shanghai",
        "Zip": "35005",
        "CountryCode": "cn",
        "State": null
    },
    "PaymentDetails": {
        "Type": "ALIPAY",
        "Currency": "cny",
        "PaymentMethod": {
            "Amount": "243",
            "Currency": "cny",
            "Redirect": {
                "Url": "https://intlmapi.alipay.com/gateway.do?_input_charset=utf-8&currency=USD&notify_url=https%3A%2F%2Fsecure.2checkout.com%2Falipay%2Fipn.php&out_trade_no=189698901&partner=2088201540985859&refer_url=1.TEST.MOR.com&return_url=https%3A%2F%2Fsecure.2checkout.com%2Forder%2Fgateway_return.php&rmb_fee=243&service=create_forex_trade&subject=2Checkout%E7%92%81%E3%88%A0%E5%B4%9F+%E9%8D%97%E6%9B%9E%E5%BD%BF%3A+%23189698901&trade_information%5Bbusiness_type%5D=4&trade_information%5Bgoods_info%5D=LPUJL13OZ6%5E1&trade_information%5Btotal_quantity%5D=1&sign=1c6c63019202662f10a96b528f8ee1a4&sign_type=MD5",
                "Method": "GET",
                "Params": {
                    "_input_charset": "utf-8",
                    "currency": "USD",
                    "notify_url": "https://secure.2checkout.com/alipay/ipn.php",
                    "out_trade_no": "189698901",
                    "partner": "2088201540985859",
                    "refer_url": "1.TEST.MOR.com",
                    "return_url": "https://secure.2checkout.com/order/gateway_return.php",
                    "rmb_fee": "243",
                    "service": "create_forex_trade",
                    "subject": "2Checkout璁㈠崟 鍗曞彿: #189698901",
                    "trade_information": {
                        "business_type": "4",
                        "goods_info": "LPUJL13OZ6^1",
                        "total_quantity": "1"
                    },
                    "sign": "1c6c63019202662f10a96b528f8ee1a4",
                    "sign_type": "MD5"
                },
                "FullHtml": "<!DOCTYPE html>\n<html lang=\"EN\"><body><script type=\"text/javascript\">window.location.replace(\"https://intlmapi.alipay.com/gateway.do?_input_charset=utf-8&currency=USD&notify_url=https%3A%2F%2Fsecure.2checkout.com%2Falipay%2Fipn.php&out_trade_no=189698901&partner=2088201540985859&refer_url=1.TEST.MOR.com&return_url=https%3A%2F%2Fsecure.2checkout.com%2Forder%2Fgateway_return.php&rmb_fee=243&service=create_forex_trade&subject=2Checkout%E7%92%81%E3%88%A0%E5%B4%9F+%E9%8D%97%E6%9B%9E%E5%BD%BF%3A+%23189698901&trade_information%5Bbusiness_type%5D=4&trade_information%5Bgoods_info%5D=LPUJL13OZ6%5E1&trade_information%5Btotal_quantity%5D=1&sign=1c6c63019202662f10a96b528f8ee1a4&sign_type=MD5\");</script></body></html>"
            },
            "ReturnURL": https://yourreturnurl.com,
            "CancelURL": https://yourcancelurl.com,
            "RecurringEnabled": false,
            "Vendor3DSReturnURL": null,
            "Vendor3DSCancelURL": null,
            "InstallmentsNumber": null
        },
        "CustomerIP": "91.220.121.21"
    },
    "DeliveryInformation": {
        "ShippingMethod": {
            "Code": null,
            "TrackingUrl": null,
            "TrackingNumber": null,
            "Comment": null
        }
    },
    "CustomerDetails": null,
    "Origin": "API",
    "AvangateCommission": 18,
    "OrderFlow": "REGULAR",
    "GiftDetails": null,
    "PODetails": null,
    "ExtraInformation": null,
    "PartnerCode": null,
    "PartnerMargin": null,
    "PartnerMarginPercent": null,
    "ExtraMargin": null,
    "ExtraMarginPercent": null,
    "ExtraDiscount": null,
    "ExtraDiscountPercent": null,
    "LocalTime": null,
    "TestOrder": false,
    "FxRate": 0.14024803891494,
    "FxMarkup": 4,
    "PayoutCurrency": "USD",
    "DeliveryFinalized": false,
    "Errors": null,
    "Items": [
        {
            "ProductDetails": {
                "Name": "Test Product",
                "ShortDescription": "<p>Join all your clouds in a big one</p>",
                "Tangible": false,
                "IsDynamic": false,
                "ExtraInfo": null,
                "RenewalStatus": false,
                "Subscriptions": null,
                "DeliveryInformation": {
                    "Delivery": "BY_AVANGATE",
                    "DownloadFile": null,
                    "DeliveryDescription": "",
                    "CodesDescription": "",
                    "Codes": []
                }
            },
            "PriceOptions": [],
            "Price": {
                "UnitNetPrice": 243,
                "UnitGrossPrice": 243,
                "UnitVAT": 0,
                "UnitDiscount": 0,
                "UnitNetDiscountedPrice": 243,
                "UnitGrossDiscountedPrice": 243,
                "UnitAffiliateCommission": 0,
                "ItemUnitNetPrice": null,
                "ItemUnitGrossPrice": null,
                "ItemNetPrice": null,
                "ItemGrossPrice": null,
                "VATPercent": 0,
                "HandlingFeeNetPrice": 0,
                "HandlingFeeGrossPrice": 0,
                "Currency": "cny",
                "NetPrice": 243,
                "GrossPrice": 243,
                "NetDiscountedPrice": 243,
                "GrossDiscountedPrice": 243,
                "Discount": 0,
                "VAT": 0,
                "AffiliateCommission": 0
            },
            "LineItemReference": "281d818c9b23daf15405807916e95dac5423d043",
            "PurchaseType": "PRODUCT",
            "Code": "LPUJL13OZ6",
            "ExternalReference": "",
            "Quantity": 1,
            "SKU": null,
            "CrossSell": null,
            "Trial": null,
            "AdditionalFields": null,
            "Promotion": null,
            "RecurringOptions": null,
            "SubscriptionStartDate": null,
            "SubscriptionCustomSettings": null,
            "UpSell": null
        }
    ],
    "Promotions": [],
    "AdditionalFields": null,
    "Currency": "cny",
    "NetPrice": 243,
    "GrossPrice": 243,
    "NetDiscountedPrice": 243,
    "GrossDiscountedPrice": 243,
    "Discount": 0,
    "VAT": 0,
    "AffiliateCommission": 0,
    "CustomParameters": null,
    "Refunds": null
}

For more on how to redirect shoppers to the payment method page to finalize the payment, read here.

Clear shopping cart contents

Overview

Use this method to completely clear the contents of the shopping cart.

Requirements

Use this method before placeOrder.

Parameters

Parameter Type/Description
sessionID Required (string)
  Session identifier, which is the output of the Login method. An exception is thrown if the values are incorrect

Response

Parameter Type/Description
Result Boolean
  True or false

Request

<?php

require('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/02Authentication
require('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/Partner/00Set_partner
require('PATH_TO_addProduct'); // addProduct example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/08Place_an_order/00Add_product_to_cart

try {
    $ClearCart= $client->clearProducts ($sessionID);
} catch (SoapFault $e) {
    echo "CartClear: " . $e->getMessage();
    exit;
}
var_dump ("CartClear ", $ClearCart);

Subscription history

Overview

Retrieve information about a subscription. Subscriptions can be retrieved starting with 5 minutes after their orders are generated in the 2Checkout system.

Parameters

Parameters

Type/Description

ReferenceNo

String

 

Unique, system-generated order reference number.

Type

String

 

Purchase type:

  • SALE
  • RENEWAL
  • UPGRADE

SubscriptionReference

String

 

Unique, system-generated subscription reference.

StartDate

String

 

Subscription start date(YYYY-MM-DD) - StartDate is mandatory when importing subscription data. If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then the StartDate you provide must be in accordance with your custom configuration.

ExpirationDate

String

 

Subscription expiration date(YYYY-MM-DD) - ExpirationDate is mandatory when importing subscription data. If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then the ExpirationDate you provide must be in accordance with your custom configuration.

Lifetime

Boolean

 

Possible values:

  • True – the subscription is evergreen

False – the subscription has a recurring billing cycle less than or equal to three years.

SKU

String

 

Stock keeping unit you defined.

DeliveryInfo

Object

 

Object with information about the delivery made to the customer - structure described below

PartnerCode

String

 

Possible values:

  • Empty = ecommerce order
  • Partner Code

 

Subscription renewal

Overview

Use this section to handle the renewal of your subscriptions.

You can retrieve information regarding the renewal status of a subscription, including the manual renewal link that a customer needs to access in order to renew.

Enable or disable the recurring billing for a subscription using the API methods displayed below.

 

Brazil - the next great eCommerce opportunity

With a population of 202M and the 6th largest world economy, Brazil accounts for 59% of Latin American eCommerce revenues. World-class technology combined with a market size bigger than UK, Italy, Russia, or India makes Brazil the next great eCommerce opportunity. Ralf Germer, the CEO, of 4M Iberoamérica, shares his insights into Latin America's eCommerce presence - examining market trends, online revenue growth predictions, and key indicators of Brazil's growing market strength. 

Watch our webinar to find out how to accelerate your online sales by expanding into Brazil's eCommerce market. We'll highlight why Brazil may be the next market you'll want to enter, examine some of the challenges companies face when entering this unique market, and highlight how 2Checkout can help you ramp up fast.

Watch this webinar and discover:

  • Why Brazil is called the "King of Latin American eCommerce" and why that's perfect for your online business
  • 4 Steps to ramp up online sales in Brazil quickly
  • Challenges expanding into Brazil and how 2Checkout can help
Join Our Webinar

 

Place an order with installments

Overview 

Use the placeOrder method to create an order and collect the payment.

Supported payment methods 

Credit/Debit cards: Visa and MasterCard local Brazilian cards.

Parameters 

Parameters

Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. Avangate throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

Requirements

  1. Payment methods: Visa, MasterCard or AMEX
  2. Country: Brazil
  3. Currency BRL
  4. Specified number of installments under the PaymentMethod object. (Minimum installment threshold is 5 BRL.)
    • Phone number
    • Fiscal code (CPF/CNPJ)
  5. Mandatory billing information must include:

  6. Transaction: non-recurring
  7. Installments are available only for:
    • Brazilian customers
    • Local Visa, MasterCard and AMEX cards
    • Non-recurring transactions

<?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);
 
$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'brl';
$Order->Country = 'BR';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1; 
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false; 
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->Promotion = NULL;
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'FirstName';
$Order->BillingDetails->LastName = 'LastName';
$Order->BillingDetails->CountryCode = 'BR';
$Order->BillingDetails->State = 'DF';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '70403-900';
$Order->BillingDetails->Email = 'customer@email.com';
$Order->BillingDetails->Phone = "556133127400";
$Order->BillingDetails->FiscalCode = "056.027.963-98";
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'CC';
$Order->PaymentDetails->Currency = 'brl';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";
$Order->PaymentDetails->PaymentMethod->CardType = 'visa';
$Order->PaymentDetails->PaymentMethod->ExpirationYear = '2019';
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = '12';
$Order->PaymentDetails->PaymentMethod->HolderName = 'John';
$Order->PaymentDetails->PaymentMethod->CCID = '123';
$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

$jsonRpcRequest = array (
'method' => 'getInstallments',
'params' => array($sessionID, $Order),
'id' => $i++,
'jsonrpc' => '2.0'
);
echo '<BR>';
echo 'The content of the current session:';
echo '<BR>';
$installments = callRPC((Object)$jsonRpcRequest, $host, true);
var_dump ($installments);
$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'brl';
$Order->Country = 'BR';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1; 
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false; 
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->Promotion = NULL;
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'FirstName';
$Order->BillingDetails->LastName = 'LastName';
$Order->BillingDetails->CountryCode = 'BR';
$Order->BillingDetails->State = 'DF';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '70403-900';
$Order->BillingDetails->Email = 'customer@email.com';
$Order->BillingDetails->Phone = "556133127400";
$Order->BillingDetails->FiscalCode = "056.027.963-98";
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'CC';
$Order->PaymentDetails->Currency = 'brl';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";
$Order->PaymentDetails->PaymentMethod->InstallmentsNumber = 2;
$Order->PaymentDetails->PaymentMethod->CardType = 'visa';
$Order->PaymentDetails->PaymentMethod->ExpirationYear = '2019';
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = '12';
$Order->PaymentDetails->PaymentMethod->HolderName = 'John';
$Order->PaymentDetails->PaymentMethod->CCID = '123';
$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

$jsonRpcRequest = array (
'method' => 'placeOrder',
'params' => array($sessionID, $Order),
'id' => $i++,
'jsonrpc' => '2.0'
);
echo '<BR>';
echo 'The content of the current session:';
echo '<BR>';
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

Use WeChat Pay

Overview

Place an order for catalog products defined in your Control Panel and collect the payment using WeChat Pay.

Requirements

Only Chinese shoppers are able to purchase using WeChat Pay. Make sure the billing country code is set to CN.

Supported currencies

  • USD
  • HKD
  • CNY

Workflow

  1. Shoppers select WeChat as payment option in the interface you provide to them.
  2. Create the order object. Use WE_CHAT_PAY as the type of the PaymentDetails object, and include ReturnURL and CancelURL.
  3. Use the placeOrder method to send the data to Avangate.
  4. Once you place the order, Avangate logs it into the system. At this point in time, the status of the order is PENDING.
  5. Avangate returns an Order object as the output of the placeOrder method. 
  6. Use the PaymentMethod object to create a redirect URL for the shoppers, concatenating the values of the Href and avng8apitoken parameters. Here's an example of the redirect URL:
    https://api.avangate.com/4.0/scripts/we_chat_pay/authorize/?avng8apitoken=1abc7fd72d008428
  7. After being redirected to WeChat Pay, shoppers need to scan the QR code provided, using the WeChat smartphone app.
  8. After customers enter their payment password, WeChat notifies Avangate if the payment is approved, and the status of the order becomes COMPLETE.
  9. Shoppers are redirected to the RedirectURL from the Order information object. In case the payment fails, shoppers are redirected to the CancelURL. 

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. Avangate throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

To place an order with WeChat, use WE_CHAT_PAY as the type of the PaymentDetails object and provide a ReturnURL and a CancelURL as part of the PaymentMethod object. See code sample. 

Response

Parameters Type/Description
Order Object
  Object containing order information.

Request

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'usd';
$Order->Country = 'CN';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1;
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false;
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'Test Cosmin API';
$Order->BillingDetails->LastName = 'Cosmin API';
$Order->BillingDetails->CountryCode = 'CN';
$Order->BillingDetails->State = 'California';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '90210';
$Order->BillingDetails->Email = 'cosmin.deftu@avangate.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;

$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'WE_CHAT_PAY';
$Order->PaymentDetails->Currency = 'USD';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '91.220.121.21';
$Order->PaymentDetails->PaymentMethod->ReturnURL = 'http://yourreturnurl.com';
$Order->PaymentDetails->PaymentMethod->CancelURL= 'http://yourcancelurl.com';

$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

$jsonRpcRequest = array (
'method' => 'placeOrder',
'params' => array($sessionID, $Order),
'id' => $i++,
'jsonrpc' => '2.0'
);

$output = callRPC($jsonRpcRequest, $host);

$wechatredirect = $output->PaymentDetails->PaymentMethod->Authorize->Href."/?avng8apitoken=".$output->PaymentDetails->PaymentMethod->Authorize->Params->avng8apitoken;

header('Location:' . $wechatredirect);

Subscription history

Overview

Retrieve information about a subscription's history. Subscriptions can be retrieved starting with 5 minutes after their orders are generated in the 2Checkout system.

Use the API methods displayed below to extend or renew a subscription.

 

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo