package com.raveapi.examples.chargecard;
// 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 ChargeCard {
public void chargeCardRave() throws Exception {
HttpResponse < JsonNode > response = Unirest.post("http://flw-pms-dev.eu-west-1.elasticbeanstalk.com/flwv3-pug/getpaidx/api/validate").
header("Content-Type", "application/json").
field("PBFPubKey", "FLWPUBK-e634d14d9ded04eaf05d5b63a0a06d2f-X").
field("transactionreference", 'ACHG-1501266916412').
field("otp", "12345").
asJson(); // passes the request in JSON format.
//do something with response
response.getBody().getObject().toString(2);
}
public static void main(String args[]) throws Exception {
ChargeAccount quidpay = new ChargeAccount();
quidpay.chargeAccountRave();
}
}
var data = new { transactionreference = "ACHG-1501266637278", PBFPubKey = "FLWSECK-e6db11d1f8a6208de8cb2f94e293450e-X", otp = "12345" };
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/validate", 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)
{
System.Console.WriteLine("Perform payment verification check and give value to your customer");
}