OTPs

This section covers APIs necessary for creating and managing custom-generated OTPs with FLutterwave.

Create an OTP

This endpoints helps you to generate an OTP via Flutterwave for any validation.

post https://api.flutterwave.com/v3/otps

Body Params

length int32

This is Integer length of the OTP being generated. Expected values are between 5 and 7.

customer object
This is customer object used to include the recipient information.
name string

This is the full name of the recipient of the OTP.

email string

This is the email address of the recipient of the OTP. You should specify this if you intend to send the OTPs to the user's email address.

phone string

This is the phone number of the recipient of the OTP. This is important for sending the OTP via WhatsApp or SMS.

sender string

This is your merchant/business name. It would display when the OTP is sent.

send boolean

Set to true to send otp to customer.

medium string

Pass the medium you want your customers to receive the OTP on. Expected values are sms, email and whatsapp.

expiry int32

Pass an integer value represented in minutes for how long you want the OTP to live for before expiring.

Headers

Authorization string

Pass your secret key as a bearer token in the request header to authorize this call

var axios = require('axios');
var data = JSON.stringify({
  "length": 7,
  "customer": {
    "name": "Flutterwave Developers",
    "email": "developers@flutterwavego.com",
    "phone": "2348000000000"
  },
  "sender": "Flutterwave Inc.",
  "send": true,
  "medium": [
    "email",
    "whatsapp"
  ],
  "expiry": 5
});

var config = {
  method: 'post',
  url: 'https://api.flutterwave.com/v3/otps',
  headers: {
    'Authorization': 'Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X',
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.flutterwave.com/v3/otps',
  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 =>'{
    "length": 7,
    "customer": { "name": "Flutterwave Developers", "email": "developers@flutterwavego.com", "phone": "2348000000000" },
    "sender": "Flutterwave Inc.",
    "send": true,
    "medium": ["email", "whatsapp"],
    "expiry": 5
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
require "uri"
require "json"
require "net/http"

url = URI("https://api.flutterwave.com/v3/otps")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "length": 7,
  "customer": {
    "name": "Flutterwave Developers",
    "email": "developers@flutterwavego.com",
    "phone": "2348000000000"
  },
  "sender": "Flutterwave Inc",
  "send": true,
  "medium": [
    "email",
    "whatsapp"
  ],
  "expiry": 5
})

response = https.request(request)
puts response.read_body
{
    "status": "success",
    "message": "OTP generated successfully",
    "data": [
        {
            "medium": "email",
            "reference": "CF-BARTER-20200616015533756952",
            "otp": "5378980",
            "expiry": "2020-06-16T02:00:33.4426637+00:00"
        },
        {
            "medium": "whatsapp",
            "reference": "CF-BARTER-20200616015533500912",
            "otp": "5378980",
            "expiry": "2020-06-16T02:00:33.6144889+00:00"
        }
    ]
}
{}

Validate an OTP

This section describes how to OTPs generated by the /create endpoint.

post https://api.flutterwave.com/v3/otps/:reference/validate

Path Params

reference string

This is the reference that was returned in the create OTP response.

Body Params

otp int32

This is the One time Pin sent to the user. You are meant to collect this from the user for validation.

Headers

Authorization string

Pass your secret key as a bearer token in the request header to authorize this call

var axios = require('axios');
var data = JSON.stringify({
  "otp": "481208"
});

var config = {
  method: 'post',
  url: 'https://api.flutterwave.com/v3/otps/CF-BARTER-20190420022611377491/validate',
  headers: {
    'Authorization': 'Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X',
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.flutterwave.com/v3/otps/CF-BARTER-20190420022611377491/validate',
  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 =>'{
    "otp": "481208"
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

require "uri"
require "json"
require "net/http"

url = URI("https://api.flutterwave.com/v3/otps/CF-BARTER-20190420022611377491/validate")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "otp": "481208"
})

response = https.request(request)
puts response.read_body
{
  "status": "success",
  "message": "Settlement fetched",
  "data": {
    "id": 41497,
    "account_id": 73362,
    "merchant_name": "Earth Gang",
    "merchant_email": "selma.m0ckaham@flutterwavego.com",
    "settlement_account": "0031318432",
    "bank_code": "063",
    "transaction_date": "2019-12-30T04:00:00.000Z",
    "due_date": "2019-12-30T04:00:00.000Z",
    "processed_date": null,
    "status": "completed",
    "is_local": 1,
    "currency": "NGN",
    "gross_amount": 50800,
    "app_fee": 950,
    "merchant_fee": 0,
    "chargeback": 0,
    "refund": 0,
    "stampduty_charge": 0,
    "net_amount": 49850,
    "transaction_count": 5,
    "processor_ref": null,
    "disburse_ref": "RV3E18675549F6A0",
    "disburse_message": null,
    "channel": "web",
    "destination": "autowallet",
    "fx_data": null,
    "flag_message": null,
    "meta": "[906256,906358,906301,906362,906319]",
    "refund_meta": null,
    "chargeback_meta": null,
    "source_bankcode": null,
    "created_at": "2019-12-31T01:30:00.000Z",
    "transactions": [
      {
        "customer_email": "h0vkard@flw.ext",
        "flw_ref": "FLW-MOCK-RECURR-42b3daee9f470127dacd19560533f3a6",
        "tx_ref": "Rave-Pages017117571060",
        "id": 984411,
        "charged_amount": 10140,
        "app_fee": 190,
        "merchant_fee": 0,
        "stampduty_charge": 0,
        "settlement_amount": 9950,
        "status": "successful",
        "payment_entity": "card",
        "transaction_date": "2019-12-30",
        "currency": "NGN",
        "card_locale": "LOCAL",
        "rrn": "N/A",
        "subaccount_settlement": 0
      },
      {
        "customer_email": "h0vkard@flw.ext",
        "flw_ref": "FLW-MOCK-RECURR-c536481525f02f76409892f517a16300",
        "tx_ref": "Rave-Pages017117571060",
        "id": 984456,
        "charged_amount": 10140,
        "app_fee": 190,
        "merchant_fee": 0,
        "stampduty_charge": 0,
        "settlement_amount": 9950,
        "status": "successful",
        "payment_entity": "card",
        "transaction_date": "2019-12-30",
        "currency": "NGN",
        "card_locale": "LOCAL",
        "rrn": "N/A",
        "subaccount_settlement": 0
      },
      {
        "customer_email": "h0vkard@flw.ext",
        "flw_ref": "FLW-MOCK-RECURR-d22d0ec0955047e9648bec46da40c987",
        "tx_ref": "Rave-Pages017117571060",
        "id": 984474,
        "charged_amount": 10190,
        "app_fee": 190,
        "merchant_fee": 0,
        "stampduty_charge": 0,
        "settlement_amount": 10000,
        "status": "successful",
        "payment_entity": "card",
        "transaction_date": "2019-12-30",
        "currency": "NGN",
        "card_locale": "LOCAL",
        "rrn": "N/A",
        "subaccount_settlement": 0
      },
      {
        "customer_email": "h0vkard@flw.ext",
        "flw_ref": "FLW-MOCK-RECURR-e55f863f14a95816e0939e7c4625ee43",
        "tx_ref": "Rave-Pages017117571060",
        "id": 984513,
        "charged_amount": 10190,
        "app_fee": 190,
        "merchant_fee": 0,
        "stampduty_charge": 0,
        "settlement_amount": 10000,
        "status": "successful",
        "payment_entity": "card",
        "transaction_date": "2019-12-30",
        "currency": "NGN",
        "card_locale": "LOCAL",
        "rrn": "N/A",
        "subaccount_settlement": 0
      },
      {
        "customer_email": "h0vkard@flw.ext",
        "flw_ref": "FLW-MOCK-RECURR-6100e5300876cef2270b2e31bc9cc16e",
        "tx_ref": "Rave-Pages017117571060",
        "id": 984517,
        "charged_amount": 10140,
        "app_fee": 190,
        "merchant_fee": 0,
        "stampduty_charge": 0,
        "settlement_amount": 9950,
        "status": "successful",
        "payment_entity": "card",
        "transaction_date": "2019-12-30",
        "currency": "NGN",
        "card_locale": "LOCAL",
        "rrn": "N/A",
        "subaccount_settlement": 0
      }
    ]
  }
}
{}
Loading...