Convert a trial
Overview
Use the convertTrial method to convert a trial to a paid subscription. In the eventuality of a conversion failure, you can use convertTrial again for the same trial subscription only after you let 24 hours pass since the initial attempt. The 2Checkout system attempts to automatically convert trials before they expire to full subscriptions unless you made an attempt that failed less than 24 hours before the scheduled expiration deadline.
In case the trial conversion fails due to a transaction issue, the 2Checkout system sends unfinished payment follow-up emails to customers, provided that you set up lead management for your account.
Parameters
Parameters | Type/Description |
---|---|
SubscriptionReference |
Required (string) |
Unique, system-generated subscription identifier of the trial that you convert to a paid subscription. The unique identifier from the 2Checkout system:
Note: This method does not work for canceled and/or expired trial subscriptions.
2Checkout charges customers using the payment data attached to the trial subscription. In the case of credit/debit cards, if customers update their payment information in myAccount or if you update these details on behalf of your subscribers, the 2Checkout system uses the latest card info provided to charge subscription renewals. |
|
ExtendSubscriptionFromPaymentDate |
Optional (boolean) |
|
true = Set the moment of the conversion as the start date of the full subscription. Example: A 7-day trial purchased on October 29 for a monthly subscription converted on October 30 with $ExtendSubscriptionFromPaymentDate = true; features the following Billing cycle expiration: Nov 30, 2013, and 2Checkout scraps the initial trial expiration date November 5.
false = Set initial trial expiration deadline as the full subscription start date. Example: A 10-day trial purchased on October 29 for a monthly subscription converted on October 30 with $ExtendSubscriptionFromPaymentDate = false; features the following Billing cycle expiration: December 9, with the first month period of the subscription added to the trial lifetime stretching until November 8.
Can be NULL. If not sent, the default value is false. |
Response
Parameters | Type/Description |
---|---|
Boolean |
true or false depending on whether the changes were successful or not. |
Request
<?php
require ('PATH_TO_AUTH');
$SubscriptionReference = 'BF44555C6C';
$ExtendSubscriptionFromPaymentDate = true; //false can also be used if you want the subscription start date to be the moment when the trial was set to initially expire.
$jsonRpcRequest = array (
'method' => 'convertTrial',
'params' => array($sessionID, $SubscriptionReference, $ExtendSubscriptionFromPaymentDate),
'id' => $i++,
'jsonrpc' => '2.0');
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));
Retrieve SKU details
Overview
Use the getSkuDetails method to retrieve SKU details based on its ID.
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. | |
skuCode | Required (string) |
Unique identifier of the SKU. |
Response
{
"PricingConfigurationCode":"{PricingConfigurationCode}",
"ProductCode":"{ProductCode}",
"Currency":"{Currency}",
"PriceOptions":[{PriceOption1},{PriceOption2}],
"PurchaseType":"{PurchaseType}",
"FromQuantity":"{FromQuantity}",
"ToQuantity":"{ToQuantity}"
}
Request
<?php
require ('PATH_TO_AUTH');
$sku = 'YOUR_SKU_CODE';
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getSKUDetails';
$jsonRpcRequest->params = array($sessionID, $sku);
$jsonRpcRequest->id = $i++;
$getOrder = callRPC($jsonRpcRequest, $host);
var_dump($getOrder);
Order session content object
Overview
Use this object to retrieve session content and to guide shoppers through advanced payment flows, such as those of PayPal, PayPal Express, Wire, Check, etc.
Attributes
Order session contents |
Type/Description |
||||
---|---|---|---|---|---|
Errors |
Optional (StringArray) |
||||
|
Payment gateway processing errors. |
||||
Items |
Array of objects |
||||
Details below. | |||||
|
ProductDetails |
Object |
|||
Details below. | |||||
|
|
Name |
Optional (string) |
||
|
|
|
Product name. |
||
|
|
ExtraInfo |
Optional (string) |
||
|
|
|
The text entered in the Additional information field when generating Buy links, or via the INFO[PRODUCT_ID] parameter used in Buy links. |
||
|
|
RenewalStatus |
Optional (boolean) |
||
|
|
|
|
||
|
|
Subscriptions |
Object |
||
Details below. | |||||
|
|
|
SubscriptionReference |
Optional (string) |
|
|
|
|
|
Unique, system-generated subscription identifier. |
|
|
|
|
PurchaseDate |
Optional (string) |
|
|
|
|
|
The date time stamp when shoppers acquired their subscriptions corresponding to the moment when the Avangate system marks the purchase as finished. Format (YYYY-MM-DD HH:mm:ss). Default GMT+02:00.
e.g. 2015-08-11 15:18:52 |
|
|
|
|
SubscriptionStartDate |
Optional (string) |
|
|
|
|
|
Example: 2015-09-29 17:57:59 |
|
|
|
|
ExpirationDate |
Optional (string) |
|
|
|
|
|
The date time stamp of upcoming renewal/expiration for subscriptions not taking into account grace period settings.
Format (YYYY-MM-DD HH:mm:ss). Default GMT+02:00.
e.g. 2015-09-11 15:18:52 |
|
|
|
|
Lifetime |
Optional (boolean) |
|
|
|
|
|
|
|
|
|
|
Trial |
Optional (boolean) |
|
|
|
|
|
|
|
|
|
|
Enabled |
Optional (boolean) |
|
|
|
|
|
|
|
|
|
|
RecurringEnabled |
Optional (boolean) |
|
|
|
|
|
|
|
|
PriceOptions |
Optional (Array of strings) |
|||
|
|
Product price options. |
|||
|
Price |
Object |
|||
|
|
This object returns the price per unit at order line level.
In the case of trials, the object returns the costs for the trial to full subscription conversion. |
|||
|
|
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 Avangate 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, Avangate and affiliate commissions, but Avangate deducts the value of any discounts. |
||
|
|
UnitAffiliateCommission |
Optional (double) |
||
|
|
|
Value of the affiliate commission per product unit calculated expressed in the payment currency.
Avangate deducts discounts from the costs incurred by shoppers before calculating affiliate commissions.
Avangate does not take into account shipping costs when calculating affiliate commissions.
NULL when Avangate does not apply an affiliate commission. |
||
|
|
Currency |
Optional (string) |
||
|
|
|
The currency ISO code for the payment - ISO 4217. Example: usd. |
||
|
|
NetPrice |
Optional (double) |
||
|
|
|
The value per order line, excluding sales tax/VAT expressed in the payment currency. |
||
|
|
GrossPrice |
Optional (double) |
||
|
|
|
Total value per order line, including sales tax/VAT expressed in the payment currency. UnitGrossPrice does not reflect any discounts. |
||
|
|
NetDiscountedPrice |
Optional (double) |
||
|
|
|
The NetPrice value per order line, excluding sales tax/VAT, from which Avangate deducts discounts. NetDiscountedPrice is expressed in the payment currency. |
||
|
|
GrossDiscountedPrice |
Optional (double) |
||
|
|
|
Total costs shoppers incur per order line, expressed in the payment currency. This value includes sales tax/VAT, Avangate and affiliate commissions, but Avangate deducts the value of any discounts.
Example:
|
||
|
|
Discount |
Optional (double) |
||
|
|
|
Value of the discounts per order line expressed in the payment currency. |
||
|
|
VAT |
Optional (double) |
||
|
|
|
Value of sales tax/VAT per order line expressed in the payment currency. |
||
|
|
AffiliateCommission |
Optional (double) |
||
|
|
|
Value of the affiliate commission per order line, calculated from the NetDiscountedPrice expressed in the payment currency. Or NULL. Avangate does not take into account shipping costs when calculating affiliate commissions. |
||
|
Code |
Optional (string) |
|||
|
|
Unique product identifier your control. Max length 256 characters. |
|||
|
Quantity |
Optional (integer) |
|||
|
|
Number of units |
|||
|
SKU |
Optional (string) |
|||
|
|
SKU identifier. |
|||
|
CrossSell |
Optional (Object) |
|||
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) |
|||
Details below. | |||||
|
|
Period |
Optional (integer) |
||
|
|
|
The length of the trial subscription lifetime in days. |
||
|
|
GrossPrice |
Optional (double) |
||
|
|
|
Total trial price in the payment currency before Avangate deducts any taxes, discounts, etc. |
||
|
|
VAT |
Optional (double) |
||
|
|
|
The total value of taxes for the trial in the payment currency, before Avangate deducts any discounts. |
||
|
|
NetPrice |
Optional (double) |
||
|
|
|
Total trial price in the payment currency, not including taxes, before Avangate deducts any discounts. |
||
|
AdditionalFields |
Optional (array of objects) |
|||
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. |
||
|
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) |
||
|
|
|
Avangate 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) |
||
|
|
|
|
||
Promotions |
Optional (Array of objects) |
||||
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) |
|||
|
|
Avangate 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 specific number of units purchased at once, smaller than the maximum 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 payment currency. |
|||
|
Enabled |
Optional (string) |
|||
|
|
true or false, depending on whether a promotion is active or disabled. |
|||
|
Type |
Optional (string) |
|||
|
|
|
|||
AdditionalFields |
Optional (array of objects) |
||||
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. |
|||
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 Avangate 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, Avangate and affiliate commissions, but Avangate deducts the value of any discounts.
For example:
|
||||
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. Avangate does not take into account shipping costs when calculating affiliate commissions. |
Set a redirect URL for default checkout flows
Overview
2Checkout supports the seamless transition of shoppers to a web page of your choosing following order completion. Shopper redirect will only happen after the order is placed successfully.
Availability
All 2Checkout accounts.
Analytics tracking
2Checkout bypasses the Thank You page (finish.php) completely and no longer displays it to shoppers. If you use analytics code in finish.php be aware that it will no longer collect data.
AfterSale Messages
Please note that setting up a Redirect URL and effectively redirecting shoppers to a different webpage after they place an order cancels any AfterSale Messages that you might have set up. 2Checkout displays AfterSale Messages in the Thank You page, at the end of the purchase process, but the Redirect URL causes the process to bypass the Thank You page and sends shoppers directly to the web page of your choosing.
Instant Delivery in finish.php
By redirecting shoppers to a different webpage after they place an order effectively cancels Instant delivery (in the Thank you page).
Instant delivery takes place in the Thank you page, at the end of the purchase process, but Redirect URL causes the process to bypass the Thank You page altogether, and sends shoppers directly to the web page of your choosing.
Shopper redirects
2Checkout always redirects shoppers:
- If they use an instantaneous payment method (including when they purchase paid trials).
- When payment is not required (order value is 0).
2Checkout does not redirect shoppers when they:
- Use an offline payment method such as bank/wire transfer.
- When they order free trials.
Configure the Redirect URL
To configure the Redirect URL, make your way to the Setup area of the Control Panel.
- Click Generate Links under Setup, and select the Default flows tab. Alternatively, you can also hit the Get buy links for this product link under the Information tab, just to the right of the Product ID, when editing a product.
- Scroll down to the Advanced Options section and locate the Redirect URL field from the Additional options area. Enter the URL for the destination to which shoppers will be redirected once they finalize payments for orders they place through the 2Checkout system.
-
Once you have entered all the desired details, scroll down to the bottom of the page and click the Generate link button. The Buy Link created will contain a &BACK_REF parameter just as in the example below. The URL following the &BACK_REF parameter is the same as the one entered under the Redirect URL field.
https://secure.2checkout.com/order/checkout.php?PRODS=1234567&BACK_REF=http%3A//www.YourCustomRedirectURL.com
While you can use the Control Panel to ease the introduction of the Redirect URL into Buy Links for your products, you can also enter it manually. Just introduce &BACK_REF= http%3A//www.YourCustomRedirectURL.com into the Buy Link and replace YourCustomRedirectURL with the actual name of the custom web page where shoppers will be redirected.
When using a Redirect URL, the domain/subdomain must be whitelisted beforehand in Control Panel. To do so, go to Setup > Ordering options > Redirect domains. If the URLs' domain/subdomain is not whitelisted the shopper will be redirected to the default Thank you page.
The domain validation will be available starting with 30th of July. Until that date we will whitelist the needed domains based on historical data.
Optional
In order to increase security and avoid BACK_REF tampering from 3rd party entities (security breaches), we added the possibility to include the parameter SECURE_CART.
In order to obtain a more secure and hashed URL, the SECURE_CART parameter must be used and set to value ‘1’ ( SECURE_CART=1) along with the hashed value of the BACK_REF parameter, according to this documentation.
The new URL might look like:
https://secure.2checkout.com/order/checkout.php?PRODS=1234567&BACK_REF=http%3A//www.YourCustomRedirectURL.com &SECURE_CART=1&PHASH=0d5e3ecfe95fd6560e117d1f18b7e7ea
- The 2Checkout platform will perform this action by default for links generated in the Merchant Control Panel and will generate the PHASH value for you.
- Parameter BACK_REF should be used in clear (raw, not coded) in the PHASH calculation (ex: &BACK_REF=http://www.YourCustomRedirectURL.com/), but should be encoded when adding it to the URL (ex: &BACK_REF=http%3A%2F%2Fwww.YourCustomRedirectURL.com%2F).
- Parameter SECURE_CART should not be taken into consideration when calculating the PHASH.
Validate 2Checkout redirects
2Checkout generates the ctrl parameter automatically and adds it to Buy Links when you use BACK_REF.
ctrl is an HMAC (keyed-hash message authentication code) MD5/SHA code enabling you to validate that the redirect was generated by 2Checkout. The code is generated using the length of the characters of the redirect URL, concatenated with the redirect URL.
Example
Buy-link |
---|
https://secure.2checkout.com/order/checkout.php?PRODS=1234567&BACK_REF=… |
STRING for HMAC_MD5/HMAC_SHA calculation |
36http://www.YourCustomRedirectURL.com 129 represents the length of the sequence of parameters. |
Secret key for this example |
_SECRET_KEY_ |
Resulting ctrl parameter value* |
3ffdce1661e12b0ab33ef28b1bbc8bb5 (MD5) 4cf27f60551b698e44e4b15267beeac9a6995fb583cf398175c4fe211ae6254e (SHA2) 1b70515c126b4942394e4208f22c0402e48525dc2498542b22a52b3a6161f49f (SHA3) |
Update product
Overview
Use the updateProduct method to update the configuration of a subscription plan/product you already configured 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 configure your subscription plans/products.
You can update/edit all parameters, except the following:
|
Exceptions
When updating a subscription plan/product, you also update its PricingConfigurations. However, you cannot modify:
- The pricing configuration CODE.
- The PricingSchema from DYNAMIC to FLAT or vice versa.
Request
<?php
require ('PATH_TO_AUTH');
$ProductCode = 'NewProdCodeAPI12345';
try {
$myProduct = $client->getProductByCode($sessionID, $ProductCode);
}
catch (SoapFault $e) {
echo "myProduct: " . $e->getMessage();
exit;
}
$myProduct->ProductName = 'Edited_From_API_Again';
var_dump ($myProduct);
try {
$NewSubscriptionPlan = $client->updateProduct($sessionID, $myProduct);
}
catch (SoapFault $e) {
echo "UpdatedProductInfo: " . $e->getMessage();
exit;
}
var_dump("UpdatedProductInfo", $NewSubscriptionPlan);
?>
Response
bool(true)
Enable/Disable product
Overview
Use the setProductStatus method to enable/disable products 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. |
productCode |
Required (string) |
|
Use this object to configure your subscription plan/products.
You can set all Product parameters except 2CheckoutID. The 2Checkout system sets the unique product ID. The 2CheckoutID is not editable. |
Status |
Required (Boolean) |
|
True or False, depending on whether you want to enable or disable a subscription plan/product. |
Request
<?php
require ('PATH_TO_AUTH');
$ProductCode = "YourProductCode";
try {
$ProductStatus = $client->setProductStatus($sessionID, $ProductCode, true); // TRUE to enable a product - FALSE to disable a product
}
catch (SoapFault $e) {
echo "ProductStatus: " . $e->getMessage();
exit;
}
var_dump("ProductStatus", $ProductStatus);
?>
Response
bool(true)
Retrieve a shipping fee configuration
Overview
Use the getShippingFee method to extract information about a specific shipping fee configuration you defined for your account.
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. |
shippingCode |
Required (string) |
|
Shipping fee configuration code. |
Response
Parameters | Type/Description |
---|---|
Array of objects |
Request
<?php
require ('PATH_TO_AUTH');
$shippingCode= "YOUR_SHIPPING_CODE";
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getShippingFee',
'params' => array($sessionID,$shippingCode)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
?>
Retrieve active promotions in cart
Overview
Use this method to list all promotions applied to products added to cart.
Requirements
Parameters
Parameter | Type/Description |
---|---|
sessionID | Required (String) |
Session identifier, output of the Login method. An exception is thrown if the values are incorrect. |
Response
Parameter | Type/Description | |
---|---|---|
Promotion |
Array of objects |
|
|
Details below |
|
|
Name |
String |
|
|
Promotion name |
|
Description |
String |
|
|
Promotion description |
|
StartDate |
String |
|
|
Promotion start date. NULL for promotions that start immediately after they're created. |
|
EndDate |
String |
|
|
Ending date. The date when you set the promotion to end. Is NULL for promotions that you want active indefinitely. |
|
MaximumOrdersNumber |
Int |
|
|
When the maximum number of orders is reached the promotion stops. NULL if you want the promotion to apply to an unlimited number of orders. |
|
MaximumQuantity |
Int |
|
|
Discount only applies to a specific number of products, smaller than the maximum defined quantity. NULL if you want the promotion to apply to an unlimited number units. Any extra quantity added to the cart will be sold at full price. |
|
InstantDiscount |
Boolean |
|
|
Selecting the instant discount option auto-applies the discount for ALL the selected products for all shoppers, without the need to enter the discount coupon. |
|
Coupon |
String |
|
|
Promotion coupon/voucher. |
|
DiscountLabel |
String |
|
|
Set discounts as percentage from the product price or as a fixed amount in the chosen currency. |
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
try {
$Promotions= $client->getPromotions ($sessionID);
} catch (SoapFault $e) {
Echo "AllDiscounts: " . $e->getMessage();
exit;
}
var_dump ("AllDiscounts", $Promotions);
Errors
Error | Description |
---|---|
EMPTY_CART |
The shopping cart is empty |
NO_PROMOTIONS |
There are no promotions applied to current shopping cart |
Add additional fields
Overview
Use the addAdditionalField method to create new additional fields 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. |
Object |
|
|
Additional field object. |
Response
bool(true)
Request
<?php
require ('PATH_TO_AUTH');
$AdditionalField = new stdClass();
$AdditionalField->Label = 'Do you agree with the new newsletter policy 2015?';
$AdditionalField->Type = 'LISTBOX';
$AdditionalField->Code = 'NewsletterPolicy1234576';
$AdditionalField->ApplyTo = 'ORDER';
$AdditionalField->Values = array();
$AdditionalField->Values[0] = 'YES';
$AdditionalField->Values[1] = 'NO';
$AdditionalField->ValidationRule = null;
$AdditionalField->Translations = array();
$AdditionalField->Translations[0] = new stdClass();
$AdditionalField->Translations[0]->Label = "Êtes-vous d'accord avec la politique de la newsletter?";
$AdditionalField->Translations[0]->Values = array();
$AdditionalField->Translations[0]->Values[0] = 'Oui';
$AdditionalField->Translations[0]->Values[1] = 'Non';
$AdditionalField->Translations[0]->Language = 'fr';
$AdditionalField->Translations[1] = new stdClass();
$AdditionalField->Translations[1]->Label = 'Haben Sie mit dem Newsletter Politik zu?';
$AdditionalField->Translations[1]->Values = array();
$AdditionalField->Translations[1]->Values[0] = 'Ja';
$AdditionalField->Translations[1]->Values[1] = 'Nein';
$AdditionalField->Translations[1]->Language = 'de';
$jsonRpcRequest = array(
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addAdditionalField',
'params' => array(
$sessionID,
$AdditionalField
)
);
var_dump(callRPC((Object) $jsonRpcRequest, $host));
?>