Skip to main content

Use Credit cards

Overview

Place an order with dynamic product information, and collect the payment using card-based payment methods.

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.

 

Requirements 

For credit card orders placed using API 5.0 or newer versions, you need to pass through additional parameters that support the 3D Secure flow. 3D Secure works by redirecting customers to pages provided by their banks, where they need to enter additional security tokens or password to trigger the completion of the charge. By using 3D Secure, you get additional protection from liability for fraudulent card payments, with customers having to go through an extra layer of authentication.

Send the following parameters as part of the PaymentMethod object:

Parameters Description
Vendor3DSReturnURL Required (string)
  URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.
Vendor3DSCancelURL Required (string)
  URL address to which customers are redirected if the 3DS details were not validated or the order could not be authorized.

Response 

Parameters Type/Description

Order information

Object

  Object containing order information.

Request

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->Currency = "USD";
$Order->Language = "EN";
$Order->Country = "US";
$Order->CustomerIP = '91.220.121.21';//"10.10.13.37";
$Order->Source = "sourceAPI.net";
$Order->LocalTime = date('Y-m-d H:i:s');
$Order->CustomerReference = 421820775;
$Order->Items = array();


/**
* 1st Product
*/
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = null;
$Order->Items[0]->Quantity = 2;
$Order->Items[0]->PurchaseType = 'PRODUCT';
$Order->Items[0]->Tangible = false; // physical
$Order->Items[0]->IsDynamic = true;

$Order->Items[0]->Price = new stdClass();
$Order->Items[0]->Price->Amount = 100;
$Order->Items[0]->Price->Type = 'CUSTOM';

$Order->Items[0]->Name = 'Dynamic Product 1 '. date("Y-m-d H:i:s");
$Order->Items[0]->Description = 'Description Produs OTF';

$Order->Items[0]->PriceOptions = [];
$priceOption = new stdClass();
$priceOption->Name = 'Name';
$priceOption->Value = 'Value';
$priceOption->Surcharge = 10;
$Order->Items[0]->PriceOptions[] = $priceOption;

$priceOption1 = new stdClass();
$priceOption1->Name = 'Name';
$priceOption1->Value = 'Value123';
$priceOption1->Surcharge = 11;
$Order->Items[0]->PriceOptions[] = $priceOption1;

$priceOption2 = new stdClass();
$priceOption2->Name = 'Name1';
$priceOption2->Value = 'Value1';
$priceOption2->Surcharge = 12;
$Order->Items[0]->PriceOptions[] = $priceOption2;

$Order->Items[0]->RecurringOptions = new stdClass();
$Order->Items[0]->RecurringOptions->CycleLength = 1;
$Order->Items[0]->RecurringOptions->CycleUnit = 'MONTH';
$Order->Items[0]->RecurringOptions->CycleAmount = 1234;
$Order->Items[0]->RecurringOptions->ContractLength = 3;
$Order->Items[0]->RecurringOptions->ContractUnit = 'YEaR';

//$Order->Items[0]->SubscriptionStartDate = '2017-10-22 12:34:56'; set a custom start date for the subscription

/**
* 3rd Product - SHIPPING
*/
$Order->Items[2] = new stdClass();
$Order->Items[2]->Name = 'Shipping Item '. date("Y-m-d H:i:s");
$Order->Items[2]->PurchaseType = 'SHIPPING';
$Order->Items[2]->Quantity = 1;
$Order->Items[2]->Price = new stdClass();
$Order->Items[2]->Price->Amount = 123;
$Order->Items[2]->IsDynamic = true;

/**
* 4th Product - TAX
*/
$Order->Items[3] = new stdClass();
$Order->Items[3]->Name = 'Tax Item '. date("Y-m-d H:i:s");
$Order->Items[3]->PurchaseType = 'TAX';
$Order->Items[3]->Quantity = 1;
$Order->Items[3]->Price = new stdClass();
$Order->Items[3]->Price->Amount = 456;
$Order->Items[3]->IsDynamic = true;
$Order->Items[3]->RecurringOptions = new stdClass();
$Order->Items[3]->RecurringOptions->CycleLength = 1;
$Order->Items[3]->RecurringOptions->CycleUnit = 'MONTH';
$Order->Items[3]->RecurringOptions->CycleAmount = 10.2;
$Order->Items[3]->RecurringOptions->ContractLength = 3;
$Order->Items[3]->RecurringOptions->ContractUnit = 'YEaR';

/**
* 5th Product - COUPON
*/
$Order->Items[4] = new stdClass();
$Order->Items[4]->Name = 'Coupon Item '. date("Y-m-d H:i:s");
$Order->Items[4]->PurchaseType = 'COUPON';
$Order->Items[4]->Quantity = 1;
$Order->Items[4]->Price = new stdClass();
$Order->Items[4]->Price->Amount = 234;
$Order->Items[4]->IsDynamic = true;

/**/
$additionalField1 = new stdClass();
$additionalField1->Code = "additional_field_order_1";
$additionalField1->Text = "REST";
$additionalField1->Value = "1";

$additionalField2 = new stdClass();
$additionalField2->Code = "additional_field_order_2";
$additionalField2->Text = "REST";
$additionalField2->Value = "a";

$additionalField3 = new stdClass();
$additionalField3->Code = "additional_field_order_3";
$additionalField3->Text = "REST";
$additionalField3->Value = "a";

$Order->AdditionalFields = array();
$Order->AdditionalFields[0] = $additionalField1;
$Order->AdditionalFields[1] = $additionalField2;
$Order->AdditionalFields[2] = $additionalField3;

$additionalField1 = new stdClass();
$additionalField1->Code = "REST";
$additionalField1->Text = "REST";
$additionalField1->Value = "REST";



$Order->MachineId = 'machineIdTestDan';
$Order->Discount = null;
$Order->ExternalReference = null;

$Order->BillingDetails = new stdClass();
$Order->BillingDetails->Address1 = 'API BILL';
$Order->BillingDetails->Address2 = 'API BILL2';
$Order->BillingDetails->City = 'London';
$Order->BillingDetails->State = 'Greater London';
$Order->BillingDetails->CountryCode = 'UK';
$Order->BillingDetails->Phone = 12345;
$Order->BillingDetails->Email = 'shopper@2checkout.com';//"mail463@aPpLe.com";//
$Order->BillingDetails->FirstName = 'First Name Bil';
$Order->BillingDetails->LastName = 'Last Name Bil';
$Order->BillingDetails->Company = 'Api Company';
$Order->BillingDetails->Zip = '12345';
$Order->BillingDetails->FiscalCode = 13205628845;

/**/
$Order->DeliveryDetails = new stdClass();
$Order->DeliveryDetails->Address1 = 'Api Del';
$Order->DeliveryDetails->Address2 = 'Api Del2';
$Order->DeliveryDetails->City = 'Api City Del';
$Order->DeliveryDetails->State = 'Paris';
$Order->DeliveryDetails->CountryCode = 'US';
$Order->DeliveryDetails->Phone = '12345';
$Order->DeliveryDetails->Email = 'deli@email.com';
$Order->DeliveryDetails->FirstName = 'Api First Name Del';
$Order->DeliveryDetails->LastName = 'Api Last Name Del';
$Order->DeliveryDetails->Zip = 12345;
/**/

$Order->PaymentDetails = new stdClass();
$Order->PaymentDetails->Type = "CC";

$Order->PaymentDetails->Currency = "USD";
$Order->PaymentDetails->CustomerIP = '91.220.121.21';//"10.10.13.37";

$Order->PaymentDetails->PaymentMethod = new stdClass();


/**/
$Order->PaymentDetails->PaymentMethod->CardNumber = "4111111111111111";//4222222222222 //4111111111111111 //4984123412341234 - Installments
$Order->PaymentDetails->PaymentMethod->CardType = "VISA";/**/

/**/
$Order->PaymentDetails->PaymentMethod->ExpirationYear = "2020";
$Order->PaymentDetails->PaymentMethod->ExpirationMonth = "12";
$Order->PaymentDetails->PaymentMethod->CCID = "123";
$Order->PaymentDetails->PaymentMethod->HolderName = "John Doe";
$Order->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$Order->PaymentDetails->PaymentMethod->CardNumberTime = 83.21; // can be null - high value in seconds is a red flag for fraud attempts.
$Order->PaymentDetails->PaymentMethod->HolderNameTime = 13.35; // can be null - high value in seconds is a red flag for fraud attempts.
$Order->PaymentDetails->PaymentMethod->Vendor3DSReturnURL = "http://www.success.ro"; 
$Order->PaymentDetails->PaymentMethod->Vendor3DSCancelURL = "http://www.error.ro"; 

try {
    $newOrder = $client->placeOrder($sessionID, $Order);
}
catch (SoapFault $e) {
    echo "newOrder: " . $e->getMessage();
    exit;
}

var_dump("newOrder", $newOrder);

Retrieve a product group

Overview

Use the getProductGroup method to extract information about a specific product group you created 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.

groupCode Required (string)
  Unique, system-generated identifier assigned to product groups. 

Response

Parameters Type/Description

ProductGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$groupCode = 'YOUR_GROUP_CODE';

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

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

Usage-based pricing (Pay-per-Usage)

Overview

Usage billing allows merchants to bill their customers based on how much of the product or service they consume after it was used. Usage can be billed standalone (without recurring charges), on top of recurring charges, or on top of usage already included in the plan (in which case it is known as overage). 2Checkout charges subscribers for usage at the start of a new billing cycle for metered resources consumed during the previous billing cycle. Usage billing is also referred to as metered billing, pay-per-use, and pay-as-you-go.

How usage billing works

For example, a communication platform charges their clients a monthly recurring fee of $9.99 and additional fees for how many messages and voice calls clients send out from the platform, as follows:

Volume-based usage fees for messages sent:

  • $0.1 per message, if the customer sent 1 to 1,000 messages (in total) in a month
  • $0.09 per message, if the customer sent 1,001 to 10,000 messages (in total) in a month and  
  • $0.075 per message, if the customer sent more than 10,000 messages (in total) in a month 

Stepped-usage fees for Voice calls made:

  • $0.2 per minute for the first 1000 minutes of voice calls made in a month
  • $0.15 per minute for the minutes above the first 1000, but under 1500 minutes of voice calls made in a month
  • $0.1 per minute for any voice calls made in a month above 1500 minutes

Assuming that in January 2020 Customer A uses the service to send out 800 messages and 1,100 voice call minutes, while Customer B sends out 5,000 messages and 2,500 voice call minutes in total for the same month, this is how much each customer will be charged when their subscription needs to be renewed for February: 

Customer Subscription price - Feb 2020 billing cycle Usage-based Pricing Option Usage - Jan 2020 Usage cost - Jan 2020 Total billed

 

Customer A 

 

 

$9.99 

Messages

800 

800 *$0.1 = $80 

 

$9.99 + $80 + $215 = $304.99 

Voice call 1,100 1,000 * $0.2 + 100 * $0.15 = 215

 

Customer B 

 

 

$9.99 

Messages

5,000 

5,000 * $0.09 = $450 

 

$9.99 + $450 + $345 = $804.99 

Voice call 2,500 1,000 * 0.2 + 500 * 0.15 + 700 * $0.1 = $345

Despite using the same services, customers will be billed different amounts, depending on how much of the services they used.

Availability

Usage Billing is included in our 2Subscribe and 2Monetize packages, but it is also part of the 2Bill add-on available for the 2Sell accounts. Contact 2Checkout directly if you wish to employ usage billing capabilities. 

Set up usage-based pricing options 

Add usage-based pricing options to subscription plans 

To add usage-based pricing options to subscription plans follow these steps: 

1. Log into your 2Checkout Merchant Control Panel.

2. Go to Setup → Products and scroll down to select the desired subscription plan (product).

3. After selecting the product/plan, click the Edit button.

4. In the next window, go to the Pricing tab of the product set-up and then to the Pricing configuration where you want the usage-based pricing option to be added.  

Usage-based pricing options are currently only available for Pricing Configurations with base price. 

By adding Usage-based pricing options to only certain Pricing Configurations you have the ability to customize pricing for different regions/countries.  

5. If the usage-based pricing option does not exist, then click on Create new pricing options group button to add it.  

  • In the iframe window, select Pay per usage as Option type.
  • Fill in the name and description of the new pricing option group, and optionally translate them into the languages you want. 
  • Fill in the unique code for the pricing option. This unique code will be used when uploading usage for your subscriptions. 
  • Select the usage pricing model:
    • a Volume-usage model will apply the same price per unit to all units (similar to the Messages option in the example above)
    • a Stepped-usage model will apply different prices per unit by progressively spreading units into the defined tiers (similar to the Voice calls option in the example above)
  • Click Save to add the pricing option to the Available pricing options groups list.
Unit Prices are not automatically converted from one currency to the other. You need to specify what the price is in the currencies you will be billing this product option. Leaving a price of zero for a currency translates into usage not being billed in that currency.

6. Locate the newly added price option or the existing price option that you want to attach to your product in the Available pricing options groups list and click on Add now. You can add to a product as many usage-based pricing options as you want.

7. To save the Pricing Option Group to the list of “Active pricing option groups” on your product, click on Save.  

Keep in mind that a Pricing Option Group added to a product will only be reflected on subscriptions created after the price option group was added. 

Edit usage pricing options  

You can edit the options on your Usage Pricing option group and have these edits impact all products that use that price option by clicking on Edit options for that pricing option group. 

You can also edit the options on your Usage Pricing option group and have these edits impact only a specific product.

  • Go to the Active pricing options groups list for that product.
  • Click on the Pricing options group name and check the Use with different impact on price option before editing and saving the details.

Deactivate usage pricing options groups  

You can deactivate usage pricing option groups by clicking “Deactivate” for the specific Price Option Group in the “Active pricing options groups” list for that product.  

Usage pricing option groups can be deactivated only when all subscriptions with that price option group are canceled or expired.  

Read here more info on how to manage and upload usage billing.

FAQ

1. What happens when subscriptions with a usage cost component are canceled? 

The 2Checkout system does not attempt to renew or charge customers for canceled subscriptions, nor will it send out any notifications. Instead, consider disabling the automatic billing process to enable 2Checkout to collect outstanding usage payments. 

2. Can subscriptions with a usage cost component be sold to partners via Channel Manager? 

This functionality is not supported at this point in time. 

3. Do affiliates get a commission from the entire value of the entire order (including usage value)? 

Yes, but only if you're offering your affiliates commissions for renewal subscriptions. 

 

Control myAccount UI display language

Overview

Use the setLanguageForMyAccount method before calling the getSingleSignOn or getSingleSignOnByCustomer methods to control the display language customers see when logged into their myAccount.

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.

isoLang

Required (string)

 

ISO 639-1 two-letter code.

Response

Parameters Type/Description

Boolean

true or false depending on whether or not the operation succeeded.

Request

<?php

require ('PATH_TO_AUTH');

$isoLang = 'YOUR_LANGUAGE_ISO_CODE';

try {
    $myAccountLanguage= $client->setLanguageForMyAccount($sessionID, $isoLang);
}
catch (SoapFault $e) {
    echo "myAccountLanguage: " . $e->getMessage();
    exit;
}

Retrieve a customer’s subscriptions

Overview

Extract all subscriptions belonging to a customer. Use the getCustomerSubscriptions method to retrieve details about the subscriptions belonging to a specific customer.

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.

avangateCustomerReference

Required (int)

 

System-generated customer reference. Required unless you prefer to use ExternalCustomerReference.

externalCustomerReference

Optional (string)

 

External customer reference that you control. Optional when you use AvangateCustomerReference. If you include it, it needs to belong to the same customer as the AvangateCustomerReference.

Response

Parameters Type/Description

Subscription

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$customerReference = YOUR_CUSTOMER_REFERENCE;

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

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

Retrieve a customer’s subscriptions

Overview

Extract all subscriptions belonging to a customer. Use the getCustomerSubscriptions method to retrieve details about the subscriptions belonging to a specific customer.

Subscriptions can be retrieved starting with 5 minutes after their orders are generated in the 2Checkout system.

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.

avangateCustomerReference

Required (int)

 

System-generated customer reference. Required unless you prefer to use ExternalCustomerReference.

externalCustomerReference

Optional (string)

 

External customer reference that you control. Optional when you use AvangateCustomerReference. If you include it, it needs to belong to the same customer as the AvangateCustomerReference.

Response

Parameters Type/Description

Subscription

Array of objects

Request

<?php

require ('PATH_TO_AUTH');

$CustomerReference = YOUR_CUSTOMER_REFERENCE;

try {
    $ListofSubscriptions = $client->getCustomerSubscriptions($sessionID, $CustomerReference);
}
catch (SoapFault $e) {
    echo "ListofSubscriptions: " . $e->getMessage();
    exit;
}
var_dump("ListofSubscriptions", $ListofSubscriptions);

Set partner invoice payment details (card payment)

Overview

Configure the details of the payment method that will be used to pay for a partner invoice. Supported payment methods:

  • PayPal
  • Credit / debit cards

Works in conjunction with setProforma and is a prerequisite for payProforma. Call setProforma, then setPaymentDetails and payProforma in this specific order to pay for a partner invoice.

Requirements

This method requires that a specific partner be set using setPartner and that a partner invoice be marked for payment using setProforma.

Parameters

Parameters Type/Description

sessionID

Required (String)

 

Session identifier, output of the Login method. An exception is thrown if the values are incorrect.

paymentDetails

Object

 

Payment details object with the structure detailed below.

 

Type

String

 

 

Possible values:

  • PAYPAL
  • CC

 

Currency

String

 

 

Partner currency ISO code - ISO 4217. This currency governs transactions between you and the partner, and is set in the Commercial Settings page, under Payment information.

Must match the currency of the partner invoice, otherwise an exception is thrown.

If NULL, the system uses the partner invoice currency.

 

PaymentMethod

Object

 

 

Structure below.

 

 

CardNumber

String

 

 

 

Credit / debit card number

 

 

CardType

String

 

 

 

Credit / debit card type:

  • VISA
  • VISAELECTRON
  • MASTERCARD
  • MAESTRO
  • AMEX

 

 

CCID

String

 

 

 

CVC2/CVV2 card identification number.

 

 

ExpirationMonth

String

 

 

 

A valid expiration month must be used, otherwise an exception is thrown. Example: 06 for June.

 

 

ExpirationYear

String

 

 

 

A valid expiration year must be used, otherwise an exception is thrown

 

 

HolderName

String

 

 

 

Card holder name

 

CustomerIP

String

 

 

Partner IP address, needed for security validation.

Response

Parameters Type/Description
Result Boolean
  True or false.

Request

<?php

require('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/02Authentication
require('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/Partner/00Set_partner
require('PATH_TO_setProforma'); // setProforma example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/14Billing/00Capture_card_payment/00Set_partner_invoice

$paymentDetails = new stdClass();

$paymentDetails->Type = 'CC';
$paymentDetails->Curency = 'YOUR_CURRENCY';
$paymentDetails->CustomerIP = 'CUSTOMER_IP';

$paymentDetails->PaymentMethod = new stdClass();
$paymentDetails->PaymentMethod->CardNumber = 'YOUR_CARD_NUMBER';
$paymentDetails->PaymentMethod->CardType = 'YOUR_CARD_TYPE';
$paymentDetails->PaymentMethod->CCID = 'YOUR_CARD_CVV';
$paymentDetails->PaymentMethod->ExpirationMonth = 'CARD_EXPIRATION_MONTH';
$paymentDetails->PaymentMethod->ExpirationYear = 'CARD_EXPIRATION_YEAR';
$paymentDetails->PaymentMethod->HolderName = 'CARDHOLDER_NAME';

try {
    $PaymentDetailsSet= $client->setPaymentDetails($sessionID, $paymentDetails);
} catch (SoapFault $e) {
    Echo "Payment: " . $e->getMessage();
    exit;
}
var_dump ("Payment", $PaymentDetailsSet);

Errors

Error Description

INVALID_PARTNER

No partner is set.

INVALID_PROFORMA

No partner invoice set.

PAYMENT_ERROR

Your currency is not supported. You can only pay in:

PAYMENT_ERROR

You did not set your PaymentMethod property.

PAYMENT_ERROR

Your PaymentMethod property ['.$_prop.'] is not defined.

PAYMENT_ERROR

Your payment type is not supported. We only accept PAYPAL and CC.

PAYMENT_ERROR

We cannot detect the business model

PAYMENT_ERROR

There are no payment methods for this currency

PAYMENT_ERROR

Your payment method is not supported

PAYMENT_ERROR

Invalid credit card

 

IPN Gateway Responses

Overview

This is a list of IPN gateway response statuses for Unfinished orders and their descriptions.  

Order Search Report

The IPN Gateway Response statuses appear on the "Gateway Response" column in the "Order Search" report for unfinished payments. If enabled for your account, you can export the report from your Control Panel account (if the functionality is not enabled for your account, contact 2Checkout) following these steps:

  1. Log in to your Merchant Control Panel.
  2. Navigate to Orders & Customers → Order search
  3. Select the necessary search fields and click on the Search button.

order search report.png

4. After clicking Search, a report will appear under the Search fields. To export this report, click the Export button, as shown in the image below.

order search report export.png

5. Select the 2Checkout Full Options Template from the drop-down menu, and then check the format in which you want to export the report. You can choose between 3 formats: CSV, XLS, XML.

order search report format and template.png

6. After performing the above selection, click on the Export button within the iframe.

7. A report will be generated and you can identify the Gateway response column that captures the reasons for which payments were rejected by the processing gateway.

gateway response column.png

IPN Gateway Response Statuses

Gateway Response Description
Access denied in payment gateway  
Order not pay  
Invalid response  
Call acquirer support call number  
Operation not completed  
Please retry transaction  
Invalid response from gateway  
Already authorized  
Message flow error  
Card type not active or incorrect PIN  
Invalid merchant  
Restricted card  
Authorization declined  
Error - retry  
Password incorrect or card disabled  
Invalid amount  
Amount exceeds card ceiling  
Invalid amount  
No such card  
No such card/issuer  
Re-enter transaction  
Invalid response  
Format error  
Issuer signed off  
Expiry date error  
Card restricted  
Lost card  
Stolen card, pick up  
Insufficient funds  
No chequing account  
No savings account  
Expired card  
Incorrect PIN // Incorrect PIN  
Transaction not permitted on card  
Not permitted to merchant  
Exceeds amount limit  
Restricted card  
Security violation  
Exceeds frequency limit  
PIN tries exceeded // PIN tries exceeded  
Wrong Reference No.  
Reserved  
Network error  
Foreign network error  
Time-out at issuer  
Account verification required  
Authentication failure  
A technical problem occurred, please contact helpdesk  
Router unavailable // Router unavailable  
Violation of law  
Duplicate transmission  
System malfunction  
Authentication failed  
Error in CVC2 or CVC2 Description fields  
Terminal is locked, please try again // Terminal locked  
Our payment system is currently under maintenance, please try later  
Error in amount field  
Error in card expiration date field  
Invalid card number  
Server is not responding //Server is not responding  
No or Invalid response received  
An error occurred during processing. Please retry the operation  
Paypal accept  
Direct Ebanking accept  
Gateway accept  

Retrieve shopping cart contents

Overview

Use this method to get information on the products added to the shopping 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.

Response

Parameter Type/Description
Contents Object
  Cart contents object.

Request

<?php

require ('PATH_TO_AUTH');  // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/02Authentication
require ('PATH_TO_SET_PARTNER'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/Partner/00Set_partner
require ('PATH_TO_ADD_PRODUCT'); // addProduct example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/08Place_an_order/00Add_product_to_cart

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getContents',
'params' => array($sessionID)
);
var_dump (callRPC((Object)$jsonRpcRequest,$host));

Errors

Error Description

EMPTY_CART

The shopping cart is empty.

 

Add products to a promotion

Overview

Use the addPromotionProducts API call via JSON-RPC API 4.0 to add products to an existing promotion.

Parameters

Parameter Type/Description

sessionID

Required (string)

 

Output of the Login method.

promotionCode

Required (string)

 

The code corresponding to the promotion that you want to add products to.

promotionProducts

Required (object)

 

Code

Required (string)

 

 

System generated product code.

 

pricingConfigurationCode

Optional (string)

 

 

System generated pricing configuration code.

 

pricingOptionCodes

Optional (array of strings)

 

 

Pricing option codes that you control.

Response

Parameter Type/Description
promotionProducts Object

Request

<?php

function callRPC($Request, $host, $Debug = true) {
    $curl = curl_init($host);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
    if ($Debug) {
        $RequestString;
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        $ResponseString;
    }
    if (!empty($ResponseString)) {
        var_dump($ResponseString);
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}

$host = 'https://api.avangate.com/rpc/3.1/';

$merchantCode = "YOUR_MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php
$key = "YOUR_SECRET_KEY"; // your account's secret key available in the 'System settings' area of the cPanel: https://secure.avangate.com/cpanel/account_settings.php

$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$hash = hash_hmac('md5', $string, $key);

$i = 1;

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash);
$jsonRpcRequest->id = $i++;

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

$promotionCode = '';

// Define a product to add to the promotion
$newProduct1 = new stdClass;
$newProduct1->Code = '';
$newProduct1->PricingConfigurationCode = '';
$newProduct1->PricingOptionCodes = ['',''];

// Define another product to add to the promotion
$newProduct2 = new stdClass;
$newProduct2->Code = '';
$newProduct2->PricingOptionCodes = [''];

$productPromotion = [$newProduct1, $newProduct2];

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addPromotionProducts',
'params' => array($sessionID, $promotionCode, $productPromotion)
);
var_dump (callRPC($jsonRpcRequest, $host));

Need help?

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

Not yet a Verifone customer?

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

Verifone logo