Subscription renewal
Overview
Use this section to handle the renewal of your subscriptions.
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
- 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.
- 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
- Shoppers select Alipay as a payment option in the checkout interface you provide to them.
- Create the order object. Use “ALIPAY” as the type of the PaymentDetails object.
- Use the placeOrder method to send the data to 2Checkout.
- Once you place the order, 2Checkout logs it into the system. At this point, the status of the order is PENDING.
- 2Checkout returns an Order object as the output of the placeOrder method.
- 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. |
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 |
---|---|
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¤cy=USD¬ify_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¤cy=USD¬ify_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:
|
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:
False – the subscription has a recurring billing cycle less than or equal to three years. |
SKU |
String |
|
Stock keeping unit you defined. |
Object |
|
|
Object with information about the delivery made to the customer - structure described below |
PartnerCode |
String |
|
Possible values:
|
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:
|
![]() |
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. |
Required (Object) |
|
|
Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details. |
Requirements
- Payment methods: Visa, MasterCard or AMEX
- Country: Brazil
- Currency BRL
- Specified number of installments under the PaymentMethod object. (Minimum installment threshold is 5 BRL.)
- Phone number
- Fiscal code (CPF/CNPJ)
-
Mandatory billing information must include:
- Transaction: non-recurring
- 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));