Enable OAuth 2 authentication

Applicable to Obligations API and Issuing API calls. 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 Native Checkout v2 Credentials section within the page:

    Access Credentials

  4. Copy and paste your Native Checkout v2 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 Native Checkout v2 access credentials can be used to generate an access token:

Directly in Postman

Generate access token in Postman

As Base64 value in cURL and PHP

curl -L -X POST 'https://demo-accounts.vivapayments.com/connect/token' \
-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 => 'https://demo-accounts.vivapayments.com/connect/token',
  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": "[access_token]",
    "Expires_in": 3600,
    "Token_type": "Bearer",
    "Scope": "urn:viva:payments:core:api:acquiring urn:viva:payments:core:api:acquiring:cards:tokens urn:viva:payments:core:api:nativecheckoutv2"
}

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:

Postman

Access Credentials

cURL and PHP

curl -L -X POST 'https://demo-api.vivapayments.com/nativecheckout/v2/chargetokens' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer [access_token]' \
--data-raw '{
"cvv": "111",
"amount": 1000,
"number": "5239290700000101",
"holdername": "Joe Blogs",
"expirationYear": 2030,
"expirationMonth": 10,
"sessionRedirectUrl": "www.example.com"
}'

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://demo-api.vivapayments.com/nativecheckout/v2/chargetokens',
  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 =>'{
"cvv": "111",
"amount": 1000,
"number": "5239290700000101",
"holdername": "Joe Blogs",
"expirationYear": 2030,
"expirationMonth": 10,
"sessionRedirectUrl": "www.example.com"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer [access_token]'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;