Skip to main content

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


?>

Update reseller information

Overview

Use this method to update the details for an existing reseller entity in the Avangate platform.

Note: Updating the details of a reseller does not impact the reseller information already attached to existing partner orders. Let's assume that you added Reseller 1 to Order 1, and then update Reseller 1 changing the company name. Reseller 1 for Order 1 will continue to feature the old Reseller 1 information. To swap it for the new details, add the reseller to the order again using setOrderReseller.

Requirements

Parameters

Parameter Type/Description
sessionID Required (string)
  Session identifier, which is the output of the Login method. An exception will be thrown if the values are incorrect.
Reseller Required (object)

Response

Parameter Type/Description
Result Boolean

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

$RefNo = 'YOUR_ORDER_REFERENCE_NUMBER';

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getOrderReseller',
'params' => array($sessionID, $RefNo)
);
// Start by retrieving the order reseller information

$existingReseller = callRPC((Object)$jsonRpcRequest, $host);

$newAddress = 'NEW_ADDRESS';

$existingReseller->Address = $newAddress;
// Update the existing reseller address

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'updateReseller',
'params' => array($sessionID, $existingReseller)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
// Send the new address to the reseller object, then display it

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'setOrderReseller',
'params' => array($sessionID, $RefNo, $existingReseller->ResellerCode)
);
var_dump(callRPC((Object)$jsonRpcRequest, $host));
// Re-assign the reseller information back to the order

$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getOrderReseller',
'params' => array($sessionID, $RefNo)
);
var_dump(callRPC((Object)$jsonRpcRequest, $host));
// Display the updated reseller information

PricingList Object Structure

Parameters

Parameter Type/Description
PricingListCode String
  The unique identifier of the pricing list.
Name String
  The name of the pricing list.
ProductInfo Complex object
  Complex object containing arrays of SimpleProduct and PriceOptions objects.

 

Retrieve partner information

Overview

Access partner details using the unique codes set to identify them.

Parameters

Parameters Type/Description
sessionID Required (string)
  Session identifier, output by the Login method. An exception will be thrown if the values are incorrect.
partnerCode Required (string)
  The unique partner code.

Response

Parameter Type/Description
Partner Object
  Partner information object.

Request

<?php

require ('PATH_TO_AUTH'); // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/02Authentication

$partnerCode = 'YOUR_PARTNER_CODE';

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

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

Errors

Error Description

INVALID_PARTNER

Partner code is mandatory.

INVALID_PARTNER

Partner code provided is not associated with an active partner account in the Avangate system.

Shipping method

Overview

The object below is returned directly or within a successful response from the following API requests:

Search shipping method

Shipping method object

Parameters   Type/Description
Items   Array of objects
      Contains shipping methods objects.
  ShippingMethod

Shipping method object.

Details below.

          Name String
      Shipping method name that you define when creating the method.
          Code String
      System-generated identified for the shipping method.
          TrackingURL String
      URL assigned to the shipping method. Provided to your customers that purchase physical products.
          BasePrice String
      Base fee attached to the shipping method, that will be charged to customers when shipping method is available in cart, regardless of their country, product value or weight.
          Currency String
      Currency in which the base fee is expressed. Example: 'USD'.
           Active Boolean
     

Possible values:

  • TRUE - if shipping method is active.
  • FALSE - if shipping method is inactive.
    Availability Strings
     

Defined where the shipping method is active.

Possible values:

  • ALL - all delivery countries.
  • CUSTOM - selected delivery countries.
  • HOME - only your home country.
    Countries Array of objects
      Countries where the shipping method applies.
                  CountryCode String
                  Two-letters country code.
                  Surcharge String
      Surcharge defined for each country.
    Surcharge Array of objects
      Additional fee assigned to the shipping method.
                 Type String
                 

Order property based on which the surcharge is added.

Possible values:

  • PRICE -  surcharge is based on total order amount.
  • WEIGHT -  surcharged is based on total order weight.
                 From Float
                  Lower interval limit.
                 To Int
      Higher interval limit.
                  Amount Int
      Surcharge defined based on order price/weight.
                 ApplyTo String
     

Possible values:

  • interval - surcharge is added for a given interval. Example: from 1 kg to 4kg.
  • unit - surcharge is added for each additional unit. Example: $5 for each unit over 4 kg.
  Pagination Object
      Pagination filters.
    Page Int
      Number of pages used for displaying the results.
    Limit Int
      Number for limiting the results.
    Count Int
      Total number of results.

 

Add products

Overview

Use addPromotionProducts 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

require ('PATH_TO_AUTH');

// 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];

try {
    $updatedPromotion = $client->addPromotionProducts($promotionCode, $productPromotion);
}

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

var_dump("UpdatedPromotion", $updatedPromotion);

 

Remove product coupon

Overview

Use this method to remove discount coupons applied to products added to cart.

Requirements

Parameters

Parameters Type/Description
sessionID Required (String)
  Session identifier, which is the output of the Login method. An exception is thrown if the values are incorrect
coupon Required (String)
  The coupon/voucher code for a promotion impacting a product added to cart.

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/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
require ('PATH_TO_ADD_COUPON'); // addCoupon example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/08Place_an_order/06Add_product_coupon

$couponCode = 'COUPON_CODE_TO_REMOVE';

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

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

Errors

Error Description

EMPTY_CART

The shopping cart is empty

INVALID_COUPON_CODE

The coupon code is empty

INVALID_COUPON

The coupon code is not applied to cart

 

Retrieve wire transfer details

Overview

Retrieve the wire payment details that partners need to use to pay for partner invoices.

Requirements

Next, use setProforma to identify a specific partner invoice.

Parameters

Parameter Type/Description
sessionID Required (String)
  Session identifier string, output of the Login method. An exception is thrown if the values are incorrect.
refNo Required (String)
  Order reference number of an order that was marked with WIRE as payment method.

Response

Parameters Type/Description

WirePaymentDetails

Object

 

Details below

 

Amount

Double

 

 

The total costs incurred by the partner for a partner invoice invoice.

 

Currency

String

 

 

Order currency ISO code - ISO 4217.

 

PaymentReference

String

 

 

Transaction identifier.

 

RoutingNumber

String

 

 

Identification number assigned to financial institutions.

 

BankAccounts

Array of objects

 

 

Array of BankAccountDetails objects with the structure detailed below. Can be NULL.

 

 

Beneficiary

String

 

 

 

Payment beneficiary name. Can be NULL.

 

 

BankName

String

 

 

 

Beneficiary bank name. Can be NULL.

 

 

BankCountry

String

 

 

 

Beneficiary bank country. Can be NULL.

 

 

BankCity

String

 

 

 

Beneficiary bank city. Can be NULL.

 

 

BankAddress

String

 

 

 

Beneficiary bank address. Can be NULL.

 

 

BankAccount

String

 

 

 

Beneficiary bank account number. Can be NULL.

 

 

BankAccountIban

String

 

 

 

Beneficiary IBAN. Can be NULL.

 

 

BankAccountSwiftCode

String

 

 

 

Beneficiary SWIFT code. Can be NULL.

 

 

Currency

String

 

 

 

Bank account currency ISO code – ISO 4217. Can be NULL.

Request

<?php

require ('PATH_TO_AUTH');  // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/02Authentication
require ('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/Partner/00Set_partner

$proformaNumber = 'YOUR_PROFORMA_NUMBER';

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

$paymentDetails = new stdClass();
$paymentDetails->Type = 'WIRE';
$paymentDetails->Curency = 'USD';

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

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

$refNo = 'YOUR_ORDER_REFERENCE_NUMBER';

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

 

Errors

Error Description

INVALID_PARTNER

No partner is set.

PAYMENT_PROFORMA

You have to set a partner invoice first.

PAYMENT_NOT_SUPPORTED

The current partner invoice is not set as payable through wire.

 

Retrieve check payment details

Overview

Retrieve the check payment details that customers must use or have used to pay for an order.

Requirements

Parameters

Parameter Type/Description
sessionID Required (String)
  Session identifier string, output of the Login method. An exception is thrown if the values are incorrect.
refNo Required (String)
  Order reference number of an order that was marked with CHECK as payment method.

Response

Parameter Type/Description

CheckPaymentDetails

Object

 

Details below

 

Beneficiary

String

 

 

Payment beneficiary name. Can be NULL.

 

CheckPostalAddress

String

 

 

Beneficiary address. Can be NULL.

 

CheckAccountHolderName

String

 

 

Beneficiary account holder name. Can be NULL.

 

Country

String

 

 

Beneficiary country. Can be NULL.

 

Amount

Double

 

 

Total order costs. Can be NULL.

 

Currency

String

 

 

Order currency ISO code – ISO 4217. Can be NULL.

Request

<?php

require ('PATH_TO_AUTH');  // Authentication example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/02Authentication
require ('PATH_TO_setPartner'); // setPartner example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/JSON-RPC/06Reference/Partner/00Set_partner

$proformaNumber = 'YOUR_PROFORMA_NUMBER';

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

$paymentDetails = new stdClass();
$paymentDetails->Type = 'CHECK';
$paymentDetails->Curency = 'USD';

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

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

$refNo = 'YOUR_ORDER_REFERENCE_NUMBER';

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

Errors

Error Description

INVALID_PARTNER

No partner is set.

PAYMENT_PROFORMA

You have to set a partner invoice first.

PAYMENT_NOT_SUPPORTED

The current partner invoice is not set as payable through check.

Retrieve an additional field

Overview

Use the getAdditionalField method to extract information about a specific additional field you set up 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.

fieldCode

Required (string)

 

Field identifier. Alpha-numeric chars, underscores and dashes.

Response

Parameters Type/Description

AdditionalField

Array of objects

Request

<?php
 
require ('PATH_TO_AUTH');

$FieldCode = 'YOUR_FIELD_CODE';
 
try {
    $AdditionalField = $client->getAdditionalField($sessionID, $FieldCode);
}

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

var_dump("AdditionalField", $AdditionalField);


?> 

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