Customer
Attributes
|
Parameters |
Type/Description |
|||
|---|---|---|---|---|
|
CustomerDetails |
Object |
|||
|
|
AvangateCustomerReference |
Optional (Int) |
||
|
|
|
System-generated Avangate customer reference.
null when you create a new customer. The Avangate system generates default customer numerical (integer) IDs (AV_CUSTOMERID) automatically for all orders containing products that feature subscriptions.
Aggregate subscriptions under the same Customer account by adding the AV_CUSTOMERID (case sensitive) parameter to Buy links. |
||
|
|
ExternalCustomerReference |
Optional (string) |
||
|
|
|
Unique customer alphanumeric (string) identifiers you control. Aggregate subscriptions under the same Customer account by adding the CUSTOMERID (case sensitive) parameter to Buy links. |
||
|
|
FirstName |
Required (string) |
||
|
|
|
Customer's first name. |
||
|
|
LastName |
Required (string) |
||
|
|
|
Customer's last name. |
||
|
|
Company |
Optional (string) |
||
|
|
|
Company name. |
||
|
|
FiscalCode |
Optional (string) |
||
|
|
|
Can be null for end users. For companies, it needs to be the VAT ID, which Avangate validates. Avangate throws an error if the VAT ID is invalid/incorrect. When present, you also need to provide the company name.
Can be null for end users. |
||
|
|
Address1 |
Required (string) |
||
|
|
|
Customer's address. |
||
|
|
Address2 |
Optional (string) |
||
|
|
|
Customer's address. |
||
|
|
City |
Required (string) |
||
|
|
|
Customer's city. |
||
|
|
State |
Optional (string) |
||
|
|
|
Customer's state. For example, "Alabama","Alaska","Arizona". |
||
|
|
Zip |
Required (string) |
||
|
|
|
Zip code. |
||
|
|
CountryCode |
Required (string) |
||
|
|
|
Customer's country code (ISO 3166 two-letter code). |
||
|
|
Phone |
Optional (string) |
||
|
|
|
Customer's phone number. |
||
|
|
Fax |
Optional (string) |
||
|
|
|
Customer's fax number. |
||
|
|
|
Required (string) |
||
|
|
|
Customer's email. |
||
|
|
ExistingCards |
Optional (Array of objects) |
||
|
|
|
|
||
|
|
|
TransientToken |
Optional (Object) |
|
|
|
|
|
Populated only with when you retrieve customer information by SSOToken. |
|
|
|
|
|
Token |
Optional (string) |
|
|
|
|
|
Token for the EXISTING_PAYMENT_DATA flow. Use it to charge customers using cards they used in the past for purchases from your Avangate account. |
|
|
|
CardType |
Optional (string) |
|
|
|
|
|
visa, visaelectron, mastercard, maestro, amex, discover, dankort, cartebleue, jcb |
|
|
|
|
LastDigits |
Optional (string) |
|
|
|
|
|
Last four digits of the credit card. |
|
|
|
|
ExpirationMonth |
Optional (string) |
|
|
|
|
|
Card expiration month. |
|
|
|
|
ExpirationYear |
Optional (string) |
|
|
|
|
|
Card expiration year. |
|
|
|
|
NameOnCard |
Optional (string) |
|
|
|
|
|
Card holder name. |
|
|
|
Enabled |
Optional (boolean) |
||
|
|
|
true or false, depending on whether the customer account is active or inactive. An active customer account features at least one Active or Past due subscription. Possible customer statuses:
|
||
|
|
Trial |
Optional (boolean) |
||
|
|
|
true or false, depending on whether the customer account features only trials or also paid subscriptions. |
||
|
|
Language |
Optional (string) |
||
|
|
|
ISO 639-1 two-letter code. Example: “en.” |
||
Assign a product group
Overview
Use the assignProductGroup method to assign a product to a product group. Following the assignation, the 2Checkout system uses the shopping cart template associated with the product group as the default cart design when shoppers purchase a subscription plan/product.
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. |
|
productCode |
Required (string) |
|
|
The code of the product you wish assigned to the group. |
| groupCode | Required (string) |
| Unique, system-generated identifier assigned to product groups. |
Response
bool(true)
Request
<?php
require ('PATH_TO_AUTH');
$productCode = "YOUR_PRODUCT_CODE";
$groupCode = "YOUR_PRODUCT_GROUP_CODE";
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'assignProductGroup',
'params' => array($sessionID, $productCode,$groupCode)
);
var_dump (callRPC($jsonRpcRequest, $host));
?>
Update a product group
Overview
Use the updateProductGroup method to create a new product group for your account.
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) |
|
|
|
Use this object to update product groups. |
Response
bool(true)
Request
<?php
require ('PATH_TO_AUTH');
$ProductGroup = new stdClass();
$ProductGroup->Name = 'New Product Group from API';
$ProductGroup->Code = 'DBA13A4268';
$ProductGroup->TemplateName = 'Default Template'; // the name of the cart template you want to associate with the product group
$ProductGroup->Description = 'This is a generic description';
$ProductGroup->Enabled = false;
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'updateProductGroup',
'params' => array($sessionID, $ProductGroup)
);
var_dump (callRPC($jsonRpcRequest, $host));One click (1-click) purchase
Overview
2Checkout supports 1-click purchases for returning customers who paid for their previous orders with:
- Credit/Debit cards
- PayPal
- iDEAL
- Alipay
- UnionPay
How does this work?
- Identify returning customers.
- Access data on the previous purchases of returning customers.
- Validate previous order references for 1-click purchase scenarios using the isValidOrderReference method (explained below).
- Place a new order using a valid previous order reference as the payment method.
- 2Checkout charges returning customers using their payment-on-file information, either a card or their PayPal account.
Requirements
- Use only references to previous orders with one of the following statuses AUTHRECEIVED or COMPLETE.
-
The email address of the BillingDetails object is mandatory and it needs to match the email address used as a part of the billing details of the initial order whose reference you're now using to place a new order. 2Checkout checks whether the email addresses are identical, and throws an error if they're not, blocking the order placement process.
You have the possibility of providing only the email address of the shopper, and can ignore the rest of the required customer billing information. This way the rest of the billing information will be pre-filled from the order used as payment reference. If you enter any billing details in addition to the email address, you'll have to provide all information required in the BillingDetails object. - For orders paid with PayPal, the original order must have automatic renewal enabled so that it can be reused for future 1-click purchases.
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. |
Response
| Parameters | Type/Description |
|---|---|
| Order information | Object |
| Object containing order information. |
Validate previous order reference
<?php
require('PATH_TO_AUTH');
$orderReference = '670174996';
$jsonRpcRequest = array (
'method' => 'isValidOrderReference',
'params' => array($sessionID, $orderReference),
'id' => $i++,
'jsonrpc' => '2.0'
);
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));
$jsonRpcRequest = array (
'method' => 'getOrder',
'params' => array($sessionID, $orderReference),
'id' => $i++,
'jsonrpc' => '2.0'
);
Place an order using previous order reference
<?php
require('PATH_TO_AUTH');
$oldOrderExistent = callRPC((Object)$jsonRpcRequest, $host, true);
$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'usd';
$Order->Country = 'US';
$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->BillingDetails = new stdClass();
$Order->BillingDetails->Email = $oldOrderExistent->BillingDetails->Email;;
$Order->DeliveryDetails = NULL;
$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'PREVIOUS_ORDER';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '10.10.10.10';
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->RefNo = $orderReference;
$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'
);
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));
Retrieve product price
Overview
Get the price for a product in a new purchase scenario, based on the product ID, the pricing list it's assigned to and specific pricing options.
Requirements
Parameters
| Parameter | Type/Description |
|---|---|
| sessionID | Required (string) |
| Session identifier, which is the output of the Login method. An exception will be thrown if the values are incorrect. | |
| productId | Required (string) |
| The unique identifier of the product from your system. | |
| pricingListCode | Required (string) |
| The unique identifier of the pricing list. | |
| priceOptions | Optional (StringArray) |
| Array of pricing option codes. These identifiers mark the individual options inside pricing options configuration groups. Can be NULL. |
Response
| Parameter | Type/Description |
|---|---|
| UnitPrice | Object |
| UnitPrice object. |
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';
$priceOptions = array(
'Pricing_options_group_code1',
'Pricing_options_group_code2'
);
try {
$ProdPrice= $client->getProductPrice($sessionID, $productId, $pricingListCode, $priceOptions);
} catch (SoapFault $e) {
echo "ProductUnitPrice: " . $e->getMessage();
exit;
}
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 provided ID in the given pricing list. |
Search shipping methods
Overview
Use searchShippingMethods to retrieve information on the shipping methods currently defined on your account.
Search filters
Use the parameters below to filter the results of your search for shipping methods.
| Parameter | Type/Description | |
|---|---|---|
| Name |
String / Optional Name of the shipping method. |
|
| Codes |
Array of strings / Optional Codes assigned to the shipping methods. |
|
| Countries |
Array of strings / Optional Countries to which the shipping method is assigned. |
|
| Active |
Boolean / Optional TRUE - active shipping methods FALSE - inactive shipping methods |
|
| Pagination |
Object / Optional Control the results pagination. |
|
| Page |
Integer / Optional Number of pages to display the results |
|
| Limit |
Integer / Optional Limit the number of results of the search |
|
Sample request
<?php
require ('PATH_TO_AUTH'); // authentication call
$SearchOptions = new \stdClass();
$SearchOptions->Name = 'ShippingMethodName'; // search for a specific shipping method
$SearchOptions->Codes = ['Code1', 'Code2', 'Code3']; // array of shipping method codes
$SearchOptions->Countries = ['US', 'UK', 'AU']; // array of country codes
$SearchOptions->Active = true; // only active shipping methods
$SearchOptions->Pagination = new \stdClass();
$SearchOptions->Pagination->Page = 1; // set display pages
$SearchOptions->Pagination->Limit = 200; // limit the results
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'searchShippingMethods',
'params' => array($sessionID, $SearchOptions)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
Response
| Parameter | Type/Description |
|---|---|
| ShippingMethod |
Object |
Retrieve shipping price
Overview
Use getShippingPrice to retrieve the shipping method and price available, based on a current cart configuration. This API call returns the available shipping methods defined in your Control Panel, together with the fees you configured based on order total amount/weight/country.
Requirements
It's mandatory to have tangible products defined in your Control Panel, to retrieve shipping method and price information.
Parameters
| Parameters | Type/Description | |
|---|---|---|
| Items |
Object / Required Contains information on the tangible product added in cart. |
|
| Code |
String / Required Product code defined in the Information tab from the Product level, in the Control Panel. |
|
| Quantity |
Integer / Optional Quantity of the product that is being purchased. Default value is 1. |
|
| BillingDetails |
Object / Required Contains customer billing information. |
|
| CountryCode |
String / Required Two-digits code of customer billing country. Example: 'US'. |
|
| DeliveryDetails |
Object / Required Contains customer delivery information. |
|
| CountryCode |
String / Required Two-digits code of customer delivery country. Example: 'US'. |
|
| Currency |
String / Optional Three-digits code of purchase currency. Example: 'USD'. |
|
| CouponCodes |
Array of strings / Optional Discount codes that can be applied to the purchase. |
|
Sample request
<?php
require ('PATH_TO_AUTH'); // authentication call
$cartItems = [];
$cartItem = new stdClass();
$cartItem->Code = 'my_product_code_1'; // product code defined in the Information tab, at product level
$cartItem->Quantity = 2; // quantity that is being purchased
$cartItems[0] = $cartItem;
$billingDetails = new stdClass();
$billingDetails->CountryCode = 'US'; // billing country
$deliveryDetails = new stdClass();
$deliveryDetails->CountryCode = 'AU'; // delivery country
$currency = 'USD'; // purchase currency
$couponCode = ['TANGIBLEPROMO']; // apply discount to promotion
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getShippingPrice';
$jsonRpcRequest->params = array($sessionID, $cartItems, $billingDetails, $deliveryDetails, $currency);
$jsonRpcRequest->id = $i++;
$getShippingPrice = callRPC($jsonRpcRequest, $host);
Response
| Parameters | Type/Description |
|---|---|
| ShippingPrice |
Object This method returns an object, containing the shipping price available for a certain cart configuration. |
Add/edit cross-sell texts
Overview
Use the addCrossSellCampaignText method to customize the texts that are shown in the shopping cart when a cross-sell campaign is displayed.
Editing a text can be done via the updateCrossSellCampaignText method with the same payload. If during a call to updateCrossSellCampaignText method, a text is not found in the database, it will be added automatically.
Request parameters
|
Parameters |
Type |
Required |
Description |
|---|---|---|---|
|
language |
String |
Required |
The ISO 639-1 two-letter code of the language; Can be Arabic, Bulgarian, Chinese, Chinese (traditional), Czech, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Korean, Norwegian, Persian, Polish, Portuguese, Portuguese (Brazil), Slovak, Slovenian, Spanish, Swedish, Thai, Romanian, Russian |
|
title |
String |
Required |
The title of the cross sell campaign as it is displayed in the cart |
|
description |
String |
Required |
The description of the cross sell campaign as it is displayed in the cart |
Response
Both the addCrossSellCampaignText and updateCrossSellCampaignText methods will return the full list of texts available in the platform.
Request sample
<?php
require ('PATH_TO_AUTH');
$csCampaignText = [];
$textObj = new stdClass();
$textObj->Language = "ro";
$textObj->Title = "Numele campaniei mele";
$textObj->Description = "Descrierea campaniei mele";
$csCampaignText[] = $textObj;
$textObj = new stdClass();
$textObj->Language = "en";
$textObj->Title = "My campaign name";
$textObj->Description = "My campaign description";
$csCampaignText[] = $textObj;
try {
$csCampaignTextResponse = $client->addCrossSellCampaignText($sessionID, $csCampaignText);
} catch (SoapFault $e) {
echo $e->getMessage();
}
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.
Object 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. |
||
|
EndUser |
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. |
|||
|
DeliveryInfo |
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. |
|||
| MerchantCode | String | |||
| Unique, system-generated ID in the Avangate system. | ||||