Bank Account Debit (UK)

This page shows you how to charge UK bank accounts using Flutterwave.

Flutterwave allows you charge UK bank accounts in Nigeria, your customer's can input their bank account number and you can charge the account.

The guide below would show you how to charge UK bank accounts on Flutterwave using our APIs.

Pre-requisites for accepting account payments on rave.

  1. Sign-up for an account here .

  2. You can use webhooks to get notified on transactions using the webhook guide .

  3. For all account payments, you would need to implement three steps to the transactions, Initiate payment, Set up webhooks, Verify completed payment.

Step 1: Collect the bank details from the customer

You can use a custom form to collect the bank account details from the customer including extra information needed, see a sample of the bank account details to collect from the customer.

{
       "amount": 20,
    	 "PBFPubKey": "FLWPUBK-4e581ebf8372cd691203b27227e2e3b8-X",
    	 "accountbank": "00000",
    	 "accountnumber": "0000000000",
    	 "payment_type": "account",
    	 "is_uk_bank_charge2": 1,
    	 "currency": "GBP",
    	 "country": "NG",
    	 "email": "[email protected]",
    	 "txRef": "SA-Card-1568348374637758450398",
    	 "meta": [{"metaname": "test", "metavalue": "12383"}],
    	 "ip": "123.0.1.3",
    	 "firstname": "Flutterwave",
    	 "lastname": "Tester"
}

Be sure to supply accurate or test values for all fields depending on your environment.

Parameter Description

ParametersRequiredDescription
PBFPubKeyTrueThis is a unique key generated for each button created on Rave’s dashboard. It starts with a prefix FLWPUBK and ends with suffix X.
accountbankTrueThis represents the bank to be debited.
accountnumberTrueThis is the account number of the customer associated with a valid bank account.
currencyTrue, set to GBP for UK accounts
(Defaults to NGN)
This is the specified currency to charge the account in.
countryFalse
(Defaults to NG)
This is the pair country for the transaction with respect to the currency. See a list of Multicurrency support here Multicurrency Payments ]
amountTrueThis is the amount to be charged from the account it is passed as - (“amount”:10).
emailTrueThis is the email address of the customer.
is_uk_bank_charge2Truevalue: 1
firstnameFalseThis is the first name of the account holder or the customer.
lastnameFalseThis is the last name of the account holder or the customer.
ipFalseIP - Internet Protocol. This represents the current IP address of the customer carrying out the transaction.
txRefTrueThis is the unique reference, unique to the particular transaction being carried out. It is generated by the merchant for every transaction.
payment_typeTrue
(Expected value: account)
This specifies that the payment method being used is for account payments

📘

Get a list of available banks to show to your customers

Make use of the List of Banks API to show your customers what banks are available for this payment method.

Step 2: Encrypt your request

To see how to encrypt using any of our encryption function copy the sample request below and visit the Rave Encryption section.

Step 3: Initiate your payment.

After encryption, the next step is to initiate your payment using the encrypted string by sending a request to the /charge endpoint. See how to do that below.

https://api.ravepay.co/flwv3-pug/getpaidx/api/charge

Sample Request:

curl --request POST \
  --url https://api.ravepay.co/flwv3-pug/getpaidx/api/charge \
  --data '{
    "PBFPubKey": "FLWPUBK-4e581ebf8372cd691203b27227e2e3b8-X",
    "client": "ABLv62BJ94h70rqeA4hj/5y842gljRZO7YmPYPg1v1dB1gzFN6QiF/cmmyvhZWPGjiPrZZL5+hhSVB6xbxbMY5Nl2On/Y2x0fPLc6H7ejrYDcuVyQ4Vj8khYl5TkccpXs8kwh7uNQ43gJClUt8V+0CsmLxZICIYnTkvtWeuxzipF1Ak4BqpN0PFrp0bjsUQJauhn2CS4jBQ4GxUJUQgxAJkW799vH1ML6smmT06yJT20MhDh5gqLgoxkWow09SDi3MmefmCTVnLw5pSUx5tHveF33b0n7QVXUo+SbykjidBQQyxfGhi4eEKO32TYuUXkCAIZWZVMeUUhCyewyOZd1yX74FYBfmWwas2BALynDuDZPU4ny2HbFOIB3x1gNjmVSEytDURxPXydQv6i1kcoNvN3nm0OIvWpKTHF8n5BttA+tMdHW9ci5V+/8J+WlbsvPs0lnexjqo62SApUsyVrfh8EZoaU86CL+pvzqcoSm5hrivPGa2h+PIZAF5fum4Ty2LhDl0HPjzE=",
    "alg": "3DES-24"
}'
{
    "PBFPubKey": "FLWPUBK-4e581ebf8372cd691203b27227e2e3b8-X",
    "client": "ABLv62BJ94h70rqeA4hj/5y842gljRZO7YmPYPg1v1dB1gzFN6QiF/cmmyvhZWPGjiPrZZL5+hhSVB6xbxbMY5Nl2On/Y2x0fPLc6H7ejrYDcuVyQ4Vj8khYl5TkccpXs8kwh7uNQ43gJClUt8V+0CsmLxZICIYnTkvtWeuxzipF1Ak4BqpN0PFrp0bjsUQJauhn2CS4jBQ4GxUJUQgxAJkW799vH1ML6smmT06yJT20MhDh5gqLgoxkWow09SDi3MmefmCTVnLw5pSUx5tHveF33b0n7QVXUo+SbykjidBQQyxfGhi4eEKO32TYuUXkCAIZWZVMeUUhCyewyOZd1yX74FYBfmWwas2BALynDuDZPU4ny2HbFOIB3x1gNjmVSEytDURxPXydQv6i1kcoNvN3nm0OIvWpKTHF8n5BttA+tMdHW9ci5V+/8J+WlbsvPs0lnexjqo62SApUsyVrfh8EZoaU86CL+pvzqcoSm5hrivPGa2h+PIZAF5fum4Ty2LhDl0HPjzE=",
    "alg": "3DES-24"
}
  • client: This is the encrypted request parameters.

  • PBFPubKey: This is your merchant public key.

  • alg: must always be passed as 3DES-24

When you initiate the payment you would get a response that looks like responses below:

{
    "status": "success",
    "message": "V-COMP",
    "data": {
        "data": {
            "amount": "20.00",
            "type": "paymentcode",
            "redirect": false,
            "transaction_date": "2020-02-11T09:02:11.128",
            "transaction_reference": "URF_1581408129731_2597735",
            "flw_reference": "ACH822621581408131130",
            "redirect_url": null,
            "payment_code": "GBPD665AA7",
            "type_data": "GBPD665AA7",
            "meta_data": {
                "account_number": "43271228",
                "sort_code": "040053"
            }
        },
        "response_code": "02",
        "response_message": "Transaction in progress"
    }
}

Some of the important responses you need to check are broken down below:

  • data.status: The status object inside the data object is the right status to check for, possible values are success, fail, pending, success-pending-validation and pending-validation.

  • data.response_code: This is the response code of the transaction, it typically tells you when a transaction is successful with a response code 00 or when the transaction requires validation 02.

  • data.flw_reference: This parameter contains the reference code you can use to verify this transaction

  • data.type: This shows you the payment instrument used i.e. if the customer used a card, account or ussd to complete the payment.

Step 4: Implement Webhooks

It is advised all merchants use webhooks to get automatic updates on their transactions. To set up webhooks please visit the Webhooks section.

Step 5: Verify the payment.

After charging an account successfully, you need to verify that the payment was successful with Flutterwave before giving value to your customer on your website.

Although the Flutterwave's Rave inline already verifies the payment from the client side, we strongly recommend you still do a server side verification to be double sure no foul play occurred during the payment flow.

Below are the important things to check for when validating the payment:

Verify the transaction reference.

Verify the data.status of the transaction to be successful.

Verify the currency to be the expected currency

Most importantly validate the amount paid to be equal to or at least greater than the amount of the value to be given.

Below is sample code of how to implement server side validation in different programming languages

curl --request POST \
  --url https://api.ravepay.co/flwv3-pug/getpaidx/api/v2/verify \
  --header 'content-type: application/json' \
  --data '{"txref":"MC-09182829","SECKEY":"FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X"}'
<?php 

$result = array();

$postdata =  array( 
  'txref' => 'MC-09182829',
  'SECKEY' => 'FLWSECK-bb971402072265fb156e90a3578fe5e6-X'
  );

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.ravepay.co/flwv3-pug/getpaidx/api/v2/verify");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($postdata));  //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [
  'Content-Type: application/json',
];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$request = curl_exec ($ch);
$err = curl_error($ch);

if($err){
	// there was an error contacting rave
  die('Curl returned error: ' . $err);
}


curl_close ($ch);

$result = json_decode($request, true);

if('error' == $result->status){
  // there was an error from the API
  die('API returned error: ' . $result->message);
}

if('successful' == $result->data->status && '00' == $result->data->chargecode){
  // transaction was successful...
  // please check other things like whether you already gave value for this ref
  // If the amount and currency matches the expected amount and currency etc.
  // if the email matches the customer who owns the product etc
  // Give value
}
//Endpoint to verify transaction
    private final String VERIFY_ENDPOINT = "https://api.ravepay.co/flwv3-pug/getpaidx/api/v2/verify"; 
    
    /**
     * 
     * Method to 
     * 
     * @param paymententity - <b>paymententity - set as a constant with default value as 1</b>
     * @param txref - <b>txref - is the unique payment reference generated by the merchant.</b>
     * @param secret - <b>secret - is the merchant secret key</b>
     * @return
     * @throws UnirestException 
     */
    public JSONObject verify(String flwRef, String secret, double amount, int paymententity) throws UnirestException, Exception {
        
        // This packages the payload
        JSONObject data = new JSONObject();
        data.put("txref", txref);
        data.put("SECKEY", secret)
        
        // end of payload
        
        // This sends the request to server with payload
        HttpResponse<JsonNode> response = Unirest.post(VERIFY_ENDPOINT)
                .header("Content-Type", "application/json")
                .body(data)
                .asJson();
        
        // This get the response from payload
        JsonNode jsonNode = response.getBody();
        
        // This get the json object from payload
        JSONObject responseObject = jsonNode.getObject();
        
        // check of no object is returned
        if(responseObject == null)
            throw new Exception("No response from server");
        
        // This get status from returned payload
        String status = responseObject.optString("status", null);
        
        // this ensures that status is not null
        if(status == null)
            throw new Exception("Transaction status unknown");
        
        // This confirms the transaction exist on rave
        if(!"success".equalsIgnoreCase(status)){
            
            String message = responseObject.optString("message", null);
            
            throw new Exception(message);
        }
        
        data = responseObject.getJSONObject("data");
        
        // This get the amount stored on server
        double actualAmount = data.getDouble("amount");
        
        // This validates that the amount stored on client is same returned
        if(actualAmount != amount)
            throw new Exception("Amount does not match");
        
        
        // now you can give value for payment.
       
    }
var data = new {txref = "OH-AAED44", SECKEY = "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X"};
            var client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var responseMessage = client.PostAsJsonAsync("https://api.ravepay.co/flwv3-pug/getpaidx/api/v2/verify", data).Result;
            var responseStr = responseMessage.Content.ReadAsStringAsync().Result;
            var response = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponseData>(responseStr);
            if (response.data.status == "successful" && response.data.amount == amount && response.data.chargecode == "00")
            {
              
              System.Console.WriteLine("Payment Successful then give value");
               
            }

When you successfully verify a completed payment see sample response below:

{
    "status": "success",
    "message": "Tx Fetched",
    "data": {
        "txid": 225422489,
        "txref": "SA-Card-1568348374637758450398",
        "flwref": "ACH555761581427204036",
        "devicefingerprint": "N/A",
        "cycle": "one-time",
        "amount": 20,
        "currency": "GBP",
        "chargedamount": 20,
        "appfee": 0.3,
        "merchantfee": 0,
        "merchantbearsfee": 1,
        "chargecode": "02",
        "chargemessage": "Transaction in progress",
        "authmodel": "AUTH",
        "ip": "123.0.1.3",
        "narration": "Raver",
        "status": "success-pending-validation",
        "vbvcode": "N/A",
        "vbvmessage": "N/A",
        "authurl": "NO-URL",
        "acctcode": null,
        "acctmessage": null,
        "paymenttype": "uk_account",
        "paymentid": "N/A",
        "fraudstatus": "ok",
        "chargetype": "normal",
        "createdday": 2,
        "createddayname": "TUESDAY",
        "createdweek": 7,
        "createdmonth": 1,
        "createdmonthname": "FEBRUARY",
        "createdquarter": 1,
        "createdyear": 2020,
        "createdyearisleap": true,
        "createddayispublicholiday": 0,
        "createdhour": 13,
        "createdminute": 20,
        "createdpmam": "pm",
        "created": "2020-02-11T13:20:02.000Z",
        "customerid": 172016336,
        "custphone": null,
        "custnetworkprovider": "N/A",
        "custname": "Flutterwave Tester",
        "custemail": "[email protected]",
        "custemailprovider": "GMAIL",
        "custcreated": "2020-02-11T13:20:02.000Z",
        "accountid": 48,
        "acctbusinessname": "Raver",
        "acctcontactperson": "Desola Adesina",
        "acctcountry": "NG",
        "acctbearsfeeattransactiontime": 1,
        "acctparent": 1,
        "acctvpcmerchant": "UBANG",
        "acctalias": "raver",
        "acctisliveapproved": 0,
        "orderref": "URF_1581427202469_2712935",
        "paymentplan": null,
        "paymentpage": null,
        "raveref": "RV31581427202438BC79135BEC",
        "meta": [
            {
                "id": 170125260,
                "metaname": "test",
                "metavalue": "12383",
                "createdAt": "2020-02-11T13:20:02.000Z",
                "updatedAt": "2020-02-11T13:20:02.000Z",
                "deletedAt": null,
                "getpaidTransactionId": 225422489
            }
        ]
    }
}