Skip to main content

Add comments to an order

Overview

Use this method to attach a comment when placing a partner order.

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.
comment Required (String)
  A comment visible to both you and the partner.

Response

Parameter Type/Description
Response 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_addProduct'); // addProduct example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/08Place_an_order/00Add_product_to_cart

$comment = 'YOUR_COMMENT';

try {
    $CommentSet= $client->setComment ($sessionID, $comment);
} catch (SoapFault $e) {
    echo " Comment: " . $e->getMessage();
    exit;
}
var_dump ("Comment", $CommentSet);

Errors

Error Description

INVALID_COMMENT

The provided comment is empty.

 

Use SOFORT

Overview

SOFORT is a payment method used primarily in Germany, Austria, Belgium, Switzerland, and The Netherlands. SOFORT supports a direct credit transfer system designed to allow the immediate delivery of goods and services through instant notification and confirmation support.

Currencies

SOFORT supports transactions in EUR and CHF.

Workflow

  1. Shoppers select SOFORT as a payment option in the checkout interface you provide to them.
  2. Create the order object. Use “DIRECT_EBANKING” as the type of the PaymentDetails object.
  3. Use the placeOrder method to send the data to 2Checkout.
  4. Use the PaymentMethod object to create a redirect URL for the shoppers. Using the provided URL, make a request using the provided method (usually a GET request) and add the parameters (located in the Params object) as key-value pairs to the URL of the request.
  5. 2Checkout returns an Order object as the output of the placeOrder method. 
  6. Once you place the order, 2Checkout logs it into the system. At this point in time, the status of the order is PENDING.

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.

See code sample for more details. 

Request sample

<?php
/**
 * Sofort place order SOAP v6.0
 */
$apiVersion = '6.0';
$url = "http://api.avangate.local:8081/soap/".$apiVersion."/";

$sb = "10";
$client = new \SoapClient($url."?wsdl", array('location' => $url, 'cache_wsdl' => WSDL_CACHE_NONE));

// IdAccount 21478
$merchantCode = "120000589445";
$key = "i9u2+w8%s4^5#8%t)A8?";
$productCode = "BDG8899343FE";

$date = gmdate('Y-m-d H:i:s');
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$hash = hash_hmac('md5', $string, $key);
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');
try {
    $sessionID = $client->login($merchantCode, $date, $hash);
} catch (SoapFault $e) {
    echo  'Login error: ' . $e->getMessage();
    die();
}

var_dump("sessionID: ", $sessionID);

$currency = 'EUR';
//$currency = 'USD';

$country = 'DE'; $state = ''; $city = 'Munchen';
//$country = 'US'; $state = 'GA'; $city = 'Atlanta';

$phone = '0049-0130-5529901';

$CartObj = new stdClass();
$CartObj->Currency = $currency;
$CartObj->Language = "EN";
$CartObj->Country = $country;
$CartObj->CountryCode = $country;
$CartObj->CustomerIP = '91.220.121.21';
$CartObj->Source = "sourceAPI.net";

//$CartObj->ExternalReference = "API2.5_PLACE_ORDER_EXT_" . date("Y-m-d h:m:i");
//$CartObj->Affiliate = new stdClass();
//$CartObj->Affiliate->AffiliateCode = 'Partner123'
//$CartObj->Affiliate->AffiliateSource = 'MobilePlatform'
$CartObj->LocalTime = date('Y-m-d H:i:s');
$CartObj->CustomerReference = '421820' . strval(rand (100, 999));
$CartObj->Items = array();

$CartObj->Items[0] = new stdClass();
$CartObj->Items[0]->Code = $productCode;//"3333399999_COPY1";//"155887799"; - vld_licence_1month //"12345"; -vld_regular
$CartObj->Items[0]->Quantity = 1;
//$CartObj->Items[0]->Price = 3;

$CartObj->Items[0]->PriceOptions = [];

$priceOption = new stdClass();
$priceOption->Name = 'Users';
$priceOption->Code = 'USERS_1';
$priceOption->Options = [];

$priceOptionOption = new stdClass();
$priceOptionOption->Name = '10 users';
$priceOptionOption->Value = '10_users';
$priceOptionOption->Surcharge = 0;

$priceOption->Options[] = $priceOptionOption;
$CartObj->Items[0]->PriceOptions[] = $priceOption;

$priceOption2 = new stdClass();
$priceOption2->Name = 'Maintenance period';
$priceOption2->Code = 'MAINTE_PERIOD';
$priceOption2->Options = [];

$priceOptionOption2 = new stdClass();
$priceOptionOption2->Name = '12 months';
$priceOptionOption2->Value = 'jira_maintenance_12_mths';
$priceOptionOption2->Surcharge = 0;

$priceOption2->Options[] = $priceOptionOption2;
$CartObj->Items[0]->PriceOptions[] = $priceOption2;

/**/
$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";

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


$additionalField1 = new stdClass();
$additionalField1->Code = "additional_field_product_1";
$additionalField1->Text = "PRODUCT1 TEXT";
$additionalField1->Value = true;

$CartObj->Items[0]->AdditionalFields = array();
$CartObj->Items[0]->AdditionalFields[0] = $additionalField1;

//$CartObj->Promotions = ["48606DBB"];

$CartObj->MachineId = 'machineIdTestAlexB';
$CartObj->Discount = null;
$CartObj->ExternalReference = null;

$CartObj->BillingDetails = new stdClass();
$CartObj->BillingDetails->IsCompany = false;
//$CartObj->BillingDetails->Company = '';
$CartObj->BillingDetails->Address1 = '37 Mannheim Strasse, A8';
$CartObj->BillingDetails->Address2 = 'floor 3';
$CartObj->BillingDetails->City = $city;
$CartObj->BillingDetails->State = $state;
$CartObj->BillingDetails->CountryCode = $country;
$CartObj->BillingDetails->Phone = $phone;
$CartObj->BillingDetails->Email = 'reinhardt@trashmail.net';
$CartObj->BillingDetails->FirstName = 'Willy';
$CartObj->BillingDetails->LastName = 'Reinhardt';
$CartObj->BillingDetails->Zip = 99234;

/**/
$CartObj->DeliveryDetails = new stdClass();
$CartObj->DeliveryDetails->Address1 = '37 Mannheim Strasse, A8';
$CartObj->DeliveryDetails->Address2 = 'floor 3';
$CartObj->DeliveryDetails->City = $city;
$CartObj->DeliveryDetails->State = $state;
$CartObj->DeliveryDetails->CountryCode = $country;
$CartObj->DeliveryDetails->Phone = $phone;
$CartObj->DeliveryDetails->Email = 'reinhardt@trashmail.net';
$CartObj->DeliveryDetails->FirstName = 'Willy';
$CartObj->DeliveryDetails->LastName = 'Reinhardt';
$CartObj->DeliveryDetails->Zip = 99234;
/**/
$CartObj->PaymentDetails = new stdClass();
$CartObj->PaymentDetails->Type = 'DIRECT_EBANKING';
$CartObj->PaymentDetails->Currency = $currency;
$CartObj->PaymentDetails->CustomerIP = '91.220.121.21';

$CartObj->PaymentDetails->PaymentMethod = new stdClass();
//$CartObj->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$CartObj->PaymentDetails->PaymentMethod->RecurringEnabled = false;
$CartObj->PaymentDetails->PaymentMethod->ReturnURL = 'https://yourreturnurl.com';
$CartObj->PaymentDetails->PaymentMethod->CancelURL= 'https://yourcancelurl.com ';


if ($CartObj->PaymentDetails->Type == 'PREVIOUS_ORDER') {
    $CartObj->ExternalReference ='orderbyref_exteranalref' . $CartObj->PaymentDetails->PaymentMethod->RefNo;
} elseif ($CartObj->PaymentDetails->Type == 'PAYPAL') {
    $CartObj->ExternalReference ='orderbyref_exteranalref_PAYPAL';
}

echo PHP_EOL . 'Request:' . PHP_EOL . json_encode($CartObj, JSON_PRETTY_PRINT) . PHP_EOL;

try {
    $placeOrder = $client->placeOrder($sessionID, $CartObj); // getAvailableCurrencies; getAvailableCountries; getAvailableLanguages; getCheckPaymentDetails
} catch (\SoapFault $e) {
    echo  $e->getMessage();
}

echo 'Encoded response: ' . PHP_EOL . json_encode($placeOrder, JSON_PRETTY_PRINT) . PHP_EOL; 

Response Parameters

Parameter Type/Description

Order information

Object

  Object containing order information.

Response Example

{
    "RefNo": "189897220",
    "OrderNo": 0,
    "ExternalReference": null,
    "ShopperRefNo": null,
    "Status": "PENDING",
    "ApproveStatus": "WAITING",
    "VendorApproveStatus": "OK",
    "MerchantCode": "251772850506",
    "Language": "en",
    "OrderDate": "2022-08-23 14:50:21",
    "FinishDate": null,
    "Source": "testAPI.com",
    "WSOrder": null,
    "Affiliate": {
        "AffiliateCode": null,
        "AffiliateSource": null,
        "AffiliateName": null,
        "AffiliateUrl": null
    },
    "HasShipping": true,
    "BillingDetails": {
        "FiscalCode": null,
        "TaxOffice": null,
        "Phone": "010-6552-9988",
        "FirstName": "John",
        "LastName": "Doe",
        "Company": null,
        "Email": "test@verifone.com",
        "Address1": "Test Address",
        "Address2": null,
        "City": "Test City",
        "Zip": "35005",
        "CountryCode": "de",
        "State": null
    },
    "DeliveryDetails": {
        "Phone": "010-6552-9988",
        "FirstName": "John",
        "LastName": "Doe",
        "Company": null,
        "Email": "test@verifone.com",
        "Address1": "Test Address",
        "Address2": null,
        "City": "Test City",
        "Zip": "35005",
        "CountryCode": "de",
        "State": null
    },
    "PaymentDetails": {
        "Type": "DIRECT_EBANKING",
        "Currency": "eur",
        "PaymentMethod": {
            "Amount": "35.5",
            "Currency": "eur",
            "Redirect": {
                "Url": "https://www.sofortueberweisung.de/payment/start",
                "Method": "POST",
                "Params": {
                    "user_id": "21352",
                    "project_id": "72016",
                    "sender_holder": "",
                    "sender_account_number": "",
                    "sender_bank_code": "",
                    "sender_country_id": "DE",
                    "amount": "35.5",
                    "currency_id": "EUR",
                    "reason_1": "BANKTRANSFER FOR: #189897220",
                    "reason_2": "",
                    "user_variable_0": "189897220",
                    "user_variable_1": 1423,
                    "user_variable_2": "secure.2checkout.com",
                    "user_variable_3": "",
                    "user_variable_4": "",
                    "user_variable_5": "",
                    "hash": "d88e50f1d90e0fc5a7858766db74e3be78e3b7b736d0598161a1a8e6115f4ed8"
                },
                "FullHtml": "<!DOCTYPE html><html><body><form action=\"https://www.sofortueberweisung.de/payment/start\" method=\"POST\" id=\"postform\"><input type=\"hidden\" name=\"user_id\" value=\"21352\" /><input type=\"hidden\" name=\"project_id\" value=\"72016\" /><input type=\"hidden\" name=\"sender_holder\" value=\"\" /><input type=\"hidden\" name=\"sender_account_number\" value=\"\" /><input type=\"hidden\" name=\"sender_bank_code\" value=\"\" /><input type=\"hidden\" name=\"sender_country_id\" value=\"DE\" /><input type=\"hidden\" name=\"amount\" value=\"35.5\" /><input type=\"hidden\" name=\"currency_id\" value=\"EUR\" /><input type=\"hidden\" name=\"reason_1\" value=\"BANKTRANSFER FOR: #189897220\" /><input type=\"hidden\" name=\"reason_2\" value=\"\" /><input type=\"hidden\" name=\"user_variable_0\" value=\"189897220\" /><input type=\"hidden\" name=\"user_variable_1\" value=\"1423\" /><input type=\"hidden\" name=\"user_variable_2\" value=\"secure.2checkout.com\" /><input type=\"hidden\" name=\"user_variable_3\" value=\"\" /><input type=\"hidden\" name=\"user_variable_4\" value=\"\" /><input type=\"hidden\" name=\"user_variable_5\" value=\"\" /><input type=\"hidden\" name=\"hash\" value=\"d88e50f1d90e0fc5a7858766db74e3be78e3b7b736d0598161a1a8e6115f4ed8\" /></form><script type=\"text/javascript\">document.getElementById(\"postform\").submit();</script></body></html>"
            },
            "ReturnURL":https://yourreturnurl.com,
            "CancelURL": https://yourcancelurl.com,
            "Vendor3DSReturnURL": null,
            "Vendor3DSCancelURL": null,
            "InstallmentsNumber": null
        },
        "CustomerIP": "91.220.121.21"
    },
    "DeliveryInformation": {
        "ShippingMethod": {
            "Code": null,
            "TrackingUrl": null,
            "TrackingNumber": null,
            "Comment": null
        }
    },
    "CustomerDetails": null,
    "Origin": "API",
    "AvangateCommission": 2.63,
    "OrderFlow": "REGULAR",
    "GiftDetails": null,
    "PODetails": null,
    "ExtraInformation": null,
    "PartnerCode": null,
    "PartnerMargin": null,
    "PartnerMarginPercent": null,
    "ExtraMargin": null,
    "ExtraMarginPercent": null,
    "ExtraDiscount": null,
    "ExtraDiscountPercent": null,
    "LocalTime": null,
    "TestOrder": false,
    "FxRate": 0.960096,
    "FxMarkup": 4,
    "PayoutCurrency": "USD",
    "DeliveryFinalized": false,
    "Errors": null,
    "Items": [
        {
            "ProductDetails": {
                "Name": "Test Product",
                "ShortDescription": "<p>Join all your clouds in a big one</p>",
                "Tangible": false,
                "IsDynamic": false,
                "ExtraInfo": null,
                "RenewalStatus": false,
                "Subscriptions": null,
                "DeliveryInformation": {
                    "Delivery": "BY_AVANGATE",
                    "DownloadFile": null,
                    "DeliveryDescription": "",
                    "CodesDescription": "",
                    "Codes": []
                }
            },
            "PriceOptions": [],
            "Price": {
                "UnitNetPrice": 29.83,
                "UnitGrossPrice": 35.5,
                "UnitVAT": 5.67,
                "UnitDiscount": 0,
                "UnitNetDiscountedPrice": 29.83,
                "UnitGrossDiscountedPrice": 35.5,
                "UnitAffiliateCommission": 0,
                "ItemUnitNetPrice": null,
                "ItemUnitGrossPrice": null,
                "ItemNetPrice": null,
                "ItemGrossPrice": null,
                "VATPercent": 19,
                "HandlingFeeNetPrice": 0,
                "HandlingFeeGrossPrice": 0,
                "Currency": "eur",
                "NetPrice": 29.83,
                "GrossPrice": 35.5,
                "NetDiscountedPrice": 29.83,
                "GrossDiscountedPrice": 35.5,
                "Discount": 0,
                "VAT": 5.67,
                "AffiliateCommission": 0
            },
            "LineItemReference": "a37ea622e0d0aab958ac08f190842d9b66b42b6c",
            "PurchaseType": "PRODUCT",
            "Code": "LPUJL13OZ6",
            "ExternalReference": "",
            "Quantity": 1,
            "SKU": null,
            "CrossSell": null,
            "Trial": null,
            "AdditionalFields": null,
            "Promotion": null,
            "RecurringOptions": null,
            "SubscriptionStartDate": null,
            "SubscriptionCustomSettings": null,
            "UpSell": null
        }
    ],
    "Promotions": [],
    "AdditionalFields": null,
    "Currency": "eur",
    "NetPrice": 29.83,
    "GrossPrice": 35.5,
    "NetDiscountedPrice": 29.83,
    "GrossDiscountedPrice": 35.5,
    "Discount": 0,
    "VAT": 5.67,
    "AffiliateCommission": 0,
    "CustomParameters": null,
    "Refunds": null
}

For more on how to redirect shoppers to the payment method page to finalize the payment, read here.

Remove product from cart

Overview

Use this method to remove a product that was added to the shopping cart, during the current 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.
productId Required (Integer)
  Unique product identifier from the Avangate system.
priceOptions Optional (StringArray)
 

Array of price options codes. These identifiers mark the individual options inside pricing options configuration groups.

This parameter must match exactly the pricing option combination of the product added to the cart in order for the product to be removed.

 

Partner orders can involve the same product, bot ordered in multiple instances, each with different pricing options.

 

Can be NULL.

quantity Optional (Integer)
  Defines the number of product units added to cart that should be removed. If no quantity info is provided, the product is completely removed from cart. Can be NULL.

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_addProduct'); // addProduct example: https://knowledgecenter.avangate.com/Integration/Channel_Manager_API/SOAP/06Reference/08Place_an_order/00Add_product_to_cart

$productId = 'YOUR_PRODUCT_ID';
$priceOptions = array(
'Pricing_options_group_code1',
'Pricing_options_group_code2'
);
$quantity = YOUR_QUANTITY;

try {
$RemoveProduct= $client->deleteProduct ($sessionID, $productId, $priceOptions, $quantity);
} catch (SoapFault $e) {
echo "ProductDeleted: " . $e->getMessage();
exit;
}
var_dump ("ProductDeleted ", $RemoveProduct);

Errors

Error Description

EMPTY_CART

The shopping cart is empty.

PRODUCT_ERROR

There is no product with the specified settings in cart.

 

Use PayPal

Overview

Place an order using catalog products defined in your Control Panel, and collect the payment using PayPal.

Currency support

Check with Avangate support for a list of currencies available for PayPal. 

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 PayPal rather than PayPal Express, use PAYPAL as the type of the PaymentDetails object and send the shopper email and a return URL as part of the PaymentMethod object. See code sample. 

Workflow

  1. Create the order object. Use PAYPAL as the type of the PaymentDetails object and send the shopper email and a return URL as part of the PaymentMethod object. Place the order.
  2. Once you place the order, Avangate logs it into the system. At this point in time, the status of the order is PENDING. Avangate responds with the Order information object.
  3. Redirect shoppers to the RedirectURL from the Order information object you receive as response from Avangate.
  4. Once shoppers log into their PayPal account and complete the transaction, they're redirected to the ReturnURL you set in the order object. Avangate also authorizes the order and updates the status to AUTHRECEIVED. 

Response

Parameters Type/Description

Order information

Object

  Object containing order information.

 

<?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 = 'Test API';
$Order->BillingDetails->LastName = 'API';
$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 = 'email@avangate.com';
$Order->BillingDetails->Phone = NULL;
$Order->BillingDetails->Company = NULL;
$Order->DeliveryDetails = NULL;

$Order->PaymentDetails = new stdClass ();
$Order->PaymentDetails->Type = 'PAYPAL';
$Order->PaymentDetails->Currency = 'usd';
$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->CustomerIP = '91.220.121.21';
$Order->PaymentDetails->PaymentMethod->ReturnURL = 'http://yoururl.com';
$Order->PaymentDetails->PaymentMethod->Email= 'email@avangate.com';

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

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

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

Retrieve assigned price option groups

Overview

Use the getAssignedPriceOptionGroups method to extract information about the price option groups you assigned to one of your products.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

ProductCode

Required (string)

 

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

Response

Parameters Type/Description

PriceOptionGroup

Array of objects

Request

<?php

require ('PATH_TO_AUTH');
 
$productCode = 'YOUR_PRODUCT_CODE';
 
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getAssignedPriceOptionGroups',
'params' => array($sessionID, $productCode)
);

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

Extract invoices

Overview

Use the getInvoices method to extract shopper invoices from the 2Checkout system based on unique order references. The method returns the binary code for invoices in the PDF file format, Base64 encoded (Base64 is used to represent binary data in the ASCII string format).

getInvoices works for COMPLETE orders for which an invoice was already issued. For refunded orders, getInvoices provides two shopper invoices, one for the original order and the second for the refund, reflecting the repayment made.

In the case of cross-selling orders which contain products from different merchants, getInvoice enables you to re-send only the invoices for your own offerings.

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.

reference

Required (string)

 

Unique, system generated reference for orders.

Response

Parameters Type/Description

InvoicesData

Array of objects

 

 

Details below.

 

Sale

String

 

 

Base64 encoded PDF file containing an invoice for a Complete order.

 

Cancellation

String

 

 

Base64 encoded PDF file containing a cancellation invoice.

 

Refunds

Array of string

 

 

Base64 encoded PDF files containing invoices for Refunds.

Request

<?php

require ('PATH_TO_AUTH');

$reference = 'ORDER_REFERENCE';

try {
    $invoices = $client->getInvoices($sessionID, $reference);
}
catch (SoapFault $e) {
    echo "invoices: " . $e->getMessage();
    exit;
}
var_dump("invoices", $invoices);

 

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;

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

var_dump("newOrder", $newOrder);

Domestic Brazilian credit/debit cards

Overview

2Checkout supports local Brazilian Visa, MasterCard, American Express, Elo, and HiperCard credit/debit cards limited to national purchases in Brazilian Real. Local cards in Brazil account for approximately 50% of all domestic online transactions.

   Payments made with Brazilian cards require shoppers to input a valid phone number and the CPF (Cadastrado de Pessoas Físicas) fiscal code.

Free orders/trials

2Checkout charges customers' cards using local Brazilian Visa and MasterCard credit/debit cards a minimum amount for authorization purposes and will refund the entire value immediately.

Installments

Brazilian customers are able to use installments for online transactions when using Visa, MasterCard, Elo, Hipercard, and American Express. Installments are only available for initial purchases and manual renewals, but not for automatic renewals. 2Checkout offers up to six (6) installments for all Brazilian cards and the minimum amount for an installment is 5 BRL. 2Checkout will split the total costs of an order ensuring that shoppers pay at least 5 BRL for each installment.

Card authorization rates in Brazil

You can push the authorization rate for card purchases in Brazil up to 90% by going 'local'. Brazilian shoppers use credit or debit cards for over 70% of online purchases with 80% of those cards issued by local banks and offering support only for Brazilian Real (R$). The vast majority of transactions involve locally-issued Visa and MasterCard, but Brazilians also use EloHipercard, and American Express for some 15% of card payments.

If you want master card authorization rates in Brazil just look at the graph below.

To summarize, almost 9 out of every 10 transactions with local Brazilian cards authorize successfully, compared to only 3 out of every 10 transactions with international cards. Installments are a key characteristic of the Brazilian payments culture and are also critical in pushing authorization rates to 90%.

Check out the self-service area of your Merchant Control Panel to start collecting revenue from Brazil by enabling your shoppers to use locally-issued cards.

F.A.Q.

  1. What are the supported currencies for domestic BR cards?
    • BRL (Brazilian Real)
  2. Do domestic Brazilian cards support recurring charges?
    • Yes, for one-off transactions.
    • No transactions using installments, but shoppers can manually renew their subscriptions.
  3. How do shoppers choose installments?
    • In the ordering interface, after shoppers select one of the supported domestic cards available for their account, they can choose to pay in full or use installments (from 2 to 6).
  4. What's the minimum amount of an installment?
    • Each installment must be a minimum of 5 BRL.
  5. How am I paid for transactions using installments?
    • 2Checkout pays you the full value of the transaction, minus the commissions you agreed to for your account, regardless of the number of installments (this is covered directly by the banks). 
  6. Why is this important?
    • Authorization rates are much higher on locally issued cards (given the fact that numerous Brazilian credit cards are closed for cross-border transactions) and access to installments is done through a local acquirer.
  7. What is the 2Checkout commission for domestic Brazilian cards?
    • Please contact 2Checkout directly for this information.
  8. Do local BR cards with/without installments require an addendum to my contract?
  9. Do I have to offer installments?
    • No, 2Checkout can set only local cards supporting one-off payments. 
  10. Does lead management work for unfinished payments via local BR cards?
    • 2Checkout sends follow-up emails for failed one-off transactions with local Brazilian cards, but not for installments.
  11. Are refunds supported for local Brazilian cards?
    • Yes. However, only a single either total or partial refund can be issued for each order.

Use Alipay

Overview

Alipay is a third-party online payment solution, allowing customers to make and receive payments on the Internet. Alipay's market share of online payments exceeds 54% in China.

Supported currencies

Alipay supports USD and CNY transactions.

Workflow

  1. Shoppers select Alipay as a payment option in the checkout interface you provide to them.
  2. Create the order object. Use “ALIPAY” as the type of the PaymentDetails object.
  3. Use the placeOrder method to send the data to 2Checkout.
  4. Once you place the order, 2Checkout logs it into the system. At this point, the status of the order is PENDING.
  5. 2Checkout returns an Order object as the output of the placeOrder method. 
  6. Use the Redirect Object in the PaymentMethod object of the response to create a redirect URL for your shoppers. Using the provided URL, make a request using the provided method (usually a GET request) and add the parameters (located in the Params object) as key-value pairs to URL of the request. 

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.

See code sample for more details. 

Request Example 

<?php

require ('PATH_TO_AUTH');

$Order = new stdClass();
$Order->RefNo = NULL;
$Order->Currency = "CNY" ;
$Order->Country = "TW";
$Order->Language = 'EN';
$Order->CustomerIP = '10.5.22.197';
$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 = '67B4EDC822';
$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;
$Order->BillingDetails = new stdClass();
$Order->BillingDetails->IsCompany = false;
$Order->BillingDetails->Address1 = 'Xian Jing Blvd 77';
$Order->BillingDetails->Address2 = 'floor 1';
$Order->BillingDetails->City = 'Shanghai';
$Order->BillingDetails->State = '';
$Order->BillingDetails->CountryCode = 'CN';
$Order->BillingDetails->Phone = '010-6552-9988';
$Order->BillingDetails->Email = 'hujianbing@336699.cn';
$Order->BillingDetails->FirstName = 'Hu';
$Order->BillingDetails->LastName = 'Jianbing';
$Order->BillingDetails->Zip = '334321';


$Order->DeliveryDetails = new stdClass();
$Order->DeliveryDetails->Address1 = 'Xian Jing Blvd 77';
$Order->DeliveryDetails->Address2 = 'floor 1';
$Order->DeliveryDetails->City = 'Shanghai';
$Order->DeliveryDetails->State = $state;
$Order->DeliveryDetails->CountryCode = 'CN';
$Order->DeliveryDetails->Phone = '010-6552-9988';
$Order->DeliveryDetails->Email = 'hujianbing@336699.cn';
$Order->DeliveryDetails->FirstName = 'Hu';
$Order->DeliveryDetails->LastName = 'Jianbing';
$Order->DeliveryDetails->Zip = '334321';

$Order->PaymentDetails->Type = 'ALIPAY';
$Order->PaymentDetails->Currency = "CNY" ;
$Order->PaymentDetails->HadPayPalToken = false;
$Order->PaymentDetails->CustomerIP = '10.5.22.197';

$Order->PaymentDetails->PaymentMethod = new stdClass ();
$Order->PaymentDetails->PaymentMethod->ReturnURL = 'https://yourreturnurl.com';
$Order->PaymentDetails->PaymentMethod->CancelURL= 'https://yourcancelurl.com ';


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

var_dump($Order);

Response Parameters

Parameter Type/Description

Order information

Object

  Object containing order information.

Response Example

{
    "RefNo": "189698901",
    "OrderNo": 0,
    "ExternalReference": null,
    "ShopperRefNo": null,
    "Status": "PENDING",
    "ApproveStatus": "WAITING",
    "VendorApproveStatus": "OK",
    "MerchantCode": "251772850506",
    "Language": "en",
    "OrderDate": "2022-08-23 14:32:21",
    "FinishDate": null,
    "Source": "testAPI.com",
    "WSOrder": null,
    "Affiliate": {
        "AffiliateCode": null,
        "AffiliateSource": null,
        "AffiliateName": null,
        "AffiliateUrl": null
    },
    "HasShipping": true,
    "BillingDetails": {
        "FiscalCode": null,
        "TaxOffice": null,
        "Phone": "010-6552-9988",
        "FirstName": "John",
        "LastName": "Doe",
        "Company": null,
        "Email": "test@verifone.com",
        "Address1": "Test Address",
        "Address2": null,
        "City": "Shanghai",
        "Zip": "35005",
        "CountryCode": "cn",
        "State": null
    },
    "DeliveryDetails": {
        "Phone": "010-6552-9988",
        "FirstName": "John",
        "LastName": "Doe",
        "Company": null,
        "Email": "test@verifone.com",
        "Address1": "Test Address",
        "Address2": null,
        "City": "Shanghai",
        "Zip": "35005",
        "CountryCode": "cn",
        "State": null
    },
    "PaymentDetails": {
        "Type": "ALIPAY",
        "Currency": "cny",
        "PaymentMethod": {
            "Amount": "243",
            "Currency": "cny",
            "Redirect": {
                "Url": "https://intlmapi.alipay.com/gateway.do?_input_charset=utf-8&currency=USD&notify_url=https%3A%2F%2Fsecure.2checkout.com%2Falipay%2Fipn.php&out_trade_no=189698901&partner=2088201540985859&refer_url=1.TEST.MOR.com&return_url=https%3A%2F%2Fsecure.2checkout.com%2Forder%2Fgateway_return.php&rmb_fee=243&service=create_forex_trade&subject=2Checkout%E7%92%81%E3%88%A0%E5%B4%9F+%E9%8D%97%E6%9B%9E%E5%BD%BF%3A+%23189698901&trade_information%5Bbusiness_type%5D=4&trade_information%5Bgoods_info%5D=LPUJL13OZ6%5E1&trade_information%5Btotal_quantity%5D=1&sign=1c6c63019202662f10a96b528f8ee1a4&sign_type=MD5",
                "Method": "GET",
                "Params": {
                    "_input_charset": "utf-8",
                    "currency": "USD",
                    "notify_url": "https://secure.2checkout.com/alipay/ipn.php",
                    "out_trade_no": "189698901",
                    "partner": "2088201540985859",
                    "refer_url": "1.TEST.MOR.com",
                    "return_url": "https://secure.2checkout.com/order/gateway_return.php",
                    "rmb_fee": "243",
                    "service": "create_forex_trade",
                    "subject": "2Checkout璁㈠崟 鍗曞彿: #189698901",
                    "trade_information": {
                        "business_type": "4",
                        "goods_info": "LPUJL13OZ6^1",
                        "total_quantity": "1"
                    },
                    "sign": "1c6c63019202662f10a96b528f8ee1a4",
                    "sign_type": "MD5"
                },
                "FullHtml": "<!DOCTYPE html>\n<html lang=\"EN\"><body><script type=\"text/javascript\">window.location.replace(\"https://intlmapi.alipay.com/gateway.do?_input_charset=utf-8&currency=USD&notify_url=https%3A%2F%2Fsecure.2checkout.com%2Falipay%2Fipn.php&out_trade_no=189698901&partner=2088201540985859&refer_url=1.TEST.MOR.com&return_url=https%3A%2F%2Fsecure.2checkout.com%2Forder%2Fgateway_return.php&rmb_fee=243&service=create_forex_trade&subject=2Checkout%E7%92%81%E3%88%A0%E5%B4%9F+%E9%8D%97%E6%9B%9E%E5%BD%BF%3A+%23189698901&trade_information%5Bbusiness_type%5D=4&trade_information%5Bgoods_info%5D=LPUJL13OZ6%5E1&trade_information%5Btotal_quantity%5D=1&sign=1c6c63019202662f10a96b528f8ee1a4&sign_type=MD5\");</script></body></html>"
            },
            "ReturnURL": https://yourreturnurl.com,
            "CancelURL": https://yourcancelurl.com,
            "RecurringEnabled": false,
            "Vendor3DSReturnURL": null,
            "Vendor3DSCancelURL": null,
            "InstallmentsNumber": null
        },
        "CustomerIP": "91.220.121.21"
    },
    "DeliveryInformation": {
        "ShippingMethod": {
            "Code": null,
            "TrackingUrl": null,
            "TrackingNumber": null,
            "Comment": null
        }
    },
    "CustomerDetails": null,
    "Origin": "API",
    "AvangateCommission": 18,
    "OrderFlow": "REGULAR",
    "GiftDetails": null,
    "PODetails": null,
    "ExtraInformation": null,
    "PartnerCode": null,
    "PartnerMargin": null,
    "PartnerMarginPercent": null,
    "ExtraMargin": null,
    "ExtraMarginPercent": null,
    "ExtraDiscount": null,
    "ExtraDiscountPercent": null,
    "LocalTime": null,
    "TestOrder": false,
    "FxRate": 0.14024803891494,
    "FxMarkup": 4,
    "PayoutCurrency": "USD",
    "DeliveryFinalized": false,
    "Errors": null,
    "Items": [
        {
            "ProductDetails": {
                "Name": "Test Product",
                "ShortDescription": "<p>Join all your clouds in a big one</p>",
                "Tangible": false,
                "IsDynamic": false,
                "ExtraInfo": null,
                "RenewalStatus": false,
                "Subscriptions": null,
                "DeliveryInformation": {
                    "Delivery": "BY_AVANGATE",
                    "DownloadFile": null,
                    "DeliveryDescription": "",
                    "CodesDescription": "",
                    "Codes": []
                }
            },
            "PriceOptions": [],
            "Price": {
                "UnitNetPrice": 243,
                "UnitGrossPrice": 243,
                "UnitVAT": 0,
                "UnitDiscount": 0,
                "UnitNetDiscountedPrice": 243,
                "UnitGrossDiscountedPrice": 243,
                "UnitAffiliateCommission": 0,
                "ItemUnitNetPrice": null,
                "ItemUnitGrossPrice": null,
                "ItemNetPrice": null,
                "ItemGrossPrice": null,
                "VATPercent": 0,
                "HandlingFeeNetPrice": 0,
                "HandlingFeeGrossPrice": 0,
                "Currency": "cny",
                "NetPrice": 243,
                "GrossPrice": 243,
                "NetDiscountedPrice": 243,
                "GrossDiscountedPrice": 243,
                "Discount": 0,
                "VAT": 0,
                "AffiliateCommission": 0
            },
            "LineItemReference": "281d818c9b23daf15405807916e95dac5423d043",
            "PurchaseType": "PRODUCT",
            "Code": "LPUJL13OZ6",
            "ExternalReference": "",
            "Quantity": 1,
            "SKU": null,
            "CrossSell": null,
            "Trial": null,
            "AdditionalFields": null,
            "Promotion": null,
            "RecurringOptions": null,
            "SubscriptionStartDate": null,
            "SubscriptionCustomSettings": null,
            "UpSell": null
        }
    ],
    "Promotions": [],
    "AdditionalFields": null,
    "Currency": "cny",
    "NetPrice": 243,
    "GrossPrice": 243,
    "NetDiscountedPrice": 243,
    "GrossDiscountedPrice": 243,
    "Discount": 0,
    "VAT": 0,
    "AffiliateCommission": 0,
    "CustomParameters": null,
    "Refunds": null
}
Parameter Type/Description

Order information

Object

  Object containing order information.

For more on how to redirect shoppers to the payment method’ page  to finalize the payment, read here.

Retrive a cross-sell campaign

Overview

Use the getProductCrossSellCampaigns method to extract information on all cross-sell campaigns triggered by the same primary 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 unique code of the primary product triggering cross-sell campaign that you can define for each of your offerings.

Response

CrossSellCampaign

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

$ProductCode = 'product_code_custom1';

try {
    $ProductCrossSellCampaigns = $client->getProductCrossSellCampaigns($sessionID, $ProductCode);
}

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

var_dump("ProductCrossSellCampaigns", $ProductCrossSellCampaigns);


?>

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