Basic Auth authentication
Basic Auth is the authentication method used for many of Viva's APIs, consisting of a Merchant ID and API Key.
How to authenticate using Basic Auth
Please follow the steps below to authenticate using Basic Auth when using Viva’s APIs:
Step 1: Find your client credentials
With Basic Auth, you pass your (Merchant ID and API Key) credentials in each request to our APIs. Please see here for information on how to locate these credentials.
Step 2: Make API calls using your credentials
You can pass these credentials in one of the following two ways:
In a Base64-encoded header
When you pass your credentials in the header, you must Base64-encode them in the format Merchant_ID:API_Key
. You can then use these encoded values as follows:
Authorization: Basic ZmJmMWUwOTAtNjVkZS00Yzc1LWI1ODAtZDlkOWJjNDk0YWQyOldEdi1WKw==
With a client such as cURL, you pass your encoded credentials in the header with the -H option, as the following example shows:
/api/orders
Environment | URL |
---|---|
Production | https://www.vivapayments.com/api/orders |
Demo | https://demo.vivapayments.com/api/orders |
curl '[Environment URL]'
-H 'Authorization: Basic [Base64-encoded Merchant ID and API key]'
-H 'Content-Type: application/json'
-d '{
"tags": [
"Sample string 1",
"Sample string 2",
"Sample string 3"
],
"email": "customer@domain.com",
"phone": "2117604000",
"fullName": "Customer name",
"paymentTimeOut": 86400,
"requestLang": "en-GB",
"maxInstallments": 12,
"allowRecurring": true,
"isPreAuth": true,
"amount": 100,
"merchantTrns": "Your reference",
"customerTrns": "Short description of items/services purchased to display to your customer"
}'
Running the above from the command line should result in a response containing an order code generated by the Create payment order call from our Payment API.
As parameters in an HTTP call
You can also pass your credentials as parameters in an HTTP call. The following example uses the Postman client:
Under the Authorization tab of your API call, select the Basic Auth option and enter the following credentials:
- Username – your Viva Merchant ID
- Password – your Viva API Key
Get Support
If you would like to integrate with Viva, or if you have any queries about our products and solutions, please see our Contact & Support page to see how we can help!