-
Notifications
You must be signed in to change notification settings - Fork 20
Direct Charge
The charge APIs help you to collect payments using different payment methods.
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.
use Flutterwave\Util\Currency;
$data = [
"amount" => 2000,
"currency" => Currency::NGN,
"tx_ref" => "TEST-".uniqid().time(),
"redirectUrl" => "https://www.example.com",
"additionalData" => [
"subaccounts" => [
["id" => "RSA_345983858845935893"]
],
"meta" => [
"unique_id" => uniqid().uniqid()
],
"preauthorize" => false,
"payment_plan" => null,
"card_details" => [
"card_number" => "5531886652142950",
"cvv" => "564",
"expiry_month" => "09",
"expiry_year" => "32"
]
],
];
$cardpayment = \Flutterwave\Flutterwave::create("card");
$customerObj = $cardpayment->customer->create([
"full_name" => "Olaobaju Abraham",
"email" => "[email protected]",
"phone" => "+234900154861"
]);
$data['customer'] = $customerObj;
$payload = $cardpayment->payload->create($data);
$result = $cardpayment->initiate($payload);
print_r($result);
If you're collecting money in KES, your customers can pay with M-Pesa.
- Create a charge, passing in the customer's mobile number.
- Customer completes the payment by authorising it from their M-Pesa app.
use Flutterwave\Util\Currency;
$data = [
"amount" => 2000,
"currency" => Currency::NGN,
"tx_ref" => uniqid().time(),
"redirectUrl" => "https://google.com"
];
$mpesapayment = \Flutterwave\Flutterwave::create("mpesa");
$customerObj = $mpesapayment->customer->create([
"full_name" => "Olaobaju Jesulayomi Abraham",
"email" => "[email protected]",
"phone" => "+2349067985861"
]);
$data['customer'] = $customerObj;
$payload = $mpesapayment->payload->create($data);
$result = $mpesapayment->initiate($payload);
print_r($result);
Direct charge via bank transfer allows you to generate account details (account number and bank) on demand to receive payments from customers via bank transfer.
$data = [
"amount" => 2000,
"currency" => Currency::NGN,
"tx_ref" => uniqid().time(),
"redirectUrl" => "https://google.com"
];
$btpayment = Flutterwave::create("bank-transfer");
$customerObj = $btpayment->customer->create([
"full_name" => "Olaobaju Jesulayomi Abraham",
"email" => "[email protected]",
"phone" => "+2349067985011"
]);
$data['customer'] = $customerObj;
$payload = $btpayment->payload->create($data);
$result = $btpayment->initiate($payload);
print_r($result);
Direct USSD charge allows you to collect payments via USSD. With USSD charge, you call our API to create a charge, then your customer completes the payment by dialling their bank's USSD code on their mobile phone. Once the payment is completed, we'll notify you via webhook.
use Flutterwave\Util\Currency;
$data = [
"amount" => 2000,
"currency" => Currency::NGN,
"tx_ref" => uniqid().time(),
"redirectUrl" => null,
"additionalData" => [
"account_bank" => "044",
"account_number" => "000000000000"
]
];
$ussdpayment = \Flutterwave\Flutterwave::create("ussd");
$customerObj = $ussdpayment->customer->create([
"full_name" => "Olaobaju Jesulayomi Abraham",
"email" => "[email protected]",
"phone" => "+2349067985861"
]);
$data['customer'] = $customerObj;
$payload = $ussdpayment->payload->create($data);
$result = $ussdpayment->initiate($payload);
Fawry payments are agency-based payments that are initiated by users online to be completed offline. With this payment method, customers can make seamless payments over the counter to a wide range of connected agent networks.
use Flutterwave\Util\Currency;
$data = [
"amount" => 2000,
"currency" => Currency::EGP,
"tx_ref" => uniqid().time(),
"redirectUrl" => "https://example.com"
];
$payment = \Flutterwave\Flutterwave::create("fawry");
$customerObj = $payment->customer->create([
"full_name" => "Olaobaju Jesulayomi Abraham",
"email" => "[email protected]",
"phone" => "+2349060085861"
]);
$data['customer'] = $customerObj;
$payload = $payment->payload->create($data);
$result = $payment->initiate($payload);