Transaction Verification

This shows how to perform server side verifications of transactions.

After integrating Quidpay and a user has successfully paid, you need to verify that the payment was successful with Quidpay before giving value to your customer on your website.

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

  1. Verify the transaction reference.

  2. Verify the status of the transaction to be a success.

  3. Verify that a charge response chargeResponse found in response.data.flwMeta has the value 00 or 0.

  4. Verify that the currency is the expected currency to accept payments in.

  5. Most importantly verify 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.

🚧

Performing a status check with your unique reference

On Quidpay it is advised your complete a status check for every transaction using the unique transaction reference (flwRef) generated by the gateway. But if it is absolutely necessary you use your own unique transaction reference to perform a status check, you must adhere to the following criteria:

  1. Ensure your transaction reference is unique for every transaction.
  1. Pass your unique transaction ref to the [xrequery](https://flutterwavedevelopers.readme.io/v1.0/reference#xrequery-transaction-verification) status check endpoint as txref in place of passing the gateway's unique transaction reference (flwref).
<?php 

$result = array();

$postdata =  array( 
  'flw_ref' => 'FLW-MOCK-539111aa99835cbbe028b058d4c9e961',
  'SECKEY' => 'FLWSECK-bb971402072265fb156e90a3578fe5e6-X',
  );

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://flw-pms-dev.eu-west-1.elasticbeanstalk.com/flwv3-pug/getpaidx/api/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 quidpay
  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->flwMeta->chargeResponse){
  // 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
}
package com.raveapi.examples.verify;

// import Unirest packages into your project

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;

// creating a class to handle Unirest Request
public class RaveVerify {
 public void verifyRave() throws Exception {
  HttpResponse < JsonNode > response = Unirest.post("http://flw-pms-dev.eu-west-1.elasticbeanstalk.com/flwv3-pug/getpaidx/api/verify").
  header("Content-Type", "application/json").
  field("flw_ref", "FLW-MOCK-539111aa99835cbbe028b058d4c9e961").
  field("SECKEY", 'FLWSECK-bb971402072265fb156e90a3578fe5e6-X').
  asJson(); // passes the request in JSON format.

  //do something with response
  response.getBody().getObject().toString(2);

 }

 public static void main(String args[]) throws Exception {
  RaveVerify quidpay = new RaveVerify();
  quidpay.verifyRave();
 }
}
var data = new { flw_ref = "FLW-MOCK-baa79d6a6ab92070fab73da392126fe3", SECKEY = "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X", normalize = "1" };
            var client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var responseMessage = client.PostAsJsonAsync("http://flw-pms-dev.eu-west-1.elasticbeanstalk.com/flwv3-pug/getpaidx/api/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 == 2000 && response.data.flwMeta.chargeResponse == "00")
            {
              
              System.Console.WriteLine("Payment Successful then give value");
               
            }