Create a payment order

Applicable only when integrating with our Redirect Checkout solution. The below examples illustrate some simple use cases for creating a payment order.

The below examples use basic auth for authentication.

See also the full-length PHP code sample for creating a payment order.  

Example 1: Create a payment order with only amount defined

Although amount is the only required parameter, we recommend that you also provide email (the customer’s e-mail address), fullName (the customer’s full name), customerTrns (a friendly description to display to the customer, such as a short description of items/services purchased or the customer order code), and requestLang (the language in which the payment form is displayed) parameters as they will encourage high conversion rates (please refer to example 2 below).

If not provided, email and fullName will be requested from the customer; customerTrns will appear empty to the customer, and requestLang will use the default value.

Request example

curl -L -X POST 'https://demo.vivapayments.com/api/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic ZGRiODI1NzktMGI3Zi00NzUyLTk5MTgtNTVlZTJlZTE1NjhkOmhWMVUmRA==' \
--data-raw '{
"amount": 100
}'

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://demo.vivapayments.com/api/orders',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "amount": 100
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic NzJkYjEwYzUtNzk0ZS00NzcwLTliNDEtMzc5NzkyZTQ4YTdmOkoqVE4yeA=='
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Run in Postman

Response example

{
    "OrderCode": 2818450991872607,
    "ErrorCode": 0,
    "ErrorText": null,
    "TimeStamp": "2021-03-29T12:38:38.4509918+03:00",
    "CorrelationId": null,
    "EventId": 0,
    "Success": true
}

Resultant URL for payment page

https://demo.vivapayments.com/web/checkout?ref=[OrderCode]

Payment page screenshot

Payment page of the above URL is opened in a browser:

Payment page example 1

Notice that the payment page appears in the default language of EL given the merchant that created this order is Greek, and that the payment description is empty, while the customer is asked to provide his email and name.

Example 2: Create payment order with amount, customer email, customer name, transaction description and request language defined

Request example

curl -L -X POST 'https://demo.vivapayments.com/api/orders' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic NzJkYjEwYzUtNzk0ZS00NzcwLTliNDEtMzc5NzkyZTQ4YTdmOkoqVE4yeA==' \
--data-raw '{
  "amount": 100,
  "email": "customer@domain.com",
  "fullName": "Customer name",
  "customerTrns": "Short description of items/services purchased to display to your customer",
  "requestLang": "en-GB"
}'

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://demo.vivapayments.com/api/orders',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "amount": 100,
  "email": "customer@domain.com",
  "fullName": "Customer name",
  "customerTrns": "Short description of items/services purchased to display to your customer",
  "requestLang": "en-GB"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic NzJkYjEwYzUtNzk0ZS00NzcwLTliNDEtMzc5NzkyZTQ4YTdmOkoqVE4yeA=='
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Run in Postman

Response example

{
    "OrderCode": 1403426798772601,
    "ErrorCode": 0,
    "ErrorText": null,
    "TimeStamp": "2021-03-29T13:31:43.4267987+03:00",
    "CorrelationId": null,
    "EventId": 0,
    "Success": true
}

Resultant URL for payment page

https://demo.vivapayments.com/web/checkout?ref=[OrderCode]

Payment page screenshot

Payment page of the above URL is opened in a browser:

Payment page example 2