Skip to main content

Attach PayPal to a subscription

Overview

Use the attachToPayPal method to build the PayPal URL that can be used to attach a subscription to a PayPal account.

Request parameters

Parameters

Type

Required

Description

subscriptionCode

String

Yes

The subscription code that will be attached to the PayPal account.

paypalEmail

String

Yes

The PayPal email associated with the subscription.

returnURL

String

Yes

The URL the user will be redirected to if the subscription is successfully attached to PayPal.

cancelURL

String

Yes

The URL the user will be redirected to if the subscription fails to attach to PayPal.

Request example

<?php


$host = "https://api.2checkout.com";


$merchantCode = "MERCHANT_CODE";
//your account's merchant code available in the 'System settings' area of the cPanel:
//https://secure.2checkout.com/cpanel/account_settings.php

$key = "SECRET_KEY";
//your account's secret key available in the 'System settings' area of the cPanel:
//https://secure.2checkout.com/cpanel/account_settings.php


$now = gmdate('Y-m-d H:i:s'); //GMT date format)
$algo = "sha256";
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash = hash_hmac($algo, $string, $key);

try {
    $client = new SoapClient($host . "/soap/6.0/?wsdl", [
        'location'       => $host . "/soap/6.0/",
        "stream_context" => stream_context_create([
            'ssl' => [
                'verify_peer'      => false,
                'verify_peer_name' => false
            ]
        ])
    ]);
    $sessionID = $client->login($merchantCode, $now, $hash, $algo);
    echo("Auth token: {$sessionID}" . PHP_EOL);

    $subscriptionCode = 'SUBSCRIPTIONCODE';
    $paypalEmail = 'PAYPALEMAIL';
    $returnURL = 'RETURNURL';
    $cancelURL = 'CANCELURL';

   var_dump($res);
} catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage() . PHP_EOL;
   exit;
} catch (Exception $ex) {
   echo $ex->getMessage() . PHP_EOL;
   exit;
}

Response parameters

Parameters

Type

Description

status

String

Can be "success" if no errors occurred or "error" otherwise.

url

String

The PayPal redirect URL if no errors occurred or empty otherwise.

error

Array

Empty if no errors occurred or the error message otherwise.

Error response parameters

Parameters

Type

Description

error_code

String

The error code of the returned exception

message

String

The error message of the returned exception

If the API throws an error, an error response will be received, similar to:

{
    "error_code": "SUBSCRIPTION_PAYPAL_ATTACH_ERR",
    "message": "Failed to link subscription to PayPal account"
}

 

Attach PayPal to a subscription

Overview

Use the attachToPayPal method to build the PayPal URL that can be used to attach a subscription to a PayPal account.

Request parameters

Parameters Type Required Description
subscriptionCode String Yes The subscription code that will be attached to the PayPal account.
paypalEmail String Yes The PayPal email associated with the subscription.
returnURL String Yes The URL the user will be redirected to if the subscription is successfully attached to PayPal.
cancelURL String Yes The URL the user will be redirected to if the subscription fails to attach to PayPal.

Request example

<?php
 
/**
 * @throws JsonException
 */
function callRPC($Request, $host)
{
    $curl = curl_init($host);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Accept: application/json']);
    $RequestString = json_encode($Request, JSON_THROW_ON_ERROR);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);
 
    $ResponseString = curl_exec($curl);
 
    if (!empty($ResponseString)) {
        echo($ResponseString);
        $Response = json_decode($ResponseString, false, 512, JSON_THROW_ON_ERROR);
        if (isset($Response->result)) {
            return $Response->result;
        }
        if (!is_null($Response->error)) {
            echo("Method: {$Request->method}" . PHP_EOL);
            echo("Error: {$Request->error}" . PHP_EOL);
        }
    } else {
        return null;
    }
 
    return null;
}
 
$host = 'https://api.avangate.com/rpc/6.0/';
 
$merchantCode = "MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$key = "SECRET_KEY"; // your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
 
$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$algo = "sha256";
$hash = hash_hmac($algo, $string, $key);
 
$i = 1;
 
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = [$merchantCode, gmdate('Y-m-d H:i:s'), $hash, $algo];
$jsonRpcRequest->id = $i++;
 
try {
    $sessionID = callRPC($jsonRpcRequest, $host);
    echo("Auth token: {$sessionID}" . PHP_EOL);
} catch (JsonException $e) {
    echo("Error: {$e->getMessage()}" . PHP_EOL);
}
 
$subscriptionCode = 'SUBSCRIPTIONCODE';
$paypalEmail = 'PAYPALEMAIL';
$returnURL = 'RETURNURL';
$cancelURL = 'CANCELURL';
 
$jsonRpcRequest = array (
    'method' => 'attachToPayPal',
    'params' => array($sessionID, $subscriptionCode, $paypalEmail, $returnURL, $cancelURL),
    'id' => $i++,
    'jsonrpc' => '2.0');
 
var_dump (callRPC((Object)$jsonRpcRequest, $host, true)); 

Response parameters

Parameters Type Description
status String Can be "success" if no errors occurred or "error" otherwise.
url String The PayPal redirect URL if no errors occurred or empty otherwise.
error Array Empty if no errors occurred or the error message otherwise.

Error response parameters

Parameters

Type

Description

error_code

String

The error code of the returned exception

message

String

The error message of the returned exception

If the API throws an error, an error response will be received, similar to:

{
    "error_code": "SUBSCRIPTION_PAYPAL_ATTACH_ERR",
    "message": "Failed to link subscription to PayPal account"
}

Inline Trials Flow

In order to generate an Inline trial checkout cart, it’s mandatory to have the following parameters in the inline script.

  • Signature: for building a Trial buy link it is required to generate a signature - ConvertPlus Buy-Link Signature for Catalog Products
  • Price (define trial price for the corresponding currency - 0 for free trial, higher than 0 for paid trial)
  • Period (define period – not less than 7 days)
  • Currency (define currency)
  • Product Code (define the product for which the trial is applied)

How your script should look like:

TwoCoInlineCart.cart.setCurrency('EUR');
TwoCoInlineCart.products.add({
                       code: 'ANTV_2016',
                       tperiod: 7,
                       tprices: {EUR: 5, RON: 20},
                  });
TwoCoInlineCart.cart.setSignature('520ba411696e37f1839145bfa793f7199d8d0295a228ea42dc20a3f39196e358');

For more details on parameters setup, check the ConvertPlus URL parameters documentation.

Limitations:

  • the trial period/price applies to a single product
  • the trial period can be a minimum of 7 days
  • 2Checkout uses the custom prices and ignores the per-product pricing configuration
  • supported payment methods: credit and debit cards, PayPal, and Direct Debit
  • 2Checkout automatically converts the trial to a paid subscription when the trial interval expires by charging shoppers based on the payment-on-file information. Customers can opt-out at any time using their myAccount

Use GooglePay

Overview

GooglePay has over 150 million users across 42 global markets using the app each month. The wallet is used on nearly 800.000 websites as a secure payment gateway. Roughly 20% of all mobile purchases are made using this digital payment gateway.

Supported currencies

GooglePay supports EUR, USD, GBP, CHF, DKK, NOK and SEK transactions.

Workflow

  1. Follow the Google Pay Web documentation (https://developers.google.com/pay/api/web/overview) to add a Google Pay button to your web page.
  2. Use 2Checkout's Google merchant ID when building the merchantInfo object.

    {
              "merchantInfo": {
                "merchantId": "BCR2DN6T2OAK7HIW"
              }
            }
  3. Set gateway to verifone and gatewayMerchantId to your 2Checkout's gateway ID found below when building the tokenizationSpecification object.

    {
              "tokenizationSpecification": {
                "type": "PAYMENT_GATEWAY",
                "parameters": {
                  "gateway": "verifone",
                  "gatewayMerchantId": "1ab01f9d-10a6-43fe-9c9e-941798a0813b"
                }
              }
            }
  4. After the shopper authorizes the payment, pass the token from the Google response to Verifone to process the payment. To do this, encode the token to base64 and add it to the placeOrder call payload in the PaymentToken property.

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
declare(strict_types=1);
class Configuration
{
    public const MERCHANT_CODE = 'your_code';
    public const MERCHANT_KEY = 'SECRET_KEY';
    public const URL = 'https://api.2checkout.com/rpc/6.0';
    public const ACTION = 'placeOrder';
    //array or JSON
    public const PAYLOAD =  <<<JSON
{
  "Currency": "usd",
  "Language": "en",
  "Country": "us",
  "Source": "API",
  "Affiliate": {
        "AffiliateCode": "ABCDE1234"
  },
  "Items": [
    {
      "Code": "WP1",
      "Quantity": 2
    }
],
  "BillingDetails": {
    "Address1": "Test Address",
    "City": "LA",
    "State": "California",
    "CountryCode": "US",
    "Email": "testcustomer@2Checkout.com",
    "FirstName": "Customer",
    "LastName": "2Checkout",
    "Zip": "12345"
  },
  "PaymentDetails": {
        "Type": "GOOGLEPAY",
        "Currency": "USD",
        "PaymentMethod": {
            "RecurringEnabled": true,
            "PaymentToken": "eyJzaWduYXR1cmUiOiJNRVlDSVFDVDBrek53RDFpcmRqTlYxZDJXT2k4eFplSDBhdnRwNXFsVWVoejdsenpkd0loQUxYdWlzNlMwNnJPemNZdUVPYW0rb0tiUDZzd3J5K1dMcnA1ajVGRkhialIiLCJpbnRlcm1lZGlhdGVTaWduaW5nS2V5Ijp7InNpZ25lZEtleSI6IntcImtleVZhbHVlXCI6XCJNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUUyZjBxZllRMHZ1OTlzNFlXOUwzZ3RERUZYdW5yMmhhRUdMSTI1Q3ZObkxzMk9tV3FHbW8zSFZHYnVhL1IvamQyWHNWeFFBbFVPdDRzUFBpQ0RMQ3pHQVxcdTAwM2RcXHUwMDNkXCIsXCJrZXlFeHBpcmF0aW9uXCI6XCIxNjkzMjk2NjUzNTAwXCJ9Iiwic2lnbmF0dXJlcyI6WyJNRVVDSVFEQUFPQmJlQXpDWWF4VWVWbmNMekg0L3ZpSGNZTUFrNUU1Z3RUc0NoWGJsZ0lnRi81eDAzM2d2a25kQ1V6WmJVTzJnbjBuZ001cEFWbEZkNXhlNFE2b3pnSVx1MDAzZCJdfSwicHJvdG9jb2xWZXJzaW9uIjoiRUN2MiIsInNpZ25lZE1lc3N"
        }
    }
}
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;
        $algo = 'sha256';
        $hash = hash_hmac($algo, $string, $key);
        return compact('merchantCode', 'date', 'hash', 'algo');
    }
 
    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, $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 Parameters

Parameter Type/Description
Order information Object
Object containing order information.

Response Example

{
    "RefNo": "74980739",
    "OrderNo": 0,
    "ExternalReference": "1692609928",
    "ShopperRefNo": null,
    "Status": "AUTHRECEIVED",
    "ApproveStatus": "WAITING",
    "VendorApproveStatus": "OK",
    "MerchantCode": "uniqueVendorCode123",
    "Language": "en",
    "OrderDate": "2023-08-21 13:26:10",
    "FinishDate": null,
    "Source": "API",
    "WSOrder": null,
    "HasShipping": false,
    "BillingDetails": {
        "FirstName": "John",
        "LastName": "Doe",
        "Company": "Wayne corp",
        "Email": "jhonnydoe@example.com",
        "Address1": "Street 223",
        "Address2": null,
        "City": "Bucharest",
        "Zip": "10460",
        "CountryCode": "ro",
        "State": "Bucharest",
        "FiscalCode": null,
        "TaxOffice": null,
        "Phone": null
    },
    "DeliveryDetails": {
        "FirstName": "John",
        "LastName": "Doe",
        "Company": "Wayne corp",
        "Email": "jhonnydoe@example.com",
        "Address1": "Street 223",
        "Address2": null,
        "City": "Bucharest",
        "Zip": "2002",
        "CountryCode": "ro",
        "State": "Bucharest",
        "Phone": null
    },
    "PaymentDetails": {
        "Type": "GOOGLEPAY",
        "Currency": "usd",
        "CustomerIP": "172.18.0.1"
    },
    "CustomerDetails": null,
    "Origin": "API",
    "AvangateCommission": 0,
    "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": 1,
    "FxMarkup": 0,
    "PayoutCurrency": "USD",
    "DeliveryFinalized": false,
    "Errors": null,
    "Items": [
        {
            "PurchaseType": "PRODUCT",
            "Code": "M5S5M35YX1",
            "ExternalReference": "",
            "Quantity": 1,
            "PriceOptions": [],
            "SKU": null,
            "Price": {
                "Currency": "usd",
                "NetPrice": 10,
                "GrossPrice": 11.9,
                "NetDiscountedPrice": 10,
                "GrossDiscountedPrice": 11.9,
                "Discount": 0,
                "VAT": 1.9,
                "AffiliateCommission": 0,
                "UnitNetPrice": 10,
                "UnitGrossPrice": 11.9,
                "UnitVAT": 1.9,
                "UnitDiscount": 0,
                "UnitNetDiscountedPrice": 10,
                "UnitGrossDiscountedPrice": 11.9,
                "UnitAffiliateCommission": 0,
                "ItemUnitNetPrice": null,
                "ItemUnitGrossPrice": null,
                "ItemNetPrice": null,
                "ItemGrossPrice": null,
                "VATPercent": 19,
                "HandlingFeeNetPrice": 0,
                "HandlingFeeGrossPrice": 0
            },
            "CrossSell": null,
            "Trial": null,
            "AdditionalFields": null,
            "Promotion": null,
            "RecurringOptions": null,
            "SubscriptionStartDate": null,
            "SubscriptionCustomSettings": null,
            "UpSell": null,
            "ProductDetails": {
                "Name": "AntiVirus123Subscription",
                "ShortDescription": "",
                "Tangible": false,
                "IsDynamic": false,
                "ExtraInfo": null,
                "RenewalStatus": false,
                "Subscriptions": null,
                "DeliveryInformation": {
                    "Delivery": "NO_DELIVERY",
                    "DownloadFile": null,
                    "DeliveryDescription": "",
                    "CodesDescription": "",
                    "Codes": []
                }
            },
            "LineItemReference": "2bc911a264d3b92750fbd06363465f408f2a89d8"
        }
    ],
    "Promotions": [],
    "AdditionalFields": null,
    "Currency": "usd",
    "NetPrice": 10,
    "GrossPrice": 11.9,
    "NetDiscountedPrice": 10,
    "GrossDiscountedPrice": 11.9,
    "Discount": 0,
    "VAT": 1.9,
    "AffiliateCommission": 0,
    "CustomParameters": null,
    "Refunds": null,
    "ContainsRenewableProducts": null,
    "RequestDeliveryData": false
}

Use GooglePay

Overview

GooglePay has over 150 million users across 42 global markets using the app each month. The wallet is used on nearly 800.000 websites as a secure payment gateway. Roughly 20% of all mobile purchases are made using this digital payment gateway.

Supported currencies

GooglePay supports EUR, USD, GBP, CHF, DKK, NOK and SEK transactions.

Workflow

  1. Follow the Google Pay Web documentation (https://developers.google.com/pay/api/web/overview) to add a Google Pay button to your web page.
  2. Use 2Checkout's Google merchant ID when building the merchantInfo object.

    {
              "merchantInfo": {
                "merchantId": "BCR2DN6T2OAK7HIW"
              }
            }
  3. Set gateway to verifone and gatewayMerchantId to your 2Checkout's gateway ID found below when building the tokenizationSpecification object.

    {
              "tokenizationSpecification": {
                "type": "PAYMENT_GATEWAY",
                "parameters": {
                  "gateway": "verifone",
                  "gatewayMerchantId": "1ab01f9d-10a6-43fe-9c9e-941798a0813b"
                }
              }
            }
  4. After the shopper authorizes the payment, pass the token from the Google response to Verifone to process the payment. To do this, encode the token to base64 and add it to the placeOrder call payload in the PaymentToken property.

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
declare(strict_types=1);
class Configuration
{
    public const MERCHANT_CODE = 'your_code';  
    public const MERCHANT_KEY = 'SECRET_KEY';
    public const URL = 'https://api.2checkout.com/soap/6.0';
    public const ACTION = 'placeOrder';
    
    public const PAYLOAD =  <<<JSON
{ 
  "Currency": "usd",
  "Language": "en",
  "Country": "us",
  "Source": "API",
  "Affiliate": {
        "AffiliateCode": "ABCDE1234"
  },
  "Items": [
    {
      "Code": "WP1",
      "Quantity": 2
    }
],
  "BillingDetails": {
    "Address1": "Test Address",
    "City": "LA",
    "State": "California",
    "CountryCode": "US",
    "Email": "testcustomer@2Checkout.com",
    "FirstName": "Customer",
    "LastName": "2Checkout",
    "Zip": "12345"
  },
  "PaymentDetails": {
        "Type": "GOOGLEPAY",
        "Currency": "USD",
        "PaymentMethod": {
            "RecurringEnabled": true,
            "PaymentToken": "eyJzaWduYXR1cmUiOiJNRVlDSVFDVDBrek53RDFpcmRqTlYxZDJXT2k4eFplSDBhdnRwNXFsVWVoejdsenpkd0loQUxYdWlzNlMwNnJPemNZdUVPYW0rb0tiUDZzd3J5K1dMcnA1ajVGRkhialIiLCJpbnRlcm1lZGlhdGVTaWduaW5nS2V5Ijp7InNpZ25lZEtleSI6IntcImtleVZhbHVlXCI6XCJNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUUyZjBxZllRMHZ1OTlzNFlXOUwzZ3RERUZYdW5yMmhhRUdMSTI1Q3ZObkxzMk9tV3FHbW8zSFZHYnVhL1IvamQyWHNWeFFBbFVPdDRzUFBpQ0RMQ3pHQVxcdTAwM2RcXHUwMDNkXCIsXCJrZXlFeHBpcmF0aW9uXCI6XCIxNjkzMjk2NjUzNTAwXCJ9Iiwic2lnbmF0dXJlcyI6WyJNRVVDSVFEQUFPQmJlQXpDWWF4VWVWbmNMekg0L3ZpSGNZTUFrNUU1Z3RUc0NoWGJsZ0lnRi81eDAzM2d2a25kQ1V6WmJVTzJnbjBuZ001cEFWbEZkNXhlNFE2b3pnSVx1MDAzZCJdfSwicHJvdG9jb2xWZXJzaW9uIjoiRUN2MiIsInNpZ25lZE1lc3N"
        }
    }
}
JSON;
 
}
class Client
{
    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?object {
        if (is_array($payload)) {
            $payload = json_encode($payload);
        }
        if (!empty($payload)) {
            // SoapClient works with objects(StdClass)
            $payload = json_decode($payload);
        }
        $soapClient = $this->getClient($url);
        $sessionId = $this->getSession($soapClient);
        $args = array_filter([$sessionId, $payload]);
        return $soapClient->$action(...$args);
    }
 
    public function getClient(string $url): SoapClient
    {
        return new SoapClient(
            $url.'?wsdl',
            [
                'location' => $url,
                'cache_wsdl' => WSDL_CACHE_NONE,
            ]
        );
    }
 
    public function getSession(SoapClient $client)
    {
        $date = gmdate('Y-m-d H:i:s');
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $string = strlen($merchantCode).$merchantCode.strlen($date).$date;
        $algo = 'sha256';
        $hash = hash_hmac($algo, $string, $key);
        $client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');
        return $client->login($merchantCode, $date, $hash, $algo);
    }
}
try {
    $client = new Client();
    var_dump($client->call());
} catch (Exception $ex) {
    var_dump($ex);
}

Response Parameters

Parameter Type/Description
Order information Object
Object containing order information.

Response Example

{
    "RefNo": "74980739",
    "OrderNo": 0,
    "ExternalReference": "1692609928",
    "ShopperRefNo": null,
    "Status": "AUTHRECEIVED",
    "ApproveStatus": "WAITING",
    "VendorApproveStatus": "OK",
    "MerchantCode": "uniqueVendorCode123",
    "Language": "en",
    "OrderDate": "2023-08-21 13:26:10",
    "FinishDate": null,
    "Source": "API",
    "WSOrder": null,
    "HasShipping": false,
    "BillingDetails": {
        "FirstName": "John",
        "LastName": "Doe",
        "Company": "Wayne corp",
        "Email": "jhonnydoe@example.com",
        "Address1": "Street 223",
        "Address2": null,
        "City": "Bucharest",
        "Zip": "10460",
        "CountryCode": "ro",
        "State": "Bucharest",
        "FiscalCode": null,
        "TaxOffice": null,
        "Phone": null
    },
    "DeliveryDetails": {
        "FirstName": "John",
        "LastName": "Doe",
        "Company": "Wayne corp",
        "Email": "jhonnydoe@example.com",
        "Address1": "Street 223",
        "Address2": null,
        "City": "Bucharest",
        "Zip": "2002",
        "CountryCode": "ro",
        "State": "Bucharest",
        "Phone": null
    },
    "PaymentDetails": {
        "Type": "GOOGLEPAY",
        "Currency": "usd",
        "CustomerIP": "172.18.0.1"
    },
    "CustomerDetails": null,
    "Origin": "API",
    "AvangateCommission": 0,
    "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": 1,
    "FxMarkup": 0,
    "PayoutCurrency": "USD",
    "DeliveryFinalized": false,
    "Errors": null,
    "Items": [
        {
            "PurchaseType": "PRODUCT",
            "Code": "M5S5M35YX1",
            "ExternalReference": "",
            "Quantity": 1,
            "PriceOptions": [],
            "SKU": null,
            "Price": {
                "Currency": "usd",
                "NetPrice": 10,
                "GrossPrice": 11.9,
                "NetDiscountedPrice": 10,
                "GrossDiscountedPrice": 11.9,
                "Discount": 0,
                "VAT": 1.9,
                "AffiliateCommission": 0,
                "UnitNetPrice": 10,
                "UnitGrossPrice": 11.9,
                "UnitVAT": 1.9,
                "UnitDiscount": 0,
                "UnitNetDiscountedPrice": 10,
                "UnitGrossDiscountedPrice": 11.9,
                "UnitAffiliateCommission": 0,
                "ItemUnitNetPrice": null,
                "ItemUnitGrossPrice": null,
                "ItemNetPrice": null,
                "ItemGrossPrice": null,
                "VATPercent": 19,
                "HandlingFeeNetPrice": 0,
                "HandlingFeeGrossPrice": 0
            },
            "CrossSell": null,
            "Trial": null,
            "AdditionalFields": null,
            "Promotion": null,
            "RecurringOptions": null,
            "SubscriptionStartDate": null,
            "SubscriptionCustomSettings": null,
            "UpSell": null,
            "ProductDetails": {
                "Name": "AntiVirus123Subscription",
                "ShortDescription": "",
                "Tangible": false,
                "IsDynamic": false,
                "ExtraInfo": null,
                "RenewalStatus": false,
                "Subscriptions": null,
                "DeliveryInformation": {
                    "Delivery": "NO_DELIVERY",
                    "DownloadFile": null,
                    "DeliveryDescription": "",
                    "CodesDescription": "",
                    "Codes": []
                }
            },
            "LineItemReference": "2bc911a264d3b92750fbd06363465f408f2a89d8"
        }
    ],
    "Promotions": [],
    "AdditionalFields": null,
    "Currency": "usd",
    "NetPrice": 10,
    "GrossPrice": 11.9,
    "NetDiscountedPrice": 10,
    "GrossDiscountedPrice": 11.9,
    "Discount": 0,
    "VAT": 1.9,
    "AffiliateCommission": 0,
    "CustomParameters": null,
    "Refunds": null,
    "ContainsRenewableProducts": null,
    "RequestDeliveryData": false
}

Electronic delivery of codes upgrade to the SHA algorithm

 

   You only need to follow this procedure if you’re using active lists for your delivery keys. Check this article to learn how to generate the hash algorithm. 
  1. Log into your 2Checkout account.

  2. Navigate to Dashboard > Setup > Fulfillment.

  3. Open an existing dynamic list or add a new code list, selecting the List type Dynamic.

    New code list

  4. Click on Set URL if you’re creating a new list.

    Set URL

  5. If you’re editing an existing dynamic list, click on Change or Debug key generator to modify the hash algorithm.

    change

  6. Select SHA2 or SHA3 as a hashing algorithm.

    Hash algorithm

  7. Select a product and fill in the delivery information form with test data.

    product info

  8. Click on Step 4. Debug >>.

    debug

  9. A successfully green banner is displayed if all is correct. Click on Step 5. Change URL >>.

    change URL

  10. A second confirmation message will be displayed if the change was successfully applied (Successfully saved the key generator URL).

    confirmation message

Buy links upgrade to the SHA algorithm

If you’re using buy links with MD5 hash on your website or in any other part of your flow, you’ll need to re-create the links with SHA2/ SHA3. For more information on how to manually re-create these links check the Buy-link parameters article.

To re-create the “On the fly pricing” buy links with the SHA algorithm, follow the steps below:

  1. Log into your 2Checkout account.

  2. Navigate to Dashboard > Setup > Generate links.

    Generate links screen

  3. Select the purchase flow, the product and click on the On the fly pricing option.

    On the fly pricing option

  4. Select the pricing options and click Generate link. This will generate a link signed with SHA that you can copy and use in your integrations. 

Shopping cart integration upgrade to the SHA algorithm

  SHA3 is already supported for Shopify and Wix and no actions are required.
  1. Locate your plugin in the following list:
  2. Download the latest 2Checkout payment module from GitHub by clicking on the Code button and then on Download ZIP.
  3. Follow the installation instructions listed in the README section of GitHub or in the README file downloaded from the ZIP folder.

  4. After following the installation instructions from GitHub, make sure you have switched your IPN endpoint to SHA. If you have any issues making the switch, follow the instructions for adding the SHA256/3 hash and deselecting the MD5 hash to your webhook URLs.

Webhooks upgrade to the SHA algorithm

 
If you are using shopping cart integration, make sure to follow the instructions from the Shopping cart integration upgrade to the SHA algorithm documentation first.
  1. Log in to your 2Checkout account.
  2. Navigate to Dashboard > Integrations > Webhooks and API.
    Webhooks and API screen
  3. Click on the INS Settings/IPN Settings/LCN Settings tab.
    Depending on your needs, there are several options for making the switch, as shown below

Add a new URL with SHA2/3 hash Recommended

  • Click on Add endpoint.

  • Add the new INS name, and URL and select the hashing algorithm. Then click on Save endpoint.

  • After setting up the URL for the new endpoint, navigate to the trigger list associated with the endpoint and click on Edit to edit the trigger.

edit trigger

  • On the next page, scroll down to the Parameters section, deselect the md5_hash parameter, select the hash parameter, and click on Save trigger.

edit parameter

  • The new INS endpoint with its hashing algorithm will be displayed in the URL list. When you’re ready, remove the old endpoint with MD5 and use only the one with the SHA algorithm.  

  • Optionally, for enhanced security of your webhooks, you can validate the hash received in INS. Click here to learn how. 

new endpoint

  • Click on Add IPN URL.

IPN settings

  • Add the IPN URL and select the hash algorithm.
  • The new IPN URL with its hashing algorithm will be displayed in the URL list. When you’re ready, remove the old endpoint with MD5 and use only the one with the SHA algorithm.

IPN settings sha

This option is suitable for merchants already using the LCN in a production environment and processing orders through the platform.

  • Click on Add LCN URL.

LCN settings

  • Add the LCN URL and select the hash algorithm.
  • The new LCN URL with its hashing algorithm will be displayed in the URL list. When you’re ready, remove the old endpoint with MD5 and use only the one with the SHA algorithm.

LCN settings sha

Keep both the SHA2/SHA3 and MD5 hash

   Prerequisite:
This approach means that you will receive an IPN with multiple hash parameters. Therefore, you will first need to adjust your integration to be able to correctly process the extra hash parameter and respond with the new algorithm. Check this article for some IPN code samples.
  • Click on the Edit button to edit an existing URL corresponding to your default IPN listener.
    Edit IPN hash
  • Select the additional hash algorithm. Click on Save.
    IPN save new hash
  • The changes in the hashing algorithm will be displayed in the URL list.
    IPN new hash URL
  • After you successfully manage to validate the notification using the SHA2/SHA3 hash algorithm, remove the MD5 hash from your endpoint.

This approach might be suitable for merchants that have been selling through the platform and have been using LCNs. This will allow a smooth transition from one hashing algorithm to another, as both will be sent in the LCN until August 15th, 2024.

   Prerequisite:
This approach means that you will receive an LCN with multiple hash parameters. Therefore, you will first need to adjust your integration to be able to correctly process the extra hash parameter and respond with the new algorithm. Check this article for some LCN code samples.
  • Click on the Edit button to edit an existing URL corresponding to your default LCN listener.
    LCN edit URL hash
  • Select the additional hash algorithm. Click on Save.
    LCN select URL hash
  • The changes in the hashing algorithm will be displayed in the URL list.
    LCN new URL hash
  • After you successfully manage to validate the notification using the SHA2/SHA3 hash algorithm, remove the MD5 hash from your endpoint.

Replace the MD5 hash with SHA2/SHA3 

This approach is best if you are using a sandbox environment, or you can afford some service interruption. This is because we will no longer send MD5 hash to this IPN endpoint, and you will need to adapt your integration to support the SHA2/SHA3 algorithm. Check this link for more details.

  • Click on the Edit button to edit an existing endpoint corresponding to your default INS listener.

edit endpoint

  • Selecting any of the SHA algorithms automatically deselects the MD5 hash. Click on Save endpoint.

INS settings sha 1

  • The changes in the hashing algorithm will be displayed in the endpoint list.

new hash

  • After setting up the URL for the new endpoint, navigate to the trigger list associated with the endpoint and click on Edit to edit the trigger.

edit trigger 1

  • On the next page, scroll down to the Parameters section, deselect the md5_hash parameter, select the hash parameter, and click on Save trigger.

edit parameter sha

  • Optionally, for enhanced security of your webhooks, you can validate the hash received in INS. Click here to learn how. 
  • Click on the Edit button to edit an existing URL corresponding to your default IPN listener.

IPN settings sha 3

  • Select the additional hash algorithm and deselect the MD5 hash. Click on Save.

  • The changes in the hashing algorithm will be displayed in the URL list.

IPN settings sha 2

  • Click on the Edit button to edit an existing URL corresponding to your default LCN listener.

LCN settings sha 1

  • Select the additional hash algorithm and deselect the MD5 hash. Click on Save.

LCN settings sha 1

  • The changes in the hashing algorithm will be displayed in the URL list.

LCN settings sha 3

Troubleshooting

Even after upgrading your INS/IPN/LCN webhooks from MD5 to the SHA2/SHA3 algorithm, you can make sure your daily operations are not impacted, by following these steps:

  • Log into your 2Checkout account.
  • Navigate to Dashboard > Reports center > API & Webhooks.

    API & Webhooks

  • Select Webhooks as Event source, IPN (Instant Payment Notification), LNC (License Change Notification), or INS (Instant Notification Service) as Webhooks and Fail as Status. You can also filter your search by INS/IPN/LCN Order reference. Press on Search.

    report settings

    INS troubleshooting 1

  • The failed INS(s)/IPN(s)/LCN(s) will be displayed. Select the Action icon to see more information.

    Action

    INS troubleshooting 2

  • The retry mechanism is only for the failed INS/IPN/LCN. You can see which one failed via the report and request/response details of each webhook.

    info box

    INS troubleshooting 3

  • Additionally, on the order level, you can click on Resend IPN and on the subscription level, you can click on Resend LCN feature in debug mode, to be able to see how your setup behaves:

Resend INS

  • Select the failed webhook and click on Resend. 

    resend ins 1

  • Click on Proceed for the INS webhook to be resent.

resend ins 2

Resend IPN

  • Click on the order number, from the Order reference list.
    order reference list
  • Select Resend notification(s).
    Resend notification(s) IPN
  • Mark the Debug IPN? checkbox and click on Re-send.
    Debug IPN
  • On the debugger you can see why the IPN failed and what hash signature was used.
    IPN debugger
  • Resend LCN

    • Click on the license number, from the License reference list.
      License reference list
    • Select Resend notification(s).
      Resend notification(s) LCN
    • Mark the Debug LCN? checkbox and click on Re-send.
      Debug LCN?
    • On the debugger you can see why the LCN failed and what hash signature was used.
      LCN debugger

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