Order object
Overview
Use this object to create new orders and collect payments from shoppers.
Supported payment methods
- Credit/Debit cards: Visa, Visa Electron, MasterCard, Maestro, Amex, Discover, Dankort, Carte Bleue, JCB. 2Checkout supports local Brazilian cards.
- PayPal and PayPal Express
- Purchase Order
- Wire
- Check
- Previous order references - In addition to the payment methods enumerated above, 2Checkout also supports 1-click purchase flows in which you use valid previous order references belonging to returning customers to pay for new orders with their previously used cards and PayPal accounts.
Currency support
Check with 2Checkout support for a list of currencies available for each payment method.
Parameters
Order object parameters | Type/Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RefNo |
Optional (string) |
||||||||||
|
Unique, system-generated, order reference number.
Do not include it when placing new orders or send it as NULL. |
||||||||||
Currency |
Required (string) |
||||||||||
|
The currency ISO code for the payment - ISO 4217. Example: “usd.” |
||||||||||
Country |
Required (string) |
||||||||||
Shopper country. ISO 3166 two-letter code. Example: “us.” |
|||||||||||
Language |
Optional (string) |
||||||||||
|
ISO 639-1 two-letter code. Language used for the purchase process. Example: “en.” |
||||||||||
ExternalReference |
Optional (string) |
||||||||||
|
Set external reference identifiers for orders. Enables you to replicate the functionality of the REF parameter included in Buy-Links. Maximum 100 characters. If there is a need for longer references, you can apply an md5 hash for any string value, resulting in a 32 characters string. You can verify the hash after the order notification, on the client-side. |
||||||||||
Source |
Optional (string) |
||||||||||
|
The link source for the sales. Enables you to replicate the functionality of the SRC (separate link identifier) parameter when included into Buy Links. Use the SRC parameter to track sale sources.
Maximum length 255 characters. |
||||||||||
AffiliateId |
Optional (int) |
||||||||||
|
Identifier belonging to affiliates who refer orders. |
||||||||||
CustomerReference |
Optional (Int) |
||||||||||
|
System-generated 2Checkout customer reference. Aggregate subscriptions under the same Customer account by adding the AV_CUSTOMERID (case sensitive) parameter to buy links. The 2Checkout system generates default customer numerical (integer) IDs (AV_CUSTOMERID) automatically for all orders containing products that feature subscriptions. |
||||||||||
Items |
Required (array of objects) |
||||||||||
Details below. | |||||||||||
|
OrderItem |
Object |
|||||||||
Details below. | |||||||||||
|
|
Code |
Required (string) |
||||||||
|
|
|
Unique product identifier your control. Max length 256 characters. |
||||||||
|
|
Quantity |
Required (integer) |
||||||||
|
|
|
Number of units |
||||||||
|
|
PriceOptions |
Optional (array of strings) |
||||||||
|
|
|
Array of price option codes. |
||||||||
|
|
SKU |
Optional (string) |
||||||||
|
|
|
SKU identifier. |
||||||||
|
|
Price |
Object - Can be NULL |
||||||||
|
|
|
|
OrderPrice |
Object - Can be NULL |
||||||
|
|
|
|
|
Currency |
Optional (string) |
|||||
|
|
|
|
|
|
The currency ISO code for the payment - ISO 4217. Example: usd. |
|||||
|
|
|
|
|
NetPrice |
Optional (double) |
|||||
|
|
|
|
|
|
Order value excluding sales tax/VAT expressed in the payment currency. |
|||||
|
|
|
|
|
GrossPrice |
Optional (double) |
|||||
|
|
|
|
|
|
Total order value, including sales tax/VAT expressed in the payment currency. GrossPrice does not reflect any discounts. |
|||||
|
|
|
|
|
NetDiscountedPrice |
Optional (double) |
|||||
|
|
|
|
|
|
The NetPrice order value excluding sales tax/VAT, from which 2Checkout deducts discounts. NetDiscountedPrice is expressed in the payment currency. |
|||||
|
|
|
|
|
GrossDiscountedPrice |
Optional (double) |
|||||
|
|
|
|
|
|
Total costs shoppers incur, expressed in the payment currency. This value includes sales tax/VAT, 2Checkout, and affiliate commissions, but 2Checkout deducts the value of any discounts.
For example:
AffiliateCommission: 94.05 |
|||||
|
|
|
|
|
Discount |
Optional (double) |
|||||
|
|
|
|
|
|
Value of the discounts for an order expressed in the payment currency. |
|||||
|
|
|
|
|
VAT |
Optional (double) |
|||||
|
|
|
|
|
|
Value of sales tax/VAT expressed in the payment currency. |
|||||
|
|
|
|
|
AffiliateCommission |
Optional (double) |
|||||
|
|
|
|
|
|
Value of the affiliate commission for the order calculated from the NetDiscountedPrice expressed in the payment currency. Or NULL. 2Checkout does not take into account shipping costs when calculating affiliate commissions. |
|||||
|
|
|
|
UnitNetPrice |
Optional (double) |
||||||
|
|
|
|
|
The value per product unit, excluding sales tax/VAT expressed in the payment currency. |
||||||
|
|
|
|
UnitGrossPrice |
Optional (double) |
||||||
|
|
|
|
|
Total value per product unit, including sales tax/VAT expressed in the payment currency. UnitGrossPrice does not reflect any discounts. |
||||||
|
|
|
|
UnitVAT |
Optional (double) |
||||||
|
|
|
|
|
Sales tax/VAT per product unit expressed in the payment currency. |
||||||
|
|
|
|
UnitDiscount |
Optional (double) |
||||||
|
|
|
|
|
Value of the discount per product unit expressed in the payment currency. |
||||||
|
|
|
|
UnitNetDiscountedPrice |
Optional (double) |
||||||
|
|
|
|
|
The value per product unit, expressed in the payment currency, excluding sales tax/VAT, from which 2Checkout deducts the unit discount. |
||||||
|
|
|
|
UnitGrossDiscountedPrice |
Optional (double) |
||||||
|
|
|
|
|
Total costs shoppers incur per product unit, expressed in the payment currency. This value includes sales tax/VAT, 2Checkout and affiliate commissions, but 2Checkout deducts the value of any discounts. |
||||||
|
|
|
|
UnitAffiliateCommission |
Optional (double) |
||||||
|
|
|
|
|
Value of the affiliate commission per product unit calculated expressed in the payment currency.
2Checkout deducts discounts from the costs incurred by shoppers before calculating affiliate commissions.
2Checkout does not take into account shipping costs when calculating affiliate commissions.
NULL when 2Checkout does not apply an affiliate commission. |
||||||
|
|
CrossSell |
Object – Can be NULL |
||||||||
Details below. | |||||||||||
|
|
|
ParentCode |
Optional (string) |
|||||||
|
|
|
|
The product code of the master product you set to trigger the campaign. |
|||||||
|
|
|
CampaignCode |
Optional (string) |
|||||||
|
|
|
|
Unique, system-generated identifier for cross-sell campaigns. |
|||||||
|
|
Trial |
Optional (Object) – Can be NULL |
||||||||
Details below. | |||||||||||
|
|
|
Period |
Optional (integer) |
|||||||
|
|
|
|
The length of the trial subscription lifetime in days. |
|||||||
|
|
|
Price |
Optional (double) |
|||||||
|
|
|
|
Total trial price in the payment currency before 2Checkout deducts any taxes, discounts, etc. |
|||||||
|
|
AdditionalFields |
Optional (array of objects) – Can be NULL |
||||||||
|
|
|
AdditionalFieldSet |
Optional (Object) – Can be NULL |
|||||||
|
|
|
|
Code |
Optional (string) |
||||||
|
|
|
|
|
The alpha-numeric characters, underscores and dashes that are set as the field identifier. |
||||||
|
|
|
|
Value |
Optional (string) |
||||||
|
|
|
|
|
Selected field value. |
||||||
SubscriptionStartDate | Optional (string) | ||||||||||
Specify the date time stamp when the subscription becomes active. Format 2016-07-02 22:22:22 (YYYY-MM-DD HH:mm:ss). Available for JSON-RPC and REST. Send empty or NULL to activate subscriptions on the same date when customers purchase them. You can exclude HH:mm:ss when sending the date and include only YYYY-MM-DD. In this case, 2Checkout uses 00:00:01. Default time zone GMT+02:00. |
|||||||||||
|
|
Promotion |
Optional (Object) |
||||||||
Details below. | |||||||||||
|
|
|
Name |
Optional (string) |
|||||||
|
|
|
|
Promotion name. |
|||||||
|
|
|
Description |
Optional (string) |
|||||||
|
|
|
|
Promotion description. |
|||||||
|
|
|
StartDate |
Optional (string) |
|||||||
|
|
|
|
The date when you set the promotion to start. NULL for promotions that start immediately after you create them. |
|||||||
|
|
|
EndDate |
Optional (string) |
|||||||
|
|
|
|
The date when you set the promotion to end. NULL for promotions you want active indefinitely. |
|||||||
|
|
|
MaximumOrdersNumber |
Optional (integer) |
|||||||
|
|
|
|
2Checkout only applies the promotion to a maximum number of orders you define.
Can be NULL if you want the promotion to apply to an unlimited number of orders. |
|||||||
|
|
|
MaximumQuantity |
Optional (integer) |
|||||||
|
|
|
|
Discount only applies to a maximum number of units purchased through a single order, smaller than the quantity you defined. Shoppers purchase any extra units at full price. Can be NULL if you want the promotion to apply to an unlimited number units. |
|||||||
|
|
|
InstantDiscount |
Optional (boolean) |
|||||||
|
|
|
|
The instant discount option auto-applies the discount for ALL selected products, without the need for shoppers to enter a discount coupon. |
|||||||
|
|
|
Coupon |
Optional (string) |
|||||||
|
|
|
|
Promotion coupon/voucher. |
|||||||
|
|
|
DiscountLabel |
Optional (string) |
|||||||
|
|
|
|
Discounts can be set as a percentage from the product price or as a fixed amount in the chosen currency. |
|||||||
|
|
|
Enabled |
Optional (string) |
|||||||
|
|
|
|
true or false, depending on whether a promotion is active or disabled. |
|||||||
|
|
|
Type |
Optional (string) |
|||||||
|
|
|
|
|
|||||||
BillingDetails |
Required (Object) |
||||||||||
Details below. | |||||||||||
|
Person |
Object |
|||||||||
Details below. | |||||||||||
|
|
FirstName |
Required (string) |
||||||||
|
|
|
Shopper name. |
||||||||
|
|
LastName |
Required (string) |
||||||||
|
|
|
Shopper surname. |
||||||||
|
|
CountryCode |
Required (string) |
||||||||
|
|
|
Shopper country. ISO 3166 two-letter code. |
||||||||
|
|
State |
Required (string) for US, Brazil and Romania |
||||||||
|
|
|
The state in the shopper's country. Mandatory when you set the Billing Country to US, Brazil and Romania. Use case insensitive utf8 strings for the full name, or just the two letter code. |
||||||||
|
|
City |
Required (string) |
||||||||
|
|
|
Shopper city. |
||||||||
|
|
Address1 |
Required (string) |
||||||||
|
|
|
Shopper address. |
||||||||
|
|
Address2 |
Optional (string) |
||||||||
|
|
|
Shopper address. |
||||||||
|
|
Zip |
Required (string) for US, Brazil and Romania |
||||||||
|
|
|
ZIP/ Postal code. |
||||||||
|
|
|
Required (string) |
||||||||
|
|
|
Shopper email address. |
||||||||
|
|
Phone |
Optional (string) |
||||||||
|
|
|
Shopper phone number. Mandatory when you set Brazil as the Billing Country. Can be NULL. |
||||||||
|
|
Company |
Optional (string) |
||||||||
|
|
|
Company name. Can be null for end users. When present, you also need to provide the FiscalCode. |
||||||||
|
FiscalCode |
Optional (string) – Required for Brazil |
|||||||||
|
|
• For companies, it needs to be the VAT ID. 2Checkout will validate the value provided and throw an error if the VAT ID is invalid/incorrect when calling setPaymentDetails. When present, you also need to provide the Company name. • Mandatory when you set Brazil as the Billing Country. For Brazilian customers it represents the Fiscal Code (CPF/CNPJ). • Can be NULL for end users. |
|||||||||
DeliveryDetails |
Required (Object) |
||||||||||
Details below. | |||||||||||
|
Person |
Object |
|||||||||
Details below. | |||||||||||
|
|
FirstName |
Required (string) |
||||||||
|
|
|
Shopper name from the delivery details. |
||||||||
|
|
LastName |
Required (string) |
||||||||
|
|
|
Shopper surname from the delivery details. |
||||||||
|
|
CountryCode |
Optional (string) |
||||||||
|
|
|
Shopper country. ISO 3166 two-letter code from the delivery details. |
||||||||
|
|
State |
Optional (string) – Required for US, Brazil and Romania |
||||||||
|
|
|
The state in the shopper's country from the delivery details. Mandatory when you set the Billing Country to US, Brazil and Romania. Use case insensitive utf8 strings for the full name, or just the two letter code. |
||||||||
|
|
City |
Optional (string) |
||||||||
|
|
|
Shopper city from the delivery details. |
||||||||
|
|
Address1 |
Optional (string) |
||||||||
|
|
|
Shopper address from the delivery details. |
||||||||
|
|
Address2 |
Optional (string) |
||||||||
|
|
|
Shopper address from the delivery details. |
||||||||
|
|
Zip |
Optional (string) |
||||||||
|
|
|
ZIP/ Postal code from the delivery details. |
||||||||
|
|
|
Optional (string) |
||||||||
|
|
|
Shopper email address from the delivery details. |
||||||||
|
|
Phone |
Optional (string) |
||||||||
|
|
|
Shopper phone number from the delivery details. Mandatory when you set Brazil as the Billing Country. Can be NULL. |
||||||||
|
|
Company |
Optional (string) |
||||||||
|
|
|
Company name from the delivery details. Can be null for end users. When present, you also need to provide the FiscalCode. |
||||||||
PaymentDetails |
Required (Object) |
||||||||||
|
Adapt this object to the desired payment method. |
||||||||||
Type |
Required (string) |
||||||||||
|
|
The payment method:
|
|||||||||
|
Currency |
Required (string) |
|||||||||
|
|
The currency ISO code for the payment - ISO 4217. Example: “usd.” |
|||||||||
|
PaymentMethod |
Required (string) |
|||||||||
|
|
Object structure and parameters differ according to the payment method selected and API method (placing orders (POST) vs. retrieving order data (GET)).
NULL for 0 value orders for which you’re not requiring customers to enter payment details. |
|||||||||
RecurringEnabled | Optional (boolean) | ||||||||||
true – shopper checks the auto-renewal checkbox and 2Checkout charges subscription renewals using a recurring billing process. false – shopper doesn’t check the auto-renewal checkbox. |
|||||||||||
|
|
|
CardPayment |
Optional (object) |
|||||||
Details below. | |||||||||||
|
|
|
|
CardNumber |
Optional (string) |
||||||
|
|
|
|
|
The credit/debit card number. |
||||||
|
|
|
|
CardType |
Optional (string) |
||||||
|
|
|
|
|
visa, visaelectron, mastercard, maestro, amex, discover, dankort, cartebleue, jcb, hipercard, elo |
||||||
|
|
|
|
ExpirationYear |
Optional (string) |
||||||
|
|
|
|
|
The year in which the card expires. |
||||||
|
|
|
|
ExpirationMonth |
Optional (string) |
||||||
|
|
|
|
|
The month in which the card expires. |
||||||
|
|
|
|
HolderName |
Optional (string) |
||||||
|
|
|
|
|
Card holder name. |
||||||
|
|
|
|
CCID |
Optional (string) |
||||||
|
|
|
|
|
Credit Card Identification - an extra ID printed on the card, usually a 3-4 digit number, the CVC2/CVV2. |
||||||
HolderNameTime | Optional (float) | ||||||||||
The interval of time in seconds in which shoppers enter their name in the HolderName field. An abnormally short interval is usually a red flag for fraud attempts. Can be NULL, but not a negative number. |
|||||||||||
CardNumberTime |
Optional (float) |
||||||||||
The interval of time in seconds in which shopper enters their card number in the CardNumber field. An abnormally short interval is usually a red flag for fraud attempts. Can be NULL, but not a negative number. |
|||||||||||
InstallmentsNumber | Optional (Int) | ||||||||||
Number of installments. Available only when customers un Brazil pay with Visa or MasterCard using Brazilian Real as the order currency. Use 1 or exclude the parameter for full payments. | |||||||||||
|
|
|
PayPalExpress |
Optional (object) |
|||||||
Details below. | |||||||||||
|
|
|
|
|
Optional (string) |
||||||
|
|
|
|
|
Email address customers use for their PayPal account. |
||||||
|
|
|
|
ReturnURL |
Optional (string) |
||||||
|
|
|
|
|
The PayPal Express Checkout redirect URL returned by calling the getPayPalExpressCheckoutRedirectURL method. The return URL is the page on your website to which PayPal redirects your buyer's browser after the buyer logs in to PayPal and approves the payment. Typically, this is a secure page (https://...) on your site. |
||||||
|
|
|
|
CancelURL |
Optional (string) |
||||||
|
|
|
|
|
The cancel URL is the page on your website to which PayPal redirects your buyer's browser if the buyer does not approve the payment. Typically, this is the secure page (https://...) on your site from which you redirected the buyer to PayPal. |
||||||
|
|
|
PreviousOrder |
Optional (Object) |
|||||||
Details below. | |||||||||||
|
|
|
|
RefNo |
Optional (string) |
||||||
|
|
|
|
|
Order reference a previous purchase that reached the Approved/Complete status. You can use order for which customers paid with credit/debit cards or with PayPal. The status of the order should be AUTHRECEIVED or COMPLETE.
Check the validity of references with the isValidOrderReference method.
The 2Checkout system blocks you from using references for fraudulent or potentially fraudulent orders. |
||||||
|
|
|
PurchaseOrderPaymentDetails |
Optional (Object) |
|||||||
Details below. | |||||||||||
|
|
|
|
InternalPONumber |
Optional (string) |
||||||
|
|
|
|
|
Identifier that business customers use internally in their organization to track and manage Purchase Orders (PO). Can be NULL. |
||||||
|
|
|
|
AutoApprove |
Optional (boolean) |
||||||
|
|
|
|
|
TRUE - requires activation of the PO AutoApprove package (If the package is inactive 2Checkout returns an error). Please contact 2Checkout. When AutoApprove is TRUE, 2Checkout no longer requires that business customers upload a PO document. As such, PO orders are automatically approved for your account, without a PO doc. 2Checkout sets the PURCHASE_PENDING status for auto-approved PO orders. FALSE - Default. Send this if the PO AutoApprove package is not available for your account. 2Checkout uses the same flow as cart purchases with Purchase Orders for business customers placing orders with POs via API. This means that customers receive the same emails as if they made the purchase using the cart and need to update the PO document, which is reviewed by 2Checkout and that you need to approve. 2Checkout sets the AVAITING_UPLOAD status for POs andUnfinished for their orders.
Can be NULL. |
||||||
|
|
|
EXISTING_PAYMENT_DATA |
Optional (Object) |
|||||||
|
|
|
|
By using EXISTING_PAYMENT_DAT you no longer require shoppers to enter any payment details. |
|||||||
|
|
|
|
TransientToken |
Optional (string) |
||||||
|
|
|
|
|
Returned as a part of the process of retrieving customer information by SSOToken. |
||||||
|
CustomerIP |
Required (string) |
|||||||||
|
|
Shopper IP. |
|||||||||
Promotions |
Optional (Array of strings) |
||||||||||
|
Array of promotion codes. |
||||||||||
AdditionalFields |
|
||||||||||
Details below. | |||||||||||
|
Code |
Optional (string) |
|||||||||
|
|
The alpha-numeric characters, underscores and dashes that are set as the field identifier. |
|||||||||
|
Text |
Optional (string) |
|||||||||
|
|
Field text visible to shoppers in the cart. |
|||||||||
|
Value |
Optional (string) |
|||||||||
|
|
Selected field value. |
|||||||||
LocalTime |
Optional (string) |
||||||||||
|
Local shopper time in the following format: Y-m-d H:i:s. This parameter can impact the fraud score of an order when it's missing, NULL or incorrectly formatted. |
||||||||||
GiftDetails |
Optional (object) |
||||||||||
|
Contains contact details for the recipient of gift purchase. |
||||||||||
|
FirstName |
Optional (string) |
|||||||||
|
|
First name of gift recipient. |
|||||||||
|
LastName |
Optional (string) |
|||||||||
|
|
Last name of gift recipient. |
|||||||||
|
|
Optional (string) |
|||||||||
|
|
Email of gift recipient. 2Checkout uses this email for the delivery/fulfillment process. |
|||||||||
|
GiftNote |
Optional (string) |
|||||||||
|
|
Custom text shoppers provide as a message to the gift recipient. |
Add product to cart
Overview
Use this method to add products to cart, during the current cart session.
Requirements
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. | |
productId | Required (integer) |
Unique product identifier from the Avangate system. | |
pricingListCode | Required (string) |
The unique identifier of a partner price list. | |
quantity | Optional (integer) |
Defines the amount of product units to be ordered. If no quantity info is provided, the minimum available number of units is included in the order.
If the quantity provided is not available for purchase, such as in the case of volume discounts, en error message is displayed.
When NULL, quantity = 1 is added automatically. |
|
priceOptions | Optional (StringArray) |
Array of price options codes. If no price options info is provided, the default, required pricing options of the product are ordered. These identifiers mark the individual options inside pricing options configuration groups.
Can be NULL. |
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
$productId = 'YOUR_PRODUCT_ID';
$pricingListCode = 'YOUR_PRICING_LIST_CODE';
$quantity = YOUR_QUANTITY;
$priceOptions = array(
'Pricing_options_group_code1',
'Pricing_options_group_code2'
);
try {
$OrderProduct= $client->addProduct($sessionID, $productId, $quantity, $priceOptions, $pricingListCode);
} catch (SoapFault $e) {
echo "ProductinCart: " . $e->getMessage();
exit;
}
var_dump ("ProductinCart ", $OrderProduct);
Errors
Error | Description |
---|---|
INVALID_PARTNER |
No partner is set. |
PRODUCT_ERROR |
Invalid product ID. |
PARTNER_PRICING_LISTS_NOT_FOUND |
There are no pricing lists with the provided code. |
PRODUCT_NOT_FOUND |
There is no active product with the specified product ID in the given pricing list. |
INVALID_QUANTITY |
Quantity is not available for purchase. |
Add a pricing configuration
Overview
Use the addPricingConfiguration method to add a new pricing configuration for your account.
Parameters
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. |
PricingConfiguration |
Required (object) |
|
Use this object to add a new pricing configuration for your account. |
ProductCode |
Required (string) |
|
The code of the produt you assign the configuration to. |
Response
bool(true)
Request
<?php
$host = "https://api.avangate.com";
$client = new SoapClient($host . "/soap/4.0/?wsdl", array(
'location' => $host . "/soap/4.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 = "YOURCODE123"; //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
$now = gmdate('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;
}
$PricingConfiguration = new stdClass();
$PricingConfiguration->Default = True;
$PricingConfiguration->Name = 'New Pricing Configuration Through API';
$PricingConfiguration->BillingCountries = array();
$PricingConfiguration->BillingCountries[0] = 'RO';
$PricingConfiguration->BillingCountries[1] = 'DE';
$PricingConfiguration->PricingSchema = 'DYNAMIC';
$PricingConfiguration->PriceType = 'NET';
$PricingConfiguration->DefaultCurrency = 'USD';
$PricingConfiguration->Prices = new stdClass();
$PricingConfiguration->Prices->Regular = array();
$PricingConfiguration->Prices->Regular[0] = new stdClass();
$PricingConfiguration->Prices->Regular[0]->Amount = 69.09;
$PricingConfiguration->Prices->Regular[0]->Currency = 'USD';
$PricingConfiguration->Prices->Regular[0]->MinQuantity = 1;
$PricingConfiguration->Prices->Regular[0]->MaxQuantity = 35;
$PricingConfiguration->Prices->Regular[0]->OptionCodes = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0] = new stdClass();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Code = 'G77ICHEM1C';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[0] = 'zh5onfolw7';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[0]->Options[1] = '75rjldfcnz';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1] = new stdClass();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Code = 'BAWAQB8LZP';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options = array();
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[0] = 'r3oi06opvi';
$PricingConfiguration->Prices->Regular[0]->OptionCodes[1]->Options[1] = '76gqbq4bhd';
$PricingConfiguration->Prices->Regular[1] = new stdClass();
$PricingConfiguration->Prices->Regular[1]->Amount = 64.66;
$PricingConfiguration->Prices->Regular[1]->Currency = 'USD';
$PricingConfiguration->Prices->Regular[1]->MinQuantity = 36;
$PricingConfiguration->Prices->Regular[1]->MaxQuantity = 83;
$PricingConfiguration->Prices->Regular[1]->OptionCodes = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0] = new stdClass();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Code = '8RNXV3T3RE';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[0] = 'rorqkqnd9p';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[0]->Options[1] = 'aeu89gqdg6';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1] = new stdClass();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Code = 'DJYD713MKC';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options = array();
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[0] = 'y2z2squ7c1';
$PricingConfiguration->Prices->Regular[1]->OptionCodes[1]->Options[1] = 'g74qfskbjg';
$PricingConfiguration->Prices->Renewal = array();
$PricingConfiguration->Prices->Renewal[0] = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->Amount = 7.89;
$PricingConfiguration->Prices->Renewal[0]->Currency = 'USD';
$PricingConfiguration->Prices->Renewal[0]->MinQuantity = 84;
$PricingConfiguration->Prices->Renewal[0]->MaxQuantity = 100;
$PricingConfiguration->Prices->Renewal[0]->OptionCodes = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0] = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Code = '73QCSXYH0E';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[0] = '54xu7mngqm';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[0]->Options[1] = 'p6m8im2unl';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1] = new stdClass();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Code = '0QD0CF0OIE';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options = array();
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[0] = 'ytbac9wpmh';
$PricingConfiguration->Prices->Renewal[0]->OptionCodes[1]->Options[1] = 'lpkxxqsqxb';
$PricingConfiguration->Prices->Renewal[1] = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->Amount = 76.99;
$PricingConfiguration->Prices->Renewal[1]->Currency = 'USD';
$PricingConfiguration->Prices->Renewal[1]->MinQuantity = 101;
$PricingConfiguration->Prices->Renewal[1]->MaxQuantity = 544;
$PricingConfiguration->Prices->Renewal[1]->OptionCodes = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0] = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Code = '03APF0H4QF';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[0] = '15ce5uw2j6';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[0]->Options[1] = 'e88d5hk0tb';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1] = new stdClass();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Code = 'PT00TYI2VY';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options = array();
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[0] = '10c24smlbl';
$PricingConfiguration->Prices->Renewal[1]->OptionCodes[1]->Options[1] = '0ondbwdk3q';
$PricingConfiguration->PriceOptions = array();
$PricingConfiguration->PriceOptions[0] = new stdClass();
$PricingConfiguration->PriceOptions[0]->Code = 'FKQ8CFLYKM';
$PricingConfiguration->PriceOptions[0]->Required = false;
$PricingConfiguration->PriceOptions[1] = new stdClass();
$PricingConfiguration->PriceOptions[1]->Code = 'TH1HKFOTFR';
$PricingConfiguration->PriceOptions[1]->Required = true;
$ProductCode = 'API_Imported_123456';
try {
$NewPricingConfiguration = $client->addPricingConfiguration($sessionID, $PricingConfiguration, $ProductCode);
}
catch (SoapFault $e) {
echo "NewPricingConfiguration: " . $e->getMessage();
exit;
}
var_dump("NewPricingConfiguration", $NewPricingConfiguration);
?>
Order field
Overview
Use this object to retrieve information about additional order/product fields.
Parameters
AdditionalField |
Object |
Label |
String |
|
Field text. |
Code |
String |
|
Field identifier. Alpha-numeric chars, underscores and dashes. |
Type |
String |
|
Field type:
|
ApplyTo |
Sting |
|
|
Values |
Array of values |
|
Custom values you control. |
ValidationRule |
String |
|
The validation rule restricting the type of information shoppers can enter in the additional field during the purchase process. |
Translations |
Array of objects |
|
Details below. |
Translation |
Object |
Label |
String |
|
Field text translated in the language of the Translations object. |
Values |
Object |
|
Custom values you control translated in the language of the Translations object. |
Language |
String |
|
ISO language code. (ISO 639-1 two-letter code). |
Create percentage discount
Request
<?php
class Client
{
protected static $merchantCode;
protected static $loginDate;
protected static $hash;
protected static $baseUrl;
protected static $callCount = 0;
protected static $sessionId = '';
protected static $client;
public static function setCredentials($code, $key)
{
static::$merchantCode = $code;
static::$loginDate = gmdate('Y-m-d H:i:s');
static::$hash = hash_hmac('md5', strlen($code) . $code . strlen(static::$loginDate) . static::$loginDate, $key);
static::$sessionId = static::login();
}
public static function setBaseUrl($url)
{
static::$baseUrl = $url;
}
public static function login()
{
$client = static::getClient();
return $client->login(static::$merchantCode, static::$loginDate, static::$hash);
}
public static function __callStatic($name, $arguments = array())
{
$client = static::getClient();
array_unshift($arguments, static::$sessionId);
$response = call_user_func_array(array($client, $name), $arguments);
return $response;
}
protected static function getClient()
{
$opts = array(
'http'=> ['user_agent' => 'PHPSoapClient'],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
);
if (null === static::$client) {
static::$client = new \SoapClient(static::$baseUrl . '?wsdl', [
'location' => static::$baseUrl,
'cache_wsdl' => WSDL_CACHE_NONE,
'stream_context' => stream_context_create($opts),
]);
}
return static::$client;
}
}
Client::setBaseUrl('https://api.avangate.com/soap/3.1/');
Client::setCredentials('YOUR_MERCHANT_CODE', 'YOUR_SECRET_KEY');
Client::login();
// create discount object
$discountObj = new stdClass;
$discountObj->Type = 'PERCENT';
$discountObj->Value = 30;
$promotionCode = 'YOUR_PROMO_CODE'; // code of the promotion that you want to update
$response = Client::setPromotionDiscount($promotionCode,$discountObj); // Set the promotion discount to the existing promotion
var_dump($response);
Instant Delivery Notification (IDN)
Overview
Use Instant Delivery Notifications (IDN) to automate the confirmation of order fulfillment/delivery to 2Checkout for products and subscriptions plans which you configured by opting for the Fulfillment made by you option. IDNs facilitate automatic delivery confirmations from your system directly into 2Checkout which logs them at the order level.
Availability
All 2Checkout accounts.
Workflow
- Shoppers purchase your products/subscription plans.
- 2Checkout handles the transaction, collects the payment, and generates Instant Payment Notifications (IPNs).
- 2Checkout stops processing the order reflected in the order status: in progress until you fulfill/deliver the purchase.
- Once you finalize fulfillment/delivery, you can confirm the action to 2Checkout either manually in the Control Panel or by creating a script that automatically sends a POST request to 2Checkout.
- 2Checkout provides an answer to your POST request either inline or using GET at a URL on your server where you can place a listener to interpret the result.
- 2Checkout finalizes order processing after receiving your fulfillment/delivery confirmation.
Requirements
- Authenticate for each request. Authenticate each HTTPS POST by using an HMAC_SHA256 signature based on the data contained in the POST and your account's merchant code and secret key.
- As soon as 2Checkout confirms your orders through IPN or via email, send standalone HTTPS POST requests to 2Checkout to the IDN URL for the orders you fulfill/deliver yourself, confirming the fact that shoppers received their product files/activation key/access to your service/etc. Include identification data for the order fulfillment/delivery you're confirming (read more below).
Method and URL
POST https://secure.2checkout.com/order/idn.php
POST Operation Data
The identification data contained in the POST is found in the following table and it is sent in the following exact order:
Parameter | Description |
---|---|
MERCHANT | Your merchant code. |
ORDER_REF | Unique, system-generated 2Checkout order reference. |
ORDER_AMOUNT | The total order value of the purchase for which you're confirming fulfillment/delivery. |
ORDER_CURRENCY | Order currency. |
IDN_DATE |
The date when you're sending the delivery confirmation request. Format: Y-m-d H:i:s Y - Represent the year. 4 digit number. M - Represents the month. 2 digit number. D - Represents the day. 2 digit number. H - Represents the hour. Values from 00 to 24. 2 digit number. I - Represents the minute. 2 digit number. S - Represents the second. 2 digit number. If you changed the time zone for the 2Checkout API by editing system settings under Account settings, then the IDN_DATE will be calculated according to your custom configuration. 2Checkout will use your custom set time zone for the IDN_DATE when calculating the HASH, and it's important that you also use the same datetime stamp, also per the custom time zone. The default 2Checkout API time zone is GMT+02:00. |
ORDER_HASH | Represents the request's signature, an HMAC_SHA256 built from all fields above. |
SIGNATURE_ALG | Required. The hashing algorithm used to authenticate the request. In order to use SHA2 or SHA3 for auth, simply pass SHA2 or SHA3 as value for the SIGNATURE_ALG parameter. |
REF_URL* | Optional. The get the 2Checkout response inline do not include this parameter in the POST or leave it empty. Otherwise, populate it with the URL address where you placed a listener on your server capable of interpreting the 2Checkout respponse delivered using GET. The URL address must begin with the http:// or https://. |
LICENSE_CODE |
OPTIONAL - the 2Checkout License Reference - the unique identifier for a license/subscription (maximum 50 characters) in the 2Checkout system. Can be used to confirm fulfillment/delivery only for partner orders. Send the 2Checkout License Reference string for which you're confirming fulfillment/delivery. The confirmation of the fulfillment/delivery of partner orders can be done one subscription at a time. Note: If used, LICENSE_CODE is also included when the HASH signature is calculated. Not available for eStore. |
ORDER_HASH example
Field Name | Length | Field Value |
---|---|---|
MERCHANT | 4 | Test |
ORDER_REF | 7 | 1000500 |
ORDER_AMOUNT | 6 | 225000 |
ORDER_CURRENCY | 3 | ROL |
IDN_DATE | 19 | 2004-12-16 17:46:56 |
Secret key for this example | AABBCCDDEEFF | |
The source string for the MAC calculation is given by adding the string length at the beginning of the field: | 4TEST7100050062250003ROL192004-12-16 17:46:56 | |
Final SHA256 value | 3d37f0d7819dbde48ff4c8910bb153ec |
Response example
2Checkout calculates the response for the data in the ORDER_HASH example similarly but with less information. The source string data:
Filed Name | Length | Field Value |
---|---|---|
ORDER_REF | 7 | 1000500 |
RESPONSE_CODE | 1 | 1 |
RESPONSE_MSG | 9 | Confirmed |
IDN_DATE | 19 | 2004-12-16 17:46:58 |
Resulting string | 71000500119Confirmed192004-12-16 17:46:58 | |
Resulting SHA256 HASH value | d317bb75d8f1d7fd203314914621c17c |
The HASH fields can contain both lowercase and uppercase characters. (hexadecimal string)
The INLINE reply from the 2Checkout server:
<EPAYMENT>1000500|1|Confirmed|2004-12-16 17:46:58|d317bb75d8f1d7fd203314914621c17c</EPAYMENT>
The GET reply:
https://www.mysite.com/prel.php?ORDER...NSE_CODE=1&RESPONSE_MSG=Confirmed&IDN_DATE=2004-12-16 17:46:58&ORDER_HASH=d317bb75d8f1d7fd203314914621c17c
IDN Response Codes and Messages
2Checkout does not log orders as confirmed when you receive an invalid reply.
Response code | Response message |
---|---|
1 | Confirmed |
2 | ORDER_REF missing or incorrect |
3 | ORDER_AMOUNT missing or incorrect |
4 | ORDER_CURRENCY is missing or incorrect |
5 | IDN_DATE is not in the correct format |
6 | Error confirming order |
7 | Order already confirmed |
8 | Unknown error |
9 | Invalid ORDER_REF |
10 | Invalid ORDER_AMOUNT |
11 | Invalid ORDER_CURRENCY |
Working example
<?php
$algo = 'sha256'; // or sha3-256
$merchantCode = 'merchant';
$key = "secret_key";
$orderref = 1234567;
$date = date('Y-m-d H:i:s');
$eur = 'EUR';
$amount = 99.99;
$string = strlen($merchantCode) . $merchantCode . strlen($orderref) . $orderref . strlen($amount) . $amount . strlen(
$eur
) . $eur . strlen($date) . $date;
$hash = hash_hmac($algo, $string, $key);
$idn = array(
'MERCHANT' => $merchantCode,
'ORDER_REF' => $orderref,
'ORDER_AMOUNT' => $amount,
'ORDER_CURRENCY' => $eur,
'SIGNATURE_ALG' => $algo,
'IDN_DATE' => date('Y-m-d H:i:s')
);
$idn['ORDER_HASH'] = $hash;
$dataels = array();
foreach (array_keys($idn) as $thiskey) {
$dataels[] = urlencode($thiskey) . "=" . urlencode($idn[$thiskey]);
}
$data = implode("&", $dataels);
var_dump($data);
$connectionToUrl = curl_init();
curl_setopt($connectionToUrl, CURLOPT_URL, "https://secure.2checkout.com/order/idn.php");
curl_setopt($connectionToUrl, CURLOPT_HEADER, false);
curl_setopt($connectionToUrl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($connectionToUrl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($connectionToUrl, CURLOPT_SSLVERSION, 0);
curl_setopt($connectionToUrl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connectionToUrl, CURLOPT_VERBOSE, 0);
curl_setopt($connectionToUrl, CURLOPT_POST, 1);
curl_setopt($connectionToUrl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($connectionToUrl, CURLOPT_POSTFIELDS, $data);
$returnConnectionPost = curl_exec($connectionToUrl);
curl_close($connectionToUrl);
var_dump($returnConnectionPost);
Delete SKU codes by details
Overview
Use the deleteSkuCodeByDetails method to remove an SKU based on its included details.
When requesting to delete SKU by details, the 2Checkout system will delete all SKU defined under the specific product code or pricing configuration code. If the combination does not contain any SKU defined, the system will return an error with the result. The method supports multiple combinations of product code, pricing configuration code in one call.
Request Parameters
Parameters | Required | Type/Description |
---|---|---|
ProductCode | Required | String. The product code that you can define for each of your offerings. Needs to be unique. |
skuDetailsObject |
Object Details below. |
|
PricingConfigurationCode |
Optional |
String. Unique identifier of the pricing configuration. |
Currency |
Optional |
String. ISO currency code. |
PurchaseType |
Optional |
String. Purchase type identifier. Possible values:
|
PriceOptions | Optional |
stringArray. Array of price options names. |
Quantity |
Optional | Integer. Numeric identifier of product quantity. |
Request Example
Response Parameters
Parameters | Type/Description |
---|---|
Response Example
Subscription
Overview
Retrieve information and manage subscriptions for your account.
Subscriptions can be retrieved starting with 5 minutes after their orders are generated in the 2Checkout system.
Parameters
Parameters |
Type/Description |
|||
---|---|---|---|---|
SubscriptionReference |
String |
|||
|
Unique, system-generated subscription identifier. |
|||
StartDate |
String |
|||
|
Subscription start date(YYYY-MM-DD) - StartDate is mandatory when importing subscription data. If you changed the time zone for the Avangate 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 Avangate API by editing system settings under Account settings, then the ExpirationDate you provide must be in accordance with your custom configuration. |
|||
RecurringEnabled |
Boolean |
|||
|
Possible values: TRUE – recurring billing/automatic subscription renewals enabled FALSE– recurring billing/automatic subscription renewals disabled |
|||
SubscriptionEnabled |
Boolean Possible values: TRUE –subscription enabled FALSE–subscription disabled |
|||
Product |
Required (object) |
|||
|
The product for which Avangate generated the subscription. Details below. |
|||
|
ProductCode |
String |
||
|
|
Unique product identifier that you control. |
||
|
ProductId |
Int |
||
|
|
Unique, system-generated product identifier. |
||
|
ProductName |
String |
||
|
|
Product name. |
||
|
ProductQuantity |
Int |
||
|
|
Ordered number of units. |
||
|
ProductVersion |
String |
||
|
|
Product version. |
||
|
PriceOptionCodes |
Array |
||
|
|
The product options codes the customer selected when acquiring the subscription. Pricing options codes are case sensitive. |
||
Object |
||||
|
The end user of the subscription. Details below. |
|||
|
Person |
Object |
||
|
|
FirstName |
String |
|
|
|
|
End user's first name |
|
|
|
LastName |
String |
|
|
|
|
End user's last name |
|
|
|
CountryCode |
String |
|
|
|
|
End user country code [ISO3166-1 Alpha 2]. |
|
|
|
State |
String |
|
|
|
|
End user state. |
|
|
|
City |
String |
|
|
|
|
End user city. |
|
|
|
Address1 |
String |
|
|
|
|
End user first address line. |
|
|
|
Address2 |
String |
|
|
|
|
End user second address line. |
|
|
|
Zip |
String |
|
|
|
|
End user zip code. |
|
|
|
|
String |
|
|
|
|
End user email address. |
|
|
|
Phone |
String |
|
|
|
|
End user phone number. |
|
|
|
Company |
String |
|
|
|
|
Company name. |
|
|
Fax |
String |
||
|
|
End user fax. |
||
|
Language |
String |
||
|
|
Language [ISO639-2] the Avangate system uses for communications. |
||
SKU |
String |
|||
|
Stock keeping unit you defined. |
|||
Object |
||||
|
The object contains information about the delivery/fulfillment made to the customer. |
|||
|
Description |
String |
||
|
|
Delivery description. |
||
|
Codes |
Array of objects |
||
|
|
Code |
String |
|
|
|
|
Activation key/license code of the first order from this subscription. Use getSubscriptionHistory method if you want to retrieve the activation keys/license codes for all orders belonging to a subscription. |
|
|
|
Description |
String |
|
|
|
|
Code description for dynamic lists from your key generator. |
|
|
|
ExtraInfo |
Object |
|
|
|
|
Info set by your key generator for dynamic lists only. |
|
|
|
|
CodeExtraInfo |
Object |
|
|
|
Type |
String |
|
|
|
Label |
String |
|
|
|
Value |
String |
|
|
File |
Array of objects |
|
|
|
|
Content |
String |
|
|
|
|
Content of the file (base64 encoded). |
|
|
|
ContentLength |
Int |
|
|
|
|
File size. |
|
|
|
Filename |
String |
|
|
|
|
The name of the delivered file. |
|
|
|
FileType |
String |
|
|
|
|
The type of the delivered file. |
ReceiveNotifications |
Boolean |
|||
|
1 – Subscribe: Avangate sends subscription notifications to the end user. 0 – Unsubscribe – Avangate does not send subscription notifications to the end user. |
|||
Lifetime |
Boolean |
|||
|
Possible values:
False – the subscription has a recurring billing cycle less than or equal to three years. |
|||
PartnerCode |
String |
|||
|
Partner Code |
|||
AvangateCustomerReference |
Int |
|||
|
Unique, system-generated customer identifier. |
|||
ExternalCustomerReference |
String |
|||
|
Customer identifier that you control. |
|||
TestSubscription |
Boolean |
|||
|
True for test subscriptions, false otherwise. |
|||
IsTrial |
Boolean |
|||
|
True for trial subscriptions, false otherwise. |
Enable a subscription
Overview
Use the enableSubscription method to enable a subscription.
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. |
subscriptionReference |
Required (string) |
Unique, system-generated subscription identifier. |
Response
Parameters | Type/Description |
---|---|
Boolean |
true or false depending on whether the changes were successful or not. |
Request
<?php
require ('PATH_TO_AUTH');
$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$jsonRpcRequest = array (
'method' => 'enableSubscription',
'params' => array($sessionID, $subscriptionReference),
'id' => $i++,
'jsonrpc' => '2.0');
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));