Use OAuth 2.0 authentication

Find your Viva Wallet client credentials

  1. Log in to Viva Wallet, demo or live , and select the required account.

  2. Go to Settings > API Access.

  3. Find the Smart Checkout Credentials section: Access Credentials

  4. Copy and paste your Client ID and Client secret to a temporary secure location.

Step 1: Use your client credentials to generate an access token

In the examples below, there are two ways in which the access credentials can be used to generate an access token:

Directly in Postman

Generate access token in Postman

Request example

post    /connect/tokens

Run in Postman

Environment URL
Production https://accounts.vivapayments.com/connect/token
Demo https://demo-accounts.vivapayments.com/connect/token
curl -X POST '[Environment URL]'
-H 'Content-Type: application/x-www-form-urlencoded'
-H 'Authorization: Basic [Base64-encoded Client ID and Client secret]'
--data-urlencode 'grant_type=client_credentials'

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '[Environment URL]',
  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 => 'grant_type=client_credentials',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Authorization: Basic [Base64-encoded Client ID and Client secret]'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response example

{
    "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBEOEZCOEQ2RURFQ0Y1Qzk3RUY1MjdDMDYxNkJCMjMzM0FCNjVGOUZSUzI1NiIsInR5cCI6ImF0K2p3dCI",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "urn:viva:payments:core:api:redirectcheckout"
}

In the above example, four parameters are shown:

Step 2: Use your access token in an API call

In the examples below, there are two ways in which the access token can be used in an API call:

Directly in Postman

Access Credentials

Request example

post    /checkout/v2/orders

Run in Postman

Environment URL
Production https://api.vivapayments.com/checkout/v2/orders
Demo https://demo-api.vivapayments.com/checkout/v2/orders
curl --location --request POST '[environment URL]' \
--header 'Authorization: Bearer [token]' \
--header 'Content-Type: application/json' \
--data-raw '{
  "amount": 1234,
  "customerTrns": "Transaction Details",
  "customer": {
    "email": "example@test.com",
    "fullName": "Customer Name",
    "phone": "Phone Number",
    "countryCode": "GB",
    "requestLang": "en-GB"
  },
  "paymentTimeout": 3600,
  "preauth": false,
  "allowRecurring": false,
  "maxInstallments": 0,
  "paymentNotification": true,
  "tipAmount": 0,
  "disableExactAmount": false,
  "disableCash": false,
  "disableWallet": false,
  "sourceCode": "Default",
  "merchantTrns": "Transaction Details",
  "tags": ["tag 1", "tag 2"]
}'

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '[environment URL]',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "amount": 1234,
  "customerTrns": "Transaction Details",
  "customer": {
    "email": "example@test.com",
    "fullName": "Customer Name",
    "phone": "Phone Number",
    "countryCode": "GB",
    "requestLang": "en-GB"
  },
  "paymentTimeout": 3600,
  "preauth": false,
  "allowRecurring": false,
  "maxInstallments": 0,
  "paymentNotification": true,
  "tipAmount": 0,
  "disableExactAmount": false,
  "disableCash": false,
  "disableWallet": false,
  "sourceCode": "Default",
  "merchantTrns": "Transaction Details",
  "tags": ["tag 1", "tag 2"]
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer [token]',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Get Support

If you have any questions about our solutions, or questions about how to integrate with our solutions, please refer to our Get Support page.