Send payment authentication code

Verify API supports Strong Customer Authentication for payments. To begin the process, supply the customer's telephone number (in E.164 format ), the payee that will receive the payment, and the amount (in Euro) of the transaction, to the PSD2 endpoint.

The Verify API returns a request_id. Use this to identify a specific verification request in subsequent calls to the API, such as when making a check request to see if the user provided the correct code.

Replace the following variables in the sample code with your own values:

Name Description
NEXMO_API_KEY Your Nexmo API key
NEXMO_API_SECRET Your Nexmo API secret
RECIPIENT_NUMBER The phone number to verify
PAYEE Included in the message to describe the payment recipient
AMOUNT How much the payment is for (always in Euro)

Write the code

Add the following to send-psd2-code.sh:

Copy to Clipboard
curl -X POST "https://api.nexmo.com/verify/psd2/json" -d api_key=$NEXMO_API_KEY -d api_secret=$NEXMO_API_SECRET -d number=$RECIPIENT_NUMBER -d payee="$PAYEE" -d amount=$AMOUNT

View full source

Run your code

Save this file to your machine and run it:

sh send-psd2-code.sh

Prerequisites

Install dependencies

npm install nexmo
Initialize your dependencies

Create a file named psd2.js and add the following code:

Copy to Clipboard
const Nexmo = require('nexmo');
const nexmo = new Nexmo({
  apiKey: NEXMO_API_KEY,
  apiSecret: NEXMO_API_SECRET
});

View full source

Write the code

Add the following to psd2.js:

Copy to Clipboard
nexmo.verify.psd2({
  number: RECIPIENT_NUMBER,
  payee: PAYEE,
  amount: AMOUNT
}, (err, result) => {
  if (err) {
    console.error(err);
  } else {
    const verifyRequestId = result.request_id;
    console.log('request_id', verifyRequestId);
  }
});

View full source

Run your code

Save this file to your machine and run it:

node psd2.js

Prerequisites

Install dependencies

Install-Package Nexmo.Csharp.Client
Import dependencies

Create a file named SendPsd2.cs and add the following code:

Copy to Clipboard
using Nexmo.Api;
using Nexmo.Api.Request;
using Nexmo.Api.Verify;

View full source

Initialize your dependencies

Add the following to SendPsd2.cs:

Copy to Clipboard
var creds = Credentials.FromApiKeyAndSecret(NEXMO_API_KEY, NEXMO_API_SECRET);
var client = new NexmoClient(creds);

View full source

Write the code

Add the following to SendPsd2.cs:

Copy to Clipboard
var request = new Psd2Request { Amount = AMOUNT, Payee = PAYEE, Number = RECIPIENT_NUMBER };
var response = client.VerifyClient.VerifyRequestWithPSD2(request);

View full source

Prerequisites

Install dependencies

gem install nexmo
Initialize your dependencies

Create a file named send_psd2_code.rb and add the following code:

Copy to Clipboard
client = Nexmo::Client.new(
  api_key: NEXMO_API_KEY,
  api_secret: NEXMO_API_SECRET
)

View full source

Write the code

Add the following to send_psd2_code.rb:

Copy to Clipboard
response = client.verify.psd2(
  number: TO_NUMBER,
  payee: 'AcmeInc',
  amount: 12.34
)

if response
  # display the Verify PSD2 `request_id`
  puts response.request_id
end

View full source

Run your code

Save this file to your machine and run it:

ruby send_psd2_code.rb