rutatiina / flutterwave-v3
一个用于集成Flutterwave的Rave支付的简单SDK
Requires
- php: >=5.4.0
- mashape/unirest-php: ^3.0
- monolog/monolog: ^2.0
- vlucas/phpdotenv: ^2.5 || ^3.0 || ^4.0 || ^5.0
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2024-09-05 04:41:26 UTC
README
Flutterwave v3 PHP SDK
使用此库将您的PHP应用程序集成到Rave。
目录
入门
这些说明将帮助您在本地机器上获取项目副本并用于开发和测试目的。有关如何在生产系统上部署项目的说明,请参阅部署。
有关仪表板和API文档的链接,请参阅参考。
编辑paymentForm.php
和processPayment.php
文件以符合您的需求。这两个文件都有良好的文档说明。
只需在浏览器中将页面重定向到paymentForm.php
文件即可处理付款。
安装
已将供应商文件夹提交到项目中,以便于没有安装composer的用户轻松安装。建议使用以下方法更新项目依赖项:
$ composer install flutterwavedev/flutterwave-v3
设置环境变量
创建一个.env文件,并按照.env.example文件的格式进行设置。在.env文件中保存您的PUBLIC_KEY、SECRET_KEY、ENV。
PUBLIC_KEY = "****YOUR**PUBLIC**KEY****" SECRET_KEY = "****YOUR**SECRET**KEY****" ENCRYPTION_KEY = "Encryption key" ENV = "staging or live"
用法
在此实现中,我们期望对此脚本发出表单编码的POST请求。请求将包含以下参数。
- payment_method
可以是卡、账户、两者
- description
您的交易描述
- logo
您的logo URL
- title
您的交易标题
- country
您的交易国家
- currency
您的交易货币
- email
您的客户的电子邮件
- firstname
您的客户的首名
- lastname
您的客户的姓氏
- phonenumber
您的客户的电话号码
- pay_button_text
您喜欢的付款按钮文本
- ref
您的交易参考。每个交易必须唯一。默认情况下,Rave类为每个交易生成唯一的交易参考。仅在此脚本的以下相关部分取消注释后传递此参数。
// Prevent direct access to this class define("BASEPATH", 1); include('library/rave.php'); include('library/raveEventHandlerInterface.php'); use Flutterwave\Rave; use Flutterwave\EventHandlerInterface; $URL = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $getData = $_GET; $postData = $_POST; $publicKey = $_SERVER['PUBLIC_KEY']; $secretKey = $_SERVER['SECRET_KEY']; $success_url = $postData['successurl']; $failure_url = $postData['failureurl']; $env = $_SERVER['ENV']; if($postData['amount']){ $_SESSION['publicKey'] = $publicKey; $_SESSION['secretKey'] = $secretKey; $_SESSION['env'] = $env; $_SESSION['successurl'] = $success_url; $_SESSION['failureurl'] = $failure_url; $_SESSION['currency'] = $postData['currency']; $_SESSION['amount'] = $postData['amount']; } $prefix = 'RV'; // Change this to the name of your business or app $overrideRef = false; // Uncomment here to enforce the useage of your own ref else a ref will be generated for you automatically if($postData['ref']){ $prefix = $postData['ref']; $overrideRef = true; } $payment = new Rave($_SESSION['secretKey'], $prefix, $overrideRef); function getURL($url,$data = array()){ $urlArr = explode('?',$url); $params = array_merge($_GET, $data); $new_query_string = http_build_query($params).'&'.$urlArr[1]; $newUrl = $urlArr[0].'?'.$new_query_string; return $newUrl; }; // This is where you set how you want to handle the transaction at different stages class myEventHandler implements EventHandlerInterface{ /** * This is called when the Rave class is initialized * */ function onInit($initializationData){ // Save the transaction to your DB. } /** * This is called only when a transaction is successful * */ function onSuccessful($transactionData){ // Get the transaction from your DB using the transaction reference (txref) // Check if you have previously given value for the transaction. If you have, redirect to your successpage else, continue // Comfirm that the transaction is successful // Confirm that the chargecode is 00 or 0 // Confirm that the currency on your db transaction is equal to the returned currency // Confirm that the db transaction amount is equal to the returned amount // Update the db transaction record (includeing parameters that didn't exist before the transaction is completed. for audit purpose) // Give value for the transaction // Update the transaction to note that you have given value for the transaction // You can also redirect to your success page from here if($transactionData->chargecode === '00' || $transactionData->chargecode === '0'){ if($transactionData->currency == $_SESSION['currency'] && $transactionData->amount == $_SESSION['amount']){ if($_SESSION['publicKey']){ header('Location: '.getURL($_SESSION['successurl'], array('event' => 'successful'))); $_SESSION = array(); session_destroy(); } }else{ if($_SESSION['publicKey']){ header('Location: '.getURL($_SESSION['failureurl'], array('event' => 'suspicious'))); $_SESSION = array(); session_destroy(); } } }else{ $this->onFailure($transactionData); } } /** * This is called only when a transaction failed * */ function onFailure($transactionData){ // Get the transaction from your DB using the transaction reference (txref) // Update the db transaction record (includeing parameters that didn't exist before the transaction is completed. for audit purpose) // You can also redirect to your failure page from here if($_SESSION['publicKey']){ header('Location: '.getURL($_SESSION['failureurl'], array('event' => 'failed'))); $_SESSION = array(); session_destroy(); } } /** * This is called when a transaction is requeryed from the payment gateway * */ function onRequery($transactionReference){ // Do something, anything! } /** * This is called a transaction requery returns with an error * */ function onRequeryError($requeryResponse){ // Do something, anything! } /** * This is called when a transaction is canceled by the user * */ function onCancel($transactionReference){ // Do something, anything! // Note: Somethings a payment can be successful, before a user clicks the cancel button so proceed with caution if($_SESSION['publicKey']){ header('Location: '.getURL($_SESSION['failureurl'], array('event' => 'canceled'))); $_SESSION = array(); session_destroy(); } } /** * This is called when a transaction doesn't return with a success or a failure response. This can be a timedout transaction on the Rave server or an abandoned transaction by the customer. * */ function onTimeout($transactionReference, $data){ // Get the transaction from your DB using the transaction reference (txref) // Queue it for requery. Preferably using a queue system. The requery should be about 15 minutes after. // Ask the customer to contact your support and you should escalate this issue to the flutterwave support team. Send this as an email and as a notification on the page. just incase the page timesout or disconnects if($_SESSION['publicKey']){ header('Location: '.getURL($_SESSION['failureurl'], array('event' => 'timedout'))); $_SESSION = array(); session_destroy(); } } } if($postData['amount']){ // Make payment $payment ->eventHandler(new myEventHandler) ->setAmount($postData['amount']) ->setPaymentOptions($postData['payment_options']) // value can be card, account or both ->setDescription($postData['description']) ->setLogo($postData['logo']) ->setTitle($postData['title']) ->setCountry($postData['country']) ->setCurrency($postData['currency']) ->setEmail($postData['email']) ->setFirstname($postData['firstname']) ->setLastname($postData['lastname']) ->setPhoneNumber($postData['phonenumber']) ->setPayButtonText($postData['pay_button_text']) ->setRedirectUrl($URL) // ->setMetaData(array('metaname' => 'SomeDataName', 'metavalue' => 'SomeValue')) // can be called multiple times. Uncomment this to add meta datas // ->setMetaData(array('metaname' => 'SomeOtherDataName', 'metavalue' => 'SomeOtherValue')) // can be called multiple times. Uncomment this to add meta datas ->initialize(); }else{ if($getData['cancelled'] && $getData['tx_ref']){ // Handle canceled payments $payment ->eventHandler(new myEventHandler) ->requeryTransaction($getData['tx_ref']) ->paymentCanceled($getData['tx_ref']); }elseif($getData['tx_ref']){ // Handle completed payments $payment->logger->notice('Payment completed. Now requerying payment.'); $payment ->eventHandler(new myEventHandler) ->requeryTransaction($getData['tx_ref']); }else{ $payment->logger->warn('Stop!!! Please pass the txref parameter!'); echo 'Stop!!! Please pass the txref parameter!'; } }
账户收费
以下实现展示了如何发起直接银行收费。使用Playground目录查看响应和使用示例。
require("Flutterwave-Rave-PHP-SDK/library/AccountPayment.php"); use Flutterwave\Account; //The data variable holds the payload $data = array( "amount" => "3000", "type" => "debit_ng_account",//debit_ng_account or debit_uk_account "account_bank" => "044", "account_number" => "0690000037", "currency" => "NGN",//NGN or GBP "email" => "olaobajua@gmail.com", "phone_number" => "07067965809", "fullname" => "Olaobaju Abraham", "client_ip" => "154.123.220.1", "device_fingerprint" => "62wd23423rq324323qew1", "meta" => [ "flightID" => "213213AS" ] ); $payment = new Account(); $result = $payment->accountCharge($data); if(isset($result['data'])){ $id = $result['data']['id']; $verify = $payment->verifyTransaction($id); } print_r($result);
ACH收费
以下实现展示了如何直接从美国和南非的客户那里接受付款。使用Playground目录查看响应和使用示例。
require("Flutterwave-Rave-PHP-SDK/library/AchPayment.php"); use Flutterwave\Ach; //The data variable holds the payload $data = array( "tx_ref" => "MC-1585230ew9v5050e8", "amount" => "100", "type" => "ach_payment", "currency" => "USD", "country" => "US", "email" => "ekene@gmail.com", "phone_number" => "0902620185", "fullname" => "Ekene Eze", "redirect_url" => "http://ekene.com/u/payment-completed", ); $payment = new Ach(); $result = $payment->achCharge($data); if(isset($result['data'])){ $id = $result['data']['id']; $verify = $payment->verifyTransaction($id); } print_r($result);
卡收费
以下实现展示了如何发起卡收费。使用Playground目录查看实现响应和使用示例。
require("Flutterwave-Rave-PHP-SDK/library/CardPayment.php"); use Flutterwave\Card; //The data variable holds the payload $data = array( "card_number"=> "5531886652142950", "cvv"=> "564", "expiry_month"=> "09", "expiry_year"=> "22", "currency"=> "NGN", "amount" => "1000", "fullname"=> "Ekene Eze", "email"=> "ekene@flw.com", "phone_number"=> "0902620185", "fullname" => "temi desola", //"tx_ref"=> "MC-3243e",// should be unique for every transaction "redirect_url"=> "https://webhook.site/3ed41e38-2c79-4c79-b455-97398730866c", ); $payment = new Card(); $res = $payment->cardCharge($data);//This call is to figure out the authmodel $data['authorization']['mode'] = $res['meta']['authorization']['mode']; if($res['meta']['authorization']['mode'] == 'pin'){ //Supply authorization pin here $data['authorization']['pin'] = '3310'; } if($res['meta']['authorization']['mode'] == 'avs_noauth'){ //supply avs details here $data["authorization"] = array( "mode" => "avs_noauth", "city"=> "Sampleville", "address"=> "3310 sample street ", "state"=> "Simplicity", "country"=> "Simple", "zipcode"=> "000000", ); } $result = $payment->cardCharge($data);//charge with new fields // print_r($result);//this returns the an array if($result['data']['auth_mode'] == 'otp'){ $id = $result['data']['id']; $flw_ref = $result['data']['flw_ref']; $otp = '12345'; $validate = $payment->validateTransaction($otp,$flw_ref);// you can print_r($validate) to see the response $verify = $payment->verifyTransaction($id); }
移动货币支付
以下实现展示了如何发起移动货币支付。使用Playground目录查看响应和使用示例。
require("Flutterwave-Rave-PHP-SDK/library/MobileMoney.php"); use Flutterwave\MobileMoney; //The data variable holds the payload $data = array( "order_id" => "USS_URG_89245453s2323", "amount" => "1500", "type" => "mobile_money_rwanda",// could be mobile_money_rwanda,mobile_money_uganda, mobile_money_zambia, mobile_money_ghana "currency" => "RWF", "email" => "ekene@flw.com", "phone_number" => "054709929220", "fullname" => "John Madakin", "client_ip" => "154.123.220.1", "device_fingerprint" => "62wd23423rq324323qew1", "meta" => [ "flightID" => "213213AS" ] ); $payment = new MobileMoney(); $result = $payment->mobilemoney($data); $id = $result['data']['id']; $verify = $payment->verifyTransaction($id); $print_r($result);
USSD
通过USSD收集付款
require("Flutterwave-Rave-PHP-SDK/library/Ussd.php"); use Flutterwave\Ussd; //The data variable holds the payload $data = array( "tx_ref" => "MC-15852309v5050e8", "account_bank" => "058", "amount" => "1500", "currency" =>"NGN", "email" =>"user@gmail.com", "phone_number" =>"054709929220", "fullname" => "John Madakin", ); $payment = new Ussd(); $result = $payment->ussd($data);//initiates the charge echo 'Dial '.$result['meta']['authorization']['note'].' to authorize your transaction'; //A webhook notification would be sent to you.... if(isset($result['data'])){ $id = $result['data']['id']; $verify = $payment->verifyTransaction($id); }
Mpesa
通过Mpesa从您的客户那里收集付款。
require("Flutterwave-Rave-PHP-SDK/library/Mpesa.php"); use Flutterwave\Mpesa; $data = array( "amount" => "1500", "type" => "mpesa", "currency" => "KES", "email" => "ekene@flw.com", "phone_number" => "054709929220", "fullname" => "Ekene Eze", "client_ip" => "154.123.220.1", "device_fingerprint" => "62wd23423rq324323qew1", "meta" => [ "flightID" => "213213AS" ] ); $payment = new Mpesa(); $result = $payment->mpesa($data); print_r($result); if(isset($result['data'])){ $id = $result['data']['id']; $verify = $payment->verifyTransaction($id); }
转账实现
如何进行转账支付
require("Flutterwave-Rave-PHP-SDK/library/Transfer.php"); use Flutterwave\Transfer; //sample payload for payBill() $data = array( "account_bank"=> "044", "account_number"=> "0690000040", "amount"=> 5500, "narration"=> "Akhlm Pstmn Trnsfr xx007", "currency"=> "NGN", "reference"=> "akhlm-pstmnpyt-rfxx007_PMCKDU_1",// read the docs about testing successful and failed transaction. "callback_url"=> "https://webhook.site/b3e505b0-fe02-430e-a538-22bbbce8ce0d", "debit_currency"=> "NGN" ); //sample payload for bulkBill() $bulkdata = array( "title"=> "Staff salary", "bulk_data"=> array( array( "bank_code"=> "044", "account_number"=> "0690000032", "amount"=> 45000, "currency"=> "NGN", "narration"=> "akhlm blktrnsfr", "reference"=> "akhlm-blktrnsfr-xx03" ), array( "bank_code"=> "044", "account_number"=> "0690000034", "amount"=> 5000, "currency"=> "NGN", "narration"=> "akhlm blktrnsfr", "reference"=> "akhlm-blktrnsfr-xy03" )) ); $getdata = array( //"reference"=>"edf-12de5223d2f32434753432" "id"=>"BIL136", "product_id"=>"OT150" ); $listdata = array( 'status'=>'failed' ); $feedata = array( 'currency'=> 'NGN', //if currency is omitted. the default currency of NGN would be used. 'amount'=> 1000 ); $payment = new Transfer(); $result = $payment->singleTransfer($data);//initiate single transfer payment $createBulkTransfer = $payment->bulkTransfer($bulkdata);// get bulk result.... $transfers = $payment->listTransfers($listdata);//you can add a payload for the page. you can remove the array if want to get it all. $getTransferFee = $payment->getTransferFee($feedata); if(isset($result['data'])){ $id = $result['data']['id']; $verify = $payment->verifyTransaction($id); }
虚拟卡
以下实现展示了如何在Rave上创建虚拟卡。使用Playground目录查看响应和使用示例。
require("Flutterwave-Rave-PHP-SDK/library/VirtualCards.php"); use Flutterwave\VirtualCard; $data = array( "currency"=>"NGN", "amount"=>20000, "billing_name"=>"Jermaine Graham", "billing_address"=>"2014 Forest Hills Drive", "billing_city"=>"Node", "billing_state"=>"Javascript", "billing_postal_code"=>"000009", "billing_country"=>"NG", "callback_url"=>"https://webhook.site/96374895-154d-4aa0-99b5-709a0a128674" ); $trns_data = array('id'=> 'a41de883-c8da-45a0-9b23-37780c88285f'); $getCardData = array('id'=>'7a81d279-a07a-4775-a55a-5fa2c98e20ae'); $terminate_data = array('id'=>'1cb36826-8e05-40d6-8b9e-7f7439a141cb'); $fund_data = array('id'=>'1cb36826-8e05-40d6-8b9e-7f7439a141cb', 'amount'=>'2000', 'debit_currency'=>'NGN'); $withdraw_data = array('id'=>'1cb36826-8e05-40d6-8b9e-7f7439a141cb', 'amount'=>'500'); $blockCard_data = array('id' => '1cb36826-8e05-40d6-8b9e-7f7439a141cb', 'status_action'=>'block'); $card = new VirtualCard(); $createCard = $card->createCard($data);//initiates the charge $getCard = $card->getCard($getCardData); $getCards = $card->listCards(); $terminate = $card->terminateCard($terminate_data); $fund = $card->fundCard($fund_data); $transactions = $card->cardTransactions($trns_data); $withdraw = $card->cardWithdrawal($withdraw_data); $block_unblock = $card->block_unblock_card($blockCard_data); print_r($createCard);
BVN验证
以下实现展示了如何验证银行验证码。
require("Flutterwave-Rave-PHP-SDK/library/Bvn.php"); use Flutterwave\Bvn; //The data variable holds the payload $bvn_number = "123456789"; $bvn = new Bvn(); $result = $bvn->verifyBVN($bvn_number); print_r($result);
付款计划
以下实现展示了如何在Rave仪表板上创建付款计划。使用Playground目录查看响应和使用示例。
require("Flutterwave-Rave-PHP-SDK/library/PaymentPlan.php"); use Flutterwave\PaymentPlan; //sample payload for payBill() $data = array( "amount"=> 2000, "name"=> "plan 2", "interval"=> "monthly", "duration"=> 48 ); $update = array( "id" => "5356","name" => "The Game","status" => "Active"); $getdata = array("id"=>"5116"); $payment = new PaymentPlan(); $result = $payment->createPlan($data);//create a Plan reciept $updateResult = $payment->updatePlan($update);//update a plan.... $paymentPlans = $payment->getPlans();//list all payment plans.... $aPlan = $payment->get_a_plan($getdata);//get a payment plans.... print_r($result);
子账户管理
以下实现展示了如何在Rave仪表板上创建子账户。使用游乐场目录查看响应和使用示例。
require("Flutterwave-Rave-PHP-SDK/library/Subaccount.php"); use Flutterwave\Subaccount; $data = array( "account_bank"=> "044", "account_number"=> "0690000037", "business_name"=> "Eternal Blue", "business_email"=> "petya@stux.net", "business_contact"=> "Anonymous", "business_contact_mobile"=> "090890382", "business_mobile"=> "09087930450", "country"=> "NG", "meta"=> array( array( "meta_name"=> "mem_adr", "meta_value"=> "0x16241F327213" ) ), "split_type"=> "percentage", "split_value"=> 0.5 ); $fetch_data = array("id" => "RS_9247C52A37C5EB15C7E8E974CD1B35D7"); $update_data = array("id" => "2755","business_name"=>"Mad O!","business_email"=> "mad@o.enterprises", "account_bank"=> "044","account_number"=> "0690000040","split_type"=> "flat","split_value"=> "200"); $subaccount = new Subaccount(); $createSubaccount = $subaccount->createSubaccount($data); $getSubaccounts = $subaccount->getSubaccounts(); $fetchSubaccount = $subaccount->fetchSubaccount($fetch_data); $updateSubaccount = $subaccount->updateSubaccount($update_data); print_r($createSubaccount);
转账接收方
以下实现展示了如何在Rave仪表板上创建转账接收方。使用游乐场目录查看响应和使用示例。
require("Flutterwave-Rave-PHP-SDK/library/Recipient.php"); use Flutterwave\Recipient; $data = array( "account_bank"=> "044", "account_number"=> "0690000036", ); $fetchdata = array( 'id' => '6153' ); $deldata = array( 'id'=>'7236' ); $payment = new Recipient(); $recipient1 = $payment->createRecipient($data);//Create a recipient for transfer $recipients = $payment->listRecipients();// get all existing recipients $recipient = $payment->fetchBeneficiary($fetchdata);//fetch a specific recipient. $deleteRecipient = $payment->deleteBeneficiary($deldata);//delete recipient print_r($recipient1);
订阅
以下实现展示了如何激活订阅、获取订阅、获取所有订阅。
require("Flutterwave-Rave-PHP-SDK/library/Subscription.php"); use Flutterwave\Subscription; $id = 1112 //Id of subscription plan //$cid = 2222 $subscription = new Subscription(); $resultGet = $subscription->getAllSubscription();//gets all existing subscription $resultActivate = $subscription->activateSubscription($id);// activates a subscription plan $resultCancel = $subscription->cancelSubscription($cid);// activates a subscription plan //returns the result print_r($result);
账单
以下实现展示了如何支付各种类型的账单,从充值到DSTv支付再到过路费。请查看Rave文档中关于账单支付的章节,了解您可以传递到payBill
方法中的不同类型的账单服务$array
。
访问:https://developer.flutterwave.com/v3.0/reference#buy-airtime-bill
require("Flutterwave-Rave-PHP-SDK/library/Bill.php"); use Flutterwave\Bill; $data = array( "country"=> "NG", "customer"=> "+23490803840303", "amount"=> 500, "recurrence"=> "ONCE", "type"=> "AIRTIME", "reference"=> "9300049645534545454332433" ); //sample payload for bulkBill() $bulkdata = array( "bulk_reference"=>"edf-12de5223d2f3243474543", "callback_url"=>"https://webhook.site/96374895-154d-4aa0-99b5-709a0a128674", "bulk_data"=> array( array( "country"=> "NG", "customer"=> "+23490803840303", "amount"=> 500, "recurrence"=> "WEEKLY", "type"=> "AIRTIME", "reference"=>"930049200929" ), array( "country"=>"NG", "customer"=> "+23490803840304", "amount"=> 500, "recurrence"=> "WEEKLY", "type"=>"AIRTIME", "reference"=>"930004912332434232" ) ), ); $getdata = array( //"reference"=>"edf-12de5223d2f32434753432" "id"=>"BIL136", "product_id"=>"OT150" ); $payment = new Bill(); $result = $payment->payBill($data);//create a bill paymenr $bulkresult = $payment->bulkBill($bulkdata);//create bulk bill payment.... $getresult = $payment->getBill($getdata);// get bulk result.... $getAgencies = $payment->getAgencies(); $getBillCategories = $payment->getBillCategories(); print_r($result);
电子账单
以下实现展示了如何创建电子收据。
require("Flutterwave-Rave-PHP-SDK/library/Ebill.php"); use Flutterwave\Ebill; $data = array( "narration"=> "mndkn blls", "number_of_units"=> 2,//should be a string "currency"=> "NGN", "amount"=> 200,//should be a string "phone_number"=> "09384747474", "email"=>"jake@rad.com", "tx_ref"=> "akhlm-pstmn-1094434370393", "ip"=> "127.9.0.7", "custom_business_name"=> "John Madakin", "country"=> "NG" ); $update = array( "reference"=>"RVEBLS-2B93A7039017-90937",//on creation of order, this is the flw_ref "currency"=> "NGN", "amount"=> "4000" ); $payment = new Ebill(); $result = $payment->order($data);//create an order reciept $updateResult = $payment->updateOrder($update);//create bulk bill payment.... print_r($result);
虚拟账户
以下实现展示了如何创建虚拟账户。请查看文档,了解更多可以在负载中添加的选项。https://developer.flutterwave.com/reference#create-a-virtual-account-number
require("Flutterwave-Rave-PHP-SDK/library/VirtualAccount.php"); use Flutterwave\VirtualAccount; //sample payload for payBill() $data = array( "email"=> "johnmadakin@allstar.com", "duration"=> 5, "frequency"=> 5, "amount"=>"22000", "is_permanent"=> true, "tx_ref"=> "jhn-mdkn-101923123463" ); $bulkdata = array( "accounts"=> 5, "email"=> "sam@son.com", "is_permanent"=> true, "tx_ref"=> "jhn-mndkn-012439283422" ); $batch = array('batch_id' => 'RND_2641579516055928'); $getdata = array( "order_ref"=>"URF_1590362018488_8875935" ); $account = new VirtualAccount(); $result = $account->createVirtualAccount($data);//create a virtak account $bulkAccounts = $account->createBulkAccounts($bulkdata);//create bulk v accounts $virtualAccounts = $account->getBulkAccounts($batch);//list all bulk accounts $virtualAccount = $account->getAccountNumber($getdata);//get an account. print_r($result);
标记化收费
第一次卡片收费和验证步骤完成后,您可以使用标记进行后续收费。
require("Flutterwave-Rave-PHP-SDK/library/TokenizedCharge.php"); use Flutterwave\TokenizedCharge; $data = array( "token"=> "flw-t1nf-1ff187b04cecb4acff4ac62c2b6f7784-m03k", "currency"=> "NGN", "country"=> "NG", "amount"=> 30300, "email"=> "olaobajua@gmail.com", "first_name"=> "Anonymous", "last_name"=> "customer", "client_ip" =>"154.123.220.1", "device_fingerprint" =>"62wd23423rq324323qew1" ); $payment = new TokinizedCharge(); $result = $payment->tokenCharge($data);//initiates the charge $verify = $payment->verifyTransaction(); print_r($result);
查看交易
列出您账户上的所有交易。您可以使用customer_email
或customer_fullname
进行特定查询以进行特定搜索。查看特定时间段、月份或年份的所有成功或失败的交易。请阅读API文档中的MISCELLANEOUS部分,了解更多选项。https://developer.flutterwave.com/reference#list-transactions
require("Flutterwave-Rave-PHP-SDK/library/Transactions.php"); use Flutterwave\Transactions; $data = array( 'amount'=> 1000 ); $fetch_data = array( 'id'=>'345522' ); $time_data = array( 'id'=>'3434' ); $history = new Transactions(); $transactions = $history->viewTransactions(); $transactionfee = $history->getTransactionFee($data); $verifyTransaction = $history->verifyTransaction($fetch_data); $timeline = $history->viewTimeline($time_data); print_r($transactions);
凭证支付
使用凭证收集ZAR离线支付
require("Flutterwave-Rave-PHP-SDK/library/VoucherPayment.php"); use Flutterwave\VoucherPayment; //The data variable holds the payload $data = array( //"public_key": "FLWPUBK-6c4e3dcb21282d44f907c9c9ca7609cb-X"//you can ommit the public key as the key is take from your .env file //"tx_ref": "MC-15852309v5050e8", "amount"=> "100", "type"=> "voucher_payment", "currency"=> "ZAR", "pin"=> "19203804939000", "email"=>"ekene@flw.com", "phone_number" =>"0902620185", "account_bank" => "058", "fullname" => "Ekene Eze", "client_ip" =>"154.123.220.1", "device_fingerprint" =>"62wd23423rq324323qew1", "meta" => array( "flightID"=> "123949494DC" ) ); $payment = new VoucherPayment(); $result = $payment->voucher($data); if(isset($result['data'])){ $id = $result['data']['id']; $verify = $payment->verifyTransaction($id); } print_r($result);
您还可以在docs文件夹中找到类文档。在那里,您将找到关于Rave
类和EventHandlerInterface
的文档。
部署
- 在仪表板设置页面切换到实时模式
- 使用实时公开API密钥
构建使用
- PHP