Skip to main content

Search proposal history by ID

Overview

Use the searchProposalHistoryById method via JSON-RPC API 6.0 to find a specific proposal or retrieve the quote version history.

Request parameters

Parameters Type Required/Optional Description

sessionId

String

Required

Unique 2Checkout session ID code.

ProposalId

String

Required

Proposal id.

Offset

Integer

Required

The offset at which the proposals should be returned. Default value: 0.

Limit

Integer

Required

The maximum number of proposal versions (history) to return. Default value: 10.

HasStatusComment String Optional

Filters the history version by statusComment field. It can be “true” or “false”.

Response

Parameters Type Description

Versions

Object

All versions of a proposal, paginated and ordered by date, newest first. Each element in the collection is a Proposal object.

Count

Integer

The total number of proposal versions.

Limit

Integer

The maximum number of proposal versions history to return. Default value: 10.

Offset

Integer

The offset at which the proposal versions history is returned.

Request sample

<?php

declare(strict_types=1);

class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    public const URL = 'http://api.avangate.local/rpc/6.0';
    public const ACTION = 'searchProposalHistoryById';
    public const ADDITIONAL_OPTIONS = 'c0d6955b-f804-4a13-93a0-cb7cd04bc68a'; // existing proposal id
    //array or JSON
    public const PAYLOAD = <<<JSON
{
    "Limit": 10,
    "Offset": 0,
}
JSON;
}

class Client
{
    private const LOGIN_METHOD = 'login';
    private $calls = 1;
    private $sessionId;

    private function generateAuth(): array
    {
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $date = gmdate('Y-m-d H:i:s');
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $hash = hash_hmac('md5', $string, $key);
        return compact('merchantCode', 'date', 'hash');
    }

    public function login(string $url)
    {
        $payload = $this->generateAuth();
        $response = $this->call($url, array_values($payload), self::LOGIN_METHOD);
        $this->sessionId = $response['result'];
    }

    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?array
    {
        if (empty($this->sessionId) && $action !== self::LOGIN_METHOD) {
            $this->login($url);
        }
        if (is_string($payload)) {
            $payload = json_decode($payload, true);
        }
        if (!empty($this->sessionId)) {
            $payload = [$this->sessionId, Configuration::ADDITIONAL_OPTIONS, $payload];
        }
        $payload = array_filter($payload);
        $request = json_encode([
            'jsonrpc' => '2.0',
            'method' => $action,
            'params' => $payload,
            'id' => $this->calls++,
        ]);
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSLVERSION, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Cookie: XDEBUG_SESSION=PHPSTORM'));
        curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        $response = curl_exec($curl);
        if (empty($response)) {
            die('Server unavailable');
        }
        echo $response . '</br>';
        return json_decode($response, true);;
    }
}

$client = new Client();
$result = $client->call();
var_dump($result);

Dynamic products via ConvertPlus

Overview

Receive payments from customers worldwide without the need of handling catalog products. ConvertPlus enables you to pass the product information dynamically to the checkout page, either by using URL parameters or via your 2Checkout Control Panel.

 

Recommended resources

Availability

Available to 2Checkout accounts that handle their own tax and invoice management. Contact us for activation.

Requirements

It's required to have ConvertPlus enabled on your account. Contact us for activation.

Generate links from the Merchant Control Panel

Follow the instructions below to generate ConvertPlus buy links with dynamic product information.

  1. Log in to the 2Checkout Merchant Control Panel.
  2. Go to Setup → Generate links.
  3. Click the ConvertPlus tab in the Checkout Links area.
  4. Select the Dynamic products radio button.
  5. Select a currency for the ordering process.
  6. Add information for each of the dynamic line items added to the cart:
    • Type
      • Digital product - for products that require electronic delivery.
      • Physical/Tangible product - for products that require shipping.
      • Shipping - line item for shipping costs.
      • Tax - the handling fee added to the final price.
      • Coupon - promotion applied at the order level.
    • Name - the name of your dynamic product, displayed to customers in the cart.
    • Quantity - line item quantity added in cart.
    • Price - unit price for each of the line items added to the cart.
  7. Click on Generate link.
  8. Copy the generated link and add it to your website.

Reporting

To access reports on your orders for dynamic products, follow the instructions below:

  1. Log in to the 2Checkout Merchant Control Panel.
  2. Go to Orders & Customers Order search.
  3. In the Products source dropdown list, select Dynamic products.
  4. Apply other desired filters and click Search.

You can read more information on ConvertPlus buy links signature here

Use WeChat Pay

Overview

Place an order for catalog products defined in your Control Panel and collect the payment using WeChat Pay.

Requirements

Only Chinese shoppers are able to purchase using WeChat Pay. Make sure the billing country code is set to CN.

Supported currencies

  • USD
  • HKD
  • CNY

Workflow

  1. Shoppers select WeChat as payment option in the interface you provide to them.
  2. Create the order object. Use WE_CHAT_PAY as the type of the PaymentDetails object, and include ReturnURL and CancelURL.
  3. Use the placeOrder method to send the data to Avangate.
  4. Once you place the order, Avangate logs it into the system. At this point in time, the status of the order is PENDING.
  5. Avangate returns an Order object as the output of the placeOrder method. 
  6. Use the PaymentMethod object to create a redirect URL for the shoppers, concatenating the values of the Href and avng8apitoken parameters. Here's an example of the redirect URL:
    https://api.avangate.com/4.0/scripts/we_chat_pay/authorize/?avng8apitoken=1abc7fd72d008428
  7. After being redirected to WeChat Pay, shoppers need to scan the QR code provided, using the WeChat smartphone app.
  8. After customers enter their payment password, WeChat notifies Avangate if the payment is approved, and the status of the order becomes COMPLETE.
  9. Shoppers are redirected to the RedirectURL from the Order information object. In case the payment fails, shoppers are redirected to the CancelURL. 

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.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

To place an order with WeChat, use WE_CHAT_PAY as the type of the PaymentDetails object and provide a ReturnURL and a CancelURL as part of the PaymentMethod object. See code sample. 

Response

Parameters Type/Description
Order Object
  Object containing order information.

Request

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = 'CNY';
$Order->Country = 'CN';
$Order->Language = 'en';
$Order->CustomerIP = '91.220.121.21';
$Order->ExternalReference = NULL;
$Order->Source = NULL;
$Order->Affiliate = new stdClass();
$Order->Affiliate->AffiliateCode = 'Partner123'
$Order->Affiliate->AffiliateSource = 'MobilePlatform'
$Order->CustomerReference = NULL;
$Order->Items = array();
$Order->Items[0] = new stdClass();
$Order->Items[0]->Code = 'my_subscription_1';
$Order->Items[0]->Quantity = 1;
$Order->Items[0]->PriceOptions = NULL;
$Order->Items[0]->SKU = NULL;
$Order->Items[0]->Price = NULL;
$Order->Items[0]->CrossSell = NULL;
$Order->Items[0]->Trial = false;
$Order->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->Promotion = NULL;
$Order->Items[0]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.

$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'John';
$Order->BillingDetails->LastName = 'Doe';
$Order->BillingDetails->CountryCode = 'CN';
$Order->BillingDetails->State = 'Beijing';
$Order->BillingDetails->City = 'Beijing';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '90210';
$Order->BillingDetails->Email = 'cosmin.deftu@avangate.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;

$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'WE_CHAT_PAY';
$Order->PaymentDetails->Currency = 'USD';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '91.220.121.21';
$Order->PaymentDetails->PaymentMethod->ReturnURL = 'http://yourreturnurl.com';
$Order->PaymentDetails->PaymentMethod->CancelURL= 'http://yourcancelurl.com';

$Order->Promotions = NULL;
$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

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

$wechatredirect = $newOrder->PaymentDetails->PaymentMethod->Authorize->Href."/?avng8apitoken=".$newOrder->PaymentDetails->PaymentMethod->Authorize->Params->avng8apitoken;

header('Location:' . $wechatredirect);

Update subscription payment information

Overview

Use the updateSubscriptionPaymentInformation method to update the credit card information related to the payment to be made for a subscription. To be able to do this, you need to generate a payment token using the credit card information via the 2Pay.js library, and then use this token in the request of the method as indicated below.

Request Parameters

Parameter Name Type Required/Optional Description

sessionID

String

Required

The 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

String

Required

The reference of the subscription for which you want to retrieve the payment information.

paymentInformation

Object

Required

The payment information object, details below:

PaymentDetails

Object

Required

The payment details object, details below:

Type

String

Required

The payment details type. Restricted to EES_TOKEN_PAYMENT for now.

PaymentMethod

Object

Required

The payment method object, details below:

EesToken

String

Required

The 2Pay token obtained by integrating the 2Pay.js library.

Vendor3DSReturnURL String Required URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.
Vendor3DSCancelURL String Required URL address to which customers are redirected after the 3DS details get validated by the bank and the order is successfully authorized.

Request Example

<?php

declare(strict_types=1);

class Configuration
{
    public const MERCHANT_CODE = '';
    public const MERCHANT_KEY = '';
    public const URL = 'http://api.2checkout.com/rpc/6.0';
    public const ACTION = 'updateSubscriptionPaymentInformation';
    public const ADDITIONAL_OPTIONS = null;
    public const SUBSCRIPTION_REF = 'YC9XXMGOYO';
    //array or JSON
    public const PAYLOAD = <<<JSON
{
  "PaymentDetails": {
    "Type": "EES_TOKEN_PAYMENT",
    "PaymentMethod": {
      "EesToken": "b8de22d1-1378-4a9a-be21-aa2145a6eb54",
      "Vendor3DSReturnURL": "www.3dsReturnURL.com",
      "Vendor3DSCancelURL": "www.3dsCancelURL.com"
    }
  }
}
JSON;
}

class Client
{
    private const LOGIN_METHOD = 'login';
    private $calls = 1;
    private $sessionId;
    private function generateAuth(): array
    {
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $date = gmdate('Y-m-d H:i:s');
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $hash = hash_hmac('md5', $string, $key);
        return compact('merchantCode', 'date', 'hash');
    }
    public function login(string $url)
    {
        $payload = $this->generateAuth();
        $response = $this->call($url, array_values($payload), self::LOGIN_METHOD);
        $this->sessionId = $response['result'];
    }
    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?array {
        if (empty($this->sessionId) && $action !== self::LOGIN_METHOD) {
            $this->login($url);
        }

        if(is_string($payload)) {
            $payload = json_decode($payload, true);
        }
        if (!empty($this->sessionId)) {
            $payload = [$this->sessionId, Configuration::SUBSCRIPTION_REF, $payload];
        }
        $payload = array_filter($payload);

        $request = json_encode([
            'jsonrpc' => '2.0',
            'method' => $action,
            'params' => $payload,
            'id' => $this->calls++,
        ]);

        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSLVERSION, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Cookie: XDEBUG_SESSION=PHPSTORM'));
        curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        $response = curl_exec($curl);
        if(empty($response)) {
            die('Server unavailable');
        }
        echo $response . '</br>';
        return json_decode($response, true);;
    }
}
$client = new Client();
$result = $client->call();
var_dump($result);

Response

The method responds with Boolean True when the payment information update was successfully performed.
Otherwise, in case of validation or access rights failures, it returns the usual error response with specific messages indicating the cause of the failure.

{
    "jsonrpc": "2.0",
    "id": 2,
    "result": {
        "FirstDigits": "4012",
        "LastDigits": "9936",
        "Authorize3DSUrl": "http://...",
        "CardType": "visa"
    }
}

 

Use Checks

Overview 

Place an order using catalog products, and collect the payment using Check.

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.

 

Workflow 

  1. Customer places the order using Check as payment option.
  2. After order is confirmed, customer receives the payment instructions via e-mail, including the address to which the check should be sent.
  3. Order is finalized as soon as the payment is confirmed into 2Checkout's bank account.

Response 

Parameters Type/Description

Order information

Object

Request

<?php

require ('PATH_TO_AUTH');

$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->Items[0]->AdditionalFields = NULL;
$Order->Items[0]->SubscriptionStartDate = NULL; //If empty or null, subscriptions become active when purchase is made.
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->FirstName = 'John';
$Order->BillingDetails->LastName = 'Doe';
$Order->BillingDetails->CountryCode = 'us';
$Order->BillingDetails->State = 'California';
$Order->BillingDetails->City = 'LA';
$Order->BillingDetails->Address1 = 'Address example';
$Order->BillingDetails->Address2 = NULL;
$Order->BillingDetails->Zip = '90210';
$Order->BillingDetails->Email = 'customer@2checkout.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = 'ABC Company';
$Order->DeliveryDetails = NULL;


$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'CHECK';
$Order->PaymentDetails->Currency = 'USD';
$Order->PaymentDetails->PaymentMethod = new stdClass ();

$Order->AdditionalFields = NULL;
$Order->LocalTime = NULL;
$Order->GiftDetails = NULL;

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

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

Order information object

Overview

Use this object to retrieve information about orders. 

Attributes

OrderInformation object parameters

Type/Description

RefNo

Optional (string)

 

Avangate generates unique reference numbers for all orders (purchases). You can use this parameter to retry authorizations for orders with failed transactions by changing the payment method.

 

NULL when you place new orders.

OrderNo

Optional (string)

 

The consecutive order number Avangate associates with orders and displays in the Order search area of your account.

ExternalReference

Optional (string)

 

Set external reference identifiers for orders. Enables you to replicate the functionality of the REF parameter included into 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.

ShopperRefNo

Optional (string)

 

External shopper identifier.

Status

Optional (string)

 

The status of the order:

  • AUTHRECEIVED – Avangate blocks the amount corresponding to the transaction, but the process of collecting funds is incomplete.
  • PENDING - Avangate has yet to block the amount corresponding to the transaction or shoppers used an offline payment method like wire transfer.
  • COMPLETE – The shopper completed the transaction for the purchase and Avangate or you fulfilled the order (when required).
  • CANCELED – Avangate cancels orders for which shoppers fail to transfer funds in due time.
  • REVERSED – Avangate reverses order transactions that never reach the Complete/Finished stage. Shoppers never complete transactions for such purchases.
  • REFUND – Avangate refunds orders only after they reach the Complete/Finished stage and returns the funds collected to shoppers.

ApproveStatus

Optional (string)

 

The status of the order resulted from the evaluation by the Avangate anti-fraud system or by a member of the anti-fraud department. This status varies for new purchases and for orders requiring customers to make manual payments.

Possible values:

  • WAITING: The Avangate anti-fraud system or a member of the anti-fraud department has yet to approve the order.
  • OK: The Avangate anti-fraud system or a member of the anti-fraud department approved the order.
  • INVALIDDATA: Shopper-supplied data is invalid – Avangate did not approve the order.
  • FRAUD: The order is fraudulent.

VendorApproveStatus

Optional (string)

 

Shows if you approved or not a partner order. Possible values:

  • OK
  • WAITING
  • REJECTED

Language

Optional (string)

 

ISO 639-1 two-letter code. Language used for the purchase process. Example: “en.”

OrderDate

Optional (string)

 

Y-m-d H:i:s (2014-05-22 00:12:12) The datetime stamp (in the API time zone defined in cPanel) when customers place their orders.

FinishDate

Optional (string)

 

Y-m-d H:i:s (2014-05-22 00:12:12) The datetime stamp (in the API time zone defined in cPanel) when the order reach the Complete status.

 

NULL for order that did not reach the Complete/Finished stage.

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. Cannot be null.

AffiliateSource

Optional (string)

 

The link source for affiliate referred sales. Similar to the functionality of the SRC (separate link identifier) parameter included into Buy Links, but controlled by the AFFSRC parameter. Affiliates use the AFFSRC parameter to track sale sources for their referrals. Maximum length 255 characters.

AffiliateId

Optional (int)

 

Identifier belonging to affiliates who refer orders.

AffiliateName

Optional (string)

 

Affiliate name.

AffiliateUrl

Optional (string)

 

Affiliate website URL from the Affiliate Details.

RecurringEnabled

Optional (boolean)

 

true or false, depending on whether the shoppers checked the subscription auto-renewal checkbox or not, during the purchase process.

HasShipping

Optional (boolean)

 

true or false, depending on whether the order requires shipping.

BillingDetails

Optional (Object)

   

Details below. 

 

Person

Object

     

Details below. 

   

FirstName

Optional (string)

     

Shopper name.

   

LastName

Optional (string)

     

Shopper surname.

   

CountryCode

Optional (string)

     

Shopper country. ISO 3166 two-letter code.

   

State

Optional (string) – Required 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

Optional (string)

     

Shopper city.

   

Address1

Optional (string)

     

Shopper address.

   

Address2

Optional (string)

     

Shopper address.

   

Zip

Optional (string)

     

ZIP/ Postal code.

   

Email

Optional (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. Avangate 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 the Billing Country is set to Brazil. For Brazilian customers it represents the Fiscal Code (CPF/CNPJ).

• Can be null for end users.

DeliveryDetails

Optional (Object)

Optional. When missing, Avangate uses the same details as for the BillingDetails object.

     

Details below. 

   

Person

Object

       

Details below. 

     

FirstName

Optional (string)

       

Shopper name from the delivery details.

     

LastName

Optional (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.

     

Email

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

Optional (Object)

 

Adapt this object to the desired payment method.

 

Type

Optional (string)

   

The payment method:

  • CC (credit/debit card - including local Brazilian cards).
  • PAYPAL
  • PAYPAL_EXPRESS
  • TEST (for test orders).
  • PREVIOUS_ORDER (place new orders using the reference of a previous order).
  • EXISTING_PAYMENT_DATA  (use a card one of your customers already used to purchase from your account).
  • WIRE – the placeOrder response includes Wire payment details.
  • CHECK – the placeOrder response includes Check payment details.
  • PURCHASEORDER - use for orders with POs.
  • FREE – for 0 value orders for which you’re not requiring customers to provide payment details.
 

Currency

Optional (string)

   

The currency ISO code for the payment - ISO 4217. Example: “usd.”

 

PaymentMethod

Optional (object)

   

Object structure and parameters differ according to payment method selected and API method (placing orders (POST) vs. retrieving order data (GET)). For payments with credit cards, PalPay Express, previous order reference and purchase order use the objects below.

For payments with check and wire, send only the ‘CHECH’ and ‘WIRE’ strings.

null for 0 value orders for which you’re not requiring customers to enter payment details.

   

PaymentDetailsCard

Optional (object)

       

Details below. 

     

CardType

Optional (string)

       

visa, visaelectron, mastercard, maestro, amex, discover, dankort, cartebleue, jcb, hipercard, elo

     

FirstDigits

Optional (string)

       

First four digits of the credit card.

     

LastDigits

Optional (string)

       

Last four digits of the credit card.

 

CheckPaymentDetails

Optional (Object)

     

Details below. 

   

Beneficiary

Optional (string)

     

The beneficiary of the payment.

Can be NULL.

   

CheckPostalAddress

Optional (string)

     

The address of the beneficiary.

Can be NULL.

   

Amount

Optional (double)

     

The total costs incurred by the customer for an order.

Can be NULL.

   

Currency

Optional (string)

     

The currency ISO code of the order/payment - ISO 4217.

Can be NULL.

 

PayPalExpress

Optional (Object)

       

Details below. 

     

Email

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 into 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.

 

WirePaymentDetails

Optional (Object)

     

Details below. 

   

Amount

Optional (double)

     

The total costs customers incur.

Can be NULL.

   

Currency

Optional (string)

     

The currency ISO code of the order - ISO 4217.

Can be NULL.

   

PaymentReference

Optional (string)

     

Transaction identifier.

Can be NULL.

   

RoutingNumber

Optional (string)

     

Identification number assigned to financial institutions.

Can be NULL.

   

BankAccounts

Optional (Array of objects)

       

Details below. 

     

Beneficiary

Optional (string)

       

The beneficiary of the payment.

Can be NULL.

     

BankName

Optional (string)

       

The name of the beneficiary's bank.

Can be NULL.

     

BankCountry

Optional (string)

       

The country of the beneficiary's bank.

Can be NULL.

     

BankCity

Optional (string)

       

The city of the beneficiary's bank.

Can be NULL.

     

BankAddress

Optional (string)

       

The address of the beneficiary's bank.

Can be NULL.

     

BankAccount

Optional (string)

       

The number for the account in which customers transfer the funds.

Can be NULL.

     

BankAccountIban

Optional (string)

       

The IBAN of the beneficiary's bank.

Can be NULL.

     

BankAccountSwiftCode

Optional (string)

       

The Swift Code of the beneficiary's bank.

Can be NULL.

     

Currency

Optional (string)

       

The currency ISO code for the bank account - ISO 4217.

Can be NULL.

 

CustomerIP

Optional (string)

   

Shopper IP.

CustomerDetails

Object

Avangate populates the parameters of the customer entity with information from the customer whose AvangateCustomerReference or ExternalCustomerReference you send during the purchase.

   

Details below. 

 

AvangateCustomerReference

Optional (Int)

   

System-generated Avangate customer reference. Aggregate subscriptions under the same Customer account if the products they're associated to are purchased by the same shopper by adding the AV_CUSTOMERID (case sensitive) parameter to buy links. The Avangate system generates default customer numerical (integer) IDs (AV_CUSTOMERID) automatically for all orders containing products that feature subscriptions.

 

ExternalCustomerReference

Optional (string)

   

The external customer reference you control. Aggregate subscriptions under the same Customer account if the products they're associated to are purchased by the same shopper by adding the CUSTOMERID (case sensitive) parameter  to buy links.

 

FirstName

Optional (string)

   

Customer's first name. 

 

LastName

Optional (string)

   

Customer's last name.

 

CountryCode

Optional (string)

   

Customer's country code (ISO 3166 two-letter code).

 

State

Optional (string)

   

Customer's state. For example, "Alabama","Alaska","Arizona".

 

City

Optional (string)

   

Customer's city.

 

Address1

Optional (string)

   

Customer's address.

 

Address2

Optional (string)

   

Customer's address.

 

Zip

Optional (string)

   

Zip code.

 

Email

Optional (string)

   

Customer's email.

 

Phone

Optional (string)

   

Customer's phone number.

 

Company

Optional (string)

   

Company name.

 

FiscalCode

Optional (string)

   

For companies, it needs to be the VAT ID. Avangate validates this values and throws an error if the VAT ID is invalid/incorrect. When present, you need to also provide Company name.

 

Can be null for end users.

 

Fax

Optional (string)

   

Customer's fax number.

 

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.

 

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.”

 

ExistingCards

Optional (Array of objects)

     

Details below. 

   

TransientToken

Optional (Object)

     

Populated only 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, hipercard, elo

   

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.

Origin

Optional (String)

 

Avangate automatically tracks the source of purchases:

 

  • Web – When customers use the desktop version of the Avangate shopping cart.
  • API - When customers use a custom, API-based ordering interface.
  • Mobile - When customers use the mobile version of the Avangate shopping cart.
  • Automatic Billing – For auto-renewals and trial conversions.

AvangateCommission

Optional (Int)

 

Avangate's commission for the order.

OrderFlow

Optional (string)

 

PURCHASE_ORDER - Sent only when shoppers used Purchase Orders.

REGULAR - Sent in all other cases.

GiftDetails

Optional (object)

 

Contains contact details for the recipient of a gift purchase.

 

FirstName

Optional (string)

   

First name of gift recipient.

 

LastName

Optional (string)

   

Last name of gift recipient.

 

Email

Optional (string)

   

Email of gift recipient. Avangate uses this email for the delivery/fulfillment process.

 

GiftNote

Optional (string)

   

Custom text shoppers provide as a message to the gift recipient.

PODetails

Object (optional)

   

Details below. 

 

Status

Optional (string)

   

PO status. Possible values:

 

PO status API

PO status cPanel

AWAITING_UPLOAD

Awaiting form submission - Waiting for the customer to submit the PO form

TIME_EXPIRED

Expired, form not received - The customer did not submit the PO form

AWAITING_MERCHANT

Awaiting your confirmation - PO approved by Avangate, awaiting vendor confirmation

MERCHANT_TIME_EXPIRED

Expired, PO not confirmed - You didn't confirm/reject the PO

AWAITING_MERCHANT

Rejected - You rejected the PO

AWAITING_PAYMENT

Awaiting payment - You approved the PO, waiting for payment

AWAITING_PAYMENT

Expired, not paid - The customer did not complete the PO payment. Avangate accepts  payments up to 30 days after the PO payment interval expires

NOT_PAID

Canceled, not paid - The customer did not complete the PO payment

NOT_PAID

Canceled by Avangate - Avangate canceled the PO

NOT_PAID

Canceled via API - You canceled the PO (via API)

PAID

Complete - Customer paid the PO. The order is complete

 

AutoApprove

Optional (Boolean)

 

TRUE or FALSE, depending on whether you set POs to auto-approve or not.

ExtraInformation

Optional (Object)

 

Details below. 

 

PaymentLink

Optional (String)

 

 

Can be:

1. The PO doc upload link - If you set AutoApprove as FALSE on the original order and before shoppers upload the PO. 

2. Payment link for orders with POs. Business customers can use the PaymentLink to finalize payment for orders with POs. If you set AutoApprove as TRUE on the original order and if Avangate and you approve the PO. 

PaymentLink

Optional (string)

 

In scenarios in which an issue blocks the transaction from finalizing, Avangate provides a retry link where shopper can complete their purchase by providing new payment details.

PartnerCode

Optional (string)

 

Partner code you configured for your partner. NULL for eStore orders.

PartnerMargin

Optional (double)

 

Partner margin you set for the order. NULL for eStore orders.

PartnerMarginPercent

Optional (double)

 

The percentage of the partner margin from the net value of the products ordered, minus the value of any discounts. NULL for eStore orders.

ExtraMargin

Optional (double)

 

Extra margin you offer by editing partner orders. NULL for eStore orders.

ExtraMarginPercent

Optional (double)

 

The percentage of the extra partner margin from the net value of the products ordered, minus the partner margin and the value of any discounts. NULL for eStore orders.

ExtraDiscount

Optional (double)

 

Extra discount you offer by editing partner orders. NULL for eStore orders.

ExtraDiscountPercent

Optional (double)

 

The percentage of the partner margin from the net value of the products ordered, minus the value of any coupon discounts. NULL for eStore orders.

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.

TestOrder

Optional (Boolean)

 

True for test orders. False of regular orders.

Errors

Optional (StringArray)

 

Payment gateway processing errors.

Items

Array of objects

   

Details below. 

 

ProductDetails

Object

   

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)

     
  • true for orders renewing subscriptions.
  • false for all other orders: new purchases, upgrades.
   

Subscriptions

Object

     

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)

       
  • true – For non-recurring, evergreen subscriptions.
  • false – For recurring subscriptions with a specific billing cycle from 7 days to 36 months.
     

Trial

Optional (boolean)

       
  • true – For trial subscriptions.
  • false – For non-trial, recurring subscriptions with a specific billing cycle from 7 days to 36 months.
     

Enabled

Optional (boolean)

       
  • true – For active and past due subscriptions.
  • false – For expired and cancelled subscriptions.
     

RecurringEnabled

Optional (boolean)

         

                   

PriceOptions

Optional (array of strings)

   

Array of price option codes.

   

Code

Optional (strings)

     

Unique code that the Avangate system generates or that you set for each pricing options group.

   

Required

Optional (boolean)

     
  • true – you require shoppers to select the price option  through the way in which you configured pricing.
  • false – you do not require shoppers to select the price option.
   

Options

Optional (array of strings)

     

The code you set or that the Avangate system generates for each price option child inside a pricing options group parent.

 

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 (in the payment currency), excluding sales tax/VAT, from which Avangate deducts discounts.

   

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:

  • UnitNetPrice: 99
  • UnitGrossPrice: 120.39
  • UnitVAT: 21.39
  • UnitDiscount: 9.9
  • UnitNetDiscountedPrice: 89.1
  • UnitGrossDiscountedPrice: 110.49
  • UnitAffiliateCommission: 22.28
  • Currency: "usd"
  • NetPrice: 198
  • GrossPrice: 240.77
  • NetDiscountedPrice: 178.2
  • GrossDiscountedPrice: 220.97
  • Discount: 19.8
  • VAT: 42.77
  • AffiliateCommission: 44.56
   

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)

     
  • REGULAR – product/cart line level discounts.
  • ORDER – quantity discounts.
  • GLOBAL – order-level discounts.

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)

   
  • REGULAR – product/cart line level discounts.
  • ORDER – quantity discounts.
  • GLOBAL – order-level 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.

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:

  • Currency: "usd"
  • NetPrice: 396
  • GrossPrice: 486.29
  • NetDiscountedPrice: 376.2
  • GrossDiscountedPrice: 466.49
  • Discount: 19.8
  • VAT: 90.29
  • 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. Avangate does not take into account shipping costs when calculating affiliate commissions.

 

India local processing and card support

Overview

In 2020, India reached an internet user base of about 700 million, about 52% of the population. But despite being the second-largest user base in the world, only behind China (930 million, 67% of the population), the penetration of eCommerce is low compared to more mature markets like the United States (284 million, 87%), or France (82% of the population).

However, the online market is growing in India at an unprecedented rate, adding around 6 million new users every month, and is expected to surpass the US to become the second-largest eCommerce market in the world by 2034. Revenue in the Indian eCommerce market is projected to reach US$45,894m by the end of 2020.

Key payment methods

Credit and debit cards are a popular payment method for eCommerce in India, though other local card brands such as RuPay, and digital wallets are also preferred (the most popular being NetBanking). However, most online shoppers in India still prefer to pay COD (cash on delivery) for their purchases.

Types of payment methods preferred by shoppers:

  • COD - 60%
  • Credit cards – 17%
  • Debit cards – 13%
  • Net Banking – 9%
  • EMI - <1%
  • 3rd party/digital wallets - <0.5%

 

Benefits of local processing

  • Increase local processing options for merchants in India
  • Improve authorization rates
  • Enables Indian shoppers to pay with their preferred methods
  • Enable entry for international clients and increase sales into one of the largest markets in the world

How to integrate with a local payment processor

Currently, 2Checkout offers integration with a local payment processor in India. If you sell in India, you can follow these simple steps below to integrate with our local processor there:

  1. Log in to your Merchant Control Panel.
  2. Navigate to Setup → Ordering options.
  3. Click on the Payment methods tab.
  4. Click on the Edit button for the Visa/MasterCard payment method.

PayU_India_local processor_1.png

5. When prompted with the checkbox selection, tick the India option to request the activation of domestic cards in this country. 

PayU_India_local processor_2.png

 

 

Retrieve subscription plan/product info

Overview

Use the searchProducts method to extract information about the subscription plan/products you configured 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.

SearchOptions

Object

 

 

SearchOptions

 

Object

Name

Optional (string)

 

Product name.

Can be NULL.

Types

Optional (StringArray)

 

Array of the values representing the type of products. Possible values:

  • REGULAR
  • BUNDLE

Leave empty to have all product types returned to the search.

Can be NULL. If NULL, Avangate returns both regular and bundle products.

Enabled

Optional (boolean)

 

True or false.

Can be NULL.

GroupName

Optional (string)

 

The name of the group that the product is associated with.

Can be NULL.

Limit

Optional (integer)

 

Number of results (products) displayed per page. Default value is 10.

Can be NULL.

Page

Optional (integer)

 

A specific page of search results. Default value is 1.

Can be NULL.

Response

Product

Object

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 error " . $e->getMessage();
}

var_dump($sessionID);

$SearchOptions        = new stdClass();
$SearchOptions->Name  = 'Avangate'; //Product name
$SearchOptions->Types = array(
    'REGULAR',
    'BUNDLE'
);
//You can also use additiona search options to narrow down results
// $SearchOptions->Enabled = ;
// $SearchOptions->GroupName = '';

$SearchOptions->Limit = '10';
$SearchOptions->Page  = '10';

try {
    $ProdSearch = $client->searchProducts($sessionID, $SearchOptions);
}

catch (SoapFault $e) {
    echo "Query: " . $e->getMessage();
    exit;
}

var_dump("Query", $ProdSearch);

?>

Retrieve assigned additional fields

Overview

Use the getAssignedAdditionalFields method to extract information about the additional fields assigned to a specific product.

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.

ProductCode

Required (string)

 

The editable code that you control at product-level, not the unique, system-generated product ID.

Response

AdditionalField

Array of objects

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;
}

$ProductCode = 'AAAA4643116';

try {
    $AssignedAdditionalField = $client->getAssignedAdditionalFields($sessionID, $ProductCode);
}

catch (SoapFault $e) {
    echo "AssignedAdditionalField: " . $e->getMessage();
    exit;
}

var_dump("AssignedAdditionalField", $AssignedAdditionalField);


?>

Add order/product additional fields

Overview

Use the addAdditionalField method to create new additional fields 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.

AdditionalField

Object

 

Additional field object.

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;
}

$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';


try {
    $NewAdditionalField = $client->addAdditionalField($sessionID, $AdditionalField);
}

catch (SoapFault $e) {
    echo "NewAdditionalField: " . $e->getMessage();
    exit;
}

var_dump("NewAdditionalField", $NewAdditionalField);


?>

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