How to use 2Checkout Signature Generation API Endpoint
Overview
Before starting to use the 2Checkout Signature Generation API endpoint make sure you read about How to generate a JSON Web Token (JWT) and you have generated your merchant token.
To connect to the 2Checkout Signature Generation API endpoint you need to pass the merchant token to request headers and add the JSON formatted product payload.
Catalog Products Use Cases
Catalog products with lock
Signature parameter(s):
- lock: 1 (boolean, required) – Set TRUE or "1" to lock products.
- products: [] (array, required) – The products array.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"products": [
{
"code": "PRODUCT_CODE_1"
},
{
"code": "PRODUCT_CODE_2"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"products": [
{
"code": "PRODUCT_CODE_1"
},
{
"code": "PRODUCT_CODE_2"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with expiration date and lock
Signature parameter(s):
- lock: 1 (boolean, required) – Set TRUE or "1" to lock products.
- expiration: 1581003962 (string, optional) – Buy-link expiry date. The link becomes invalid after the date of this parameter. Send as a UTC UNIX timestamp.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"expiration": "1893456001",
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"expiration": "1893456001",
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with expiration date and custom price
Signature parameter(s):
- currency: USD (string, required) – Pre-selected billing currency is used to charge your customers.
- expiration: 1581003962 (string, optional) – Buy-link expiry date. The link becomes invalid after the date of this parameter. Send as a UTC UNIX timestamp.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
- products[][custom-price]: {} (object, required) – The products prices for different currencies.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"expiration": "1893456001",
"products": [
{
"code": "PRODUCT_CODE_1",
"custom-price": {
"EUR": 10,
"USD": 8
}
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"expiration": "1893456001",
"products": [
{
"code": "PRODUCT_CODE_1",
"custom-price": {
"EUR": 10,
"USD": 8
}
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with return method parameter
Signature parameter(s):
- return-method[url]: https://www.example.com (string, optional) – URL to which customers are redirected after their finalized purchase.
- return-method[type]: link (string, optional) – The return method used for redirecting your customers after a successful sale. Possible values: link, header.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
Learn more about the redirect URL in this article.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"return-method": {
"url": "https:\/\/www.example.com",
"type": "link"
},
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"return-method": {
"url": "https:\/\/www.example.com",
"type": "link"
},
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with order external reference
Signature parameter(s):
- reference[external][order]: ref-1 (string, required) – Use this parameter to set an external reference to the order.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"reference": {
"external": {
"order": "order_external_reference"
}
},
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"reference": {
"external": {
"order": "order_external_reference"
}
},
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with customer reference
Signature parameter(s):
- reference[customer]: ref-1 (string, required) – Customer numerical (integer) identifier/reference.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
It can be used for new acquisitions aggregating new subscriptions under an existing Customer account.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"reference": {
"customer": "customer_reference"
},
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"reference": {
"customer": "customer_reference"
},
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with external customer reference
Signature parameter(s):
- reference[external][customer]: ref-1 (string, required) – The external customer reference.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"reference": {
"external": {
"customer": "customer_external_reference"
}
},
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"reference": {
"external": {
"customer": "customer_external_reference"
}
},
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with custom parameters
Signature parameter(s):
- custom-parameters: [] (array, required) – The name field for all custom parameters is mandatory.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"custom-parameters": [
{
"name": "custom_param_name",
"value": "custom_param_value"
}
],
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"custom-parameters": [
{
"name": "custom_param_name",
"value": "custom_param_value"
}
],
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with coupons and lock parameter
Signature parameter(s):
- lock: 1 (boolean, required) – Set TRUE or "1" to lock products.
- coupons: [] (array, required) – An array of coupon codes.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"coupons": [
"COUPON-CODE"
],
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"coupons": [
"COUPON-CODE"
],
"products": [
{
"code": "PRODUCT_CODE_1"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with coupons and custom price
Signature parameter(s):
- currency: USD (string, required) – Pre-selected billing currency is used to charge your customers.
- coupons: [] (array, required) – An array of coupon codes.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
- products[][custom-price]: {} (object, required) – The products prices for different currencies.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"coupons": [
"COUPON-CODE"
],
"products": [
{
"code": "PRODUCT_CODE_1",
"custom-price": {
"EUR": 1
}
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"coupons": [
"COUPON-CODE"
],
"products": [
{
"code": "PRODUCT_CODE_1",
"custom-price": {
"EUR": 1
}
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with quantity and lock parameters
Signature parameter(s):
- lock: 1 (boolean, required) – Set TRUE or "1" to lock products.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
- products[][quantity]: integer (integer, required) – The number of units (quantity) for each product in checkout.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"products": [
{
"code": "PRODUCT_CODE_1",
"quantity": 1
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"products": [
{
"code": "PRODUCT_CODE_1",
"quantity": 1
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with quantity and custom price parameters
Signature parameter(s):
- currency: USD (string, required) – Pre-selected billing currency is used to charge your customers.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
- products[][quantity]: integer (integer, required) – The number of units (quantity) for each product in checkout.
- products[][custom-price]: {} (object, required) – The products prices for different currencies.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"products": [
{
"code": "PRODUCT_CODE_1",
"quantity": 1,
"custom-price": {
"EUR": 1
}
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"products": [
{
"code": "PRODUCT_CODE_1",
"quantity": 1,
"custom-price": {
"EUR": 1
}
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with custom options and lock
Signature parameter(s):
- lock: 1 (boolean, required) – Set TRUE or "1" to lock products.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
- products[][options]: {} (object, required) – The product options.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"products": [
{
"code": "PRODUCT_CODE_1",
"options": [
{
"name": "option_name_1",
"value": "option_value2"
}
]
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"lock": 1,
"products": [
{
"code": "PRODUCT_CODE_1",
"options": [
{
"name": "option_name_1",
"value": "option_value2"
}
]
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with custom options and custom price
Signature parameter(s):
- currency: USD (string, required) – Pre-selected billing currency is used to charge your customers.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
- products[][options]: {} (object, required) – The product options.
- products[][custom-price]: {} (object, required) – The products prices for different currencies.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"products": [
{
"code": "PRODUCT_CODE_1",
"options": [
{
"name": "option_name_1",
"value": "option_value2"
}
],
"custom-price": {
"EUR": 1
}
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"products": [
{
"code": "PRODUCT_CODE_1",
"options": [
{
"name": "option_name_1",
"value": "option_value2"
}
],
"custom-price": {
"EUR": 1
}
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Catalog product with custom price
Signature parameter(s):
- currency: USD (string, required) – Pre-selected billing currency is used to charge your customers.
- products[][code]: PRODUCT_CODE_1 (string, required) – The product code.
- products[][price]: {} (object, required) – The product prices for different currencies.
- products[][custom-price]: {} (object, required) – The product custom prices for different currencies.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"products": [
{
"code": "PRODUCT_CODE_1",
"custom-price": {
"EUR": 10,
"USD": 8
}
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"currency": "USD",
"products": [
{
"code": "PRODUCT_CODE_1",
"custom-price": {
"EUR": 10,
"USD": 8
}
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic Products Use Cases
Dynamic products
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Pre-selected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][price]: 10 (integer, required) - The products prices value.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME_1",
"price": 10
},
{
"name": "PRODUCT_NAME_2",
"price": 8
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME_1",
"price": 10
},
{
"name": "PRODUCT_NAME_2",
"price": 8
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic product with product quantity
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Preselected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][quantity]: 1 (integer, required) - The number of units (quantity) for each product in checkout.
- products[][price]: 10 (integer, required) - The products prices value.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME_1",
"quantity": 1,
"price": 10
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME_1",
"quantity": 1,
"price": 10
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic product with options
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Preselected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][price]: 10 (integer, required) - The products prices value.
- products[][options]: [] (array, required) - The product options.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME_1",
"price": 10,
"options": [
{
"name": "option_name_1",
"value": "option_value_1",
"surcharge": 3
}
]
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME_1",
"price": 10,
"options": [
{
"name": "option_name_1",
"value": "option_value_1",
"surcharge": 3
}
]
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic product with price
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Preselected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][price]: 10 (integer, required) - The products prices value.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME",
"price": 10
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME",
"price": 10
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic product with product type
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Preselected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][price]: 10 (integer, required) - The products prices value.
- products[][type]: product (string, required) - The type of dynamic product. Possible values: product, shipping, tax.
If the type parameter is empty or not send, the default line item is considered product.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "TAX_VALUE",
"price": 10,
"type": "tax"
},
{
"name": "SHIPPING_NAME",
"price": 10,
"type": "shipping"
},
{
"name": "PRODUCT_NAME",
"price": 10,
"type": "product"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "TAX_VALUE",
"price": 10,
"type": "tax"
},
{
"name": "SHIPPING_NAME",
"price": 10,
"type": "shipping"
},
{
"name": "PRODUCT_NAME",
"price": 10,
"type": "product"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic product with tangible parameter
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Preselected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][type]: product (string, required) - The type of dynamic product. Possible values: product, shipping, tax.
- products[][price]: 10 (integer, required) - The products prices value.
- products[][tangible]: 1 (boolean, required) - Send TRUE or 1 for products that require physical delivery.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "EUR",
"products": [
{
"name": "TAX_VALUE",
"type": "tax",
"quantity": 1,
"price": 1
},
{
"name": "SHIPPING_NAME",
"type": "shipping",
"quantity": 1,
"price": 1
},
{
"name": "PRODUCT_NAME",
"type": "product",
"quantity": 1,
"price": 1,
"tangible": 1
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "EUR",
"products": [
{
"name": "TAX_VALUE",
"type": "tax",
"quantity": 1,
"price": 1
},
{
"name": "SHIPPING_NAME",
"type": "shipping",
"quantity": 1,
"price": 1
},
{
"name": "PRODUCT_NAME",
"type": "product",
"quantity": 1,
"price": 1,
"tangible": 1
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic product with description
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Preselected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][price]: 10 (integer, required) - The products prices value.
- products[][description]: text... (string, required) - Description is displayed in the checkout page.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"dynamic": "1",
"currency": "USD",
"merchant": "MERCHANT_CODE",
"products": [
{
"name": "PRODUCT_NAME",
"price": 10,
"description": "product description"
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"dynamic": "1",
"currency": "USD",
"merchant": "MERCHANT_CODE",
"products": [
{
"name": "PRODUCT_NAME",
"price": 10,
"description": "product description"
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic product with recurrence, duration and renewal price
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Preselected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][price]: 10 (integer, required) - The products prices value.
- products[][recurrence][length]: 1 (integer, required) - Set product recurring period.
- products[][recurrence][unit]: day (string, required) - Set product recurring unit. Example: day
- products[][duration][length]: 1 (integer, required) - Set the duration of the recurrence period.
- products[][duration][unit]: day (string, required) - Set the duration of the recurrence unit. Example: day
- products[][renewal-price]: 20 (integer, required) - Set the price that should be applied to the renewal order. This parameter is conditioned by two other parameters: duration and renewal-price.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME",
"price": 10,
"recurrence": {
"length": 1,
"unit": "day"
},
"duration": {
"length": 1,
"unit": "day"
},
"renewal-price": 20
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME",
"price": 10,
"recurrence": {
"length": 1,
"unit": "day"
},
"duration": {
"length": 1,
"unit": "day"
},
"renewal-price": 20
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}
Dynamic product with item external reference
Signature parameter(s):
- dynamic: 1 (boolean, required) - Set TRUE or "1" for dynamic products.
- currency: USD (string, required) - Preselected billing currency is used to charge your customers.
- products[][name]: PRODUCT_NAME_1 (string, required) - The name of the dynamic product.
- products[][price]: 10 (integer, required) - The products prices value.
- products[][reference][external][item]: ref-1 (string, required) - Set product identifier for your dynamic products. You can send multiple values separated by semicolon.
cURL
curl -X POST \
https://secure.2checkout.com/checkout/api/encrypt/generate/signature \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg' \
-d '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME",
"price": 10,
"reference": {
"external": {
"item": "item_external_reference"
}
}
}
]
}'
PHP
$curl = curl_init();
$payload = '{
"merchant": "MERCHANT_CODE",
"dynamic": "1",
"currency": "USD",
"products": [
{
"name": "PRODUCT_NAME",
"price": 10,
"reference": {
"external": {
"item": "item_external_reference"
}
}
}
]
}';
curl_setopt_array($curl, [
CURLOPT_URL => "https://secure.2checkout.com/checkout/api/encrypt/generate/signature",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'merchant-token: eyJhbGciOiJIUz.............oXW6ykmEMx7XjGQPTMFg',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response . PHP_EOL;
}
Result
{"signature":"ffff1f2daef1.....................f771ac345efff"}