Skip to content

Card Charge

Abraham Olaobaju edited this page Sep 1, 2023 · 4 revisions

Overview

Direct card charge allows you to charge both local cards (issued in your country of operation) and international cards. This is useful if your customers are predominantly credit/debit card users, and you'd prefer for them to manage payments via your app.

Initiating a Card Charge.

The following implementation shows how to initiate a direct card charge.

require("Flutterwave-Rave-PHP-SDK/lib/CardPayment.php");
use Flutterwave\Card;
    $array = array(
        "PBFPubKey" => "****YOUR**PUBLIC**KEY****",
        "cardno" =>"5438898014560229",
        "cvv" => "890",
        "expirymonth"=> "09",
        "expiryyear"=> "19",
        "currency"=> "NGN",
        "country"=> "NG",
        "amount"=> "2000",
        "pin"=>"3310",
        //"payment_plan"=> "980", //use this parameter only when the payment is a subscription, specify the payment plan id
        "email"=> "eze@gmail.com",
        "phonenumber"=> "0902620185",
        "firstname"=> "temi",
        "lastname"=> "desola",
        "IP"=> "355426087298442",
        "txRef"=>"MC-".time(),// your unique merchant reference
        "meta"=>["metaname"=> "flightID", "metavalue"=>"123949494DC"],
        "redirect_url"=>"https://rave-webhook.herokuapp.com/receivepayment",
        "device_fingerprint"=> "69e6b7f0b72037aa8428b70fbe03986c"
    );
$card = new Card();
$result = $card->cardCharge($array);
print_r($result);

Preath

require("Flutterwave-Rave-PHP-SDK/lib/Preauth.php");
use Flutterwave\Preauth;

$array = array(
"PBFPubKey"=> "FLWPUBK-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-X",
  "cardno"=> "5438898014560229",
  "charge_type"=> "preauth",
  "cvv"=> "812",
  "expirymonth"=> "08",
  "expiryyear"=> "20",
  "currency"=> "NGN",
  "country"=> "NG",
  "amount"=> "100",
  "email"=> "user@example.com",
  "phonenumber"=> "08056552980",
  "firstname"=> "user",
  "lastname"=> "example",
  "IP"=> "40.198.14",
  "txRef"=> "MC-12344358",//must be unique
  "redirect_url"=> "https://rave-web.herokuapp.com/receivepayment",
  "device_fingerprint"=> "69e6b7f0b72037aa8428b70fbe03986c"
);

$payment = new Preauth();
$result = $payment->accountCharge($array);//to charge to card
//$capturePayment = $payment->captureFunds($array);//note the payload ```$array``` for this would be different. refer to documentation //on data to be passed.
//print_r($capturePayment);
//$refundOrVoid = $payment->refundOrVoid($array);
//print_r($refundOrVoid);
print_r($result);

Tokenized

require("Flutterwave-Rave-PHP-SDK/lib/TokenizedCharge.php");
use Flutterwave\TokenizedCharge;

$array = array(
"SECKEY":"FLWSECK-xxxxxxxxxxx-X",
"token":"flw-t1nf-404dff6823ff91ce154f04dd40085b9e-m03k",
"currency":"NGN",
"country":"NG",
"amount":"100",
"email":"user@example.com",
"firstname":"Yemi",
"lastname":"Oyeleke",
"IP":"190.233.222.1",
"narration":"Internet Renewal",
"txRef":"MC_1522966555872",
"meta":""
);

$payment = new TokenizedCharge();
$result = $payment->tokenCharge($array);
//$updateEmailLinkedToToken = $payment->updateEmailTiedToToken($array);//updates email linked to the token
//print_r($updateEmailLinkedToToken);
//$bulkCharge = $payment->bulkCharge($array);//initiate bulk charges
//print_r($bulkCharge);
//$checkBulkStatus = $payment->bulkChargeStatus($array);//checks the status of the bulk charge.
//print_r($checkBulkStatus);
print_r($result);