seunex17 / flutterwave-php-payment-gateway
一个易于使用的php包,用于flutterway支付网关
v1.0.0
2021-02-15 22:19 UTC
Requires
- php: >=5.6.0
README
一个易于使用的php包,用于flutterway支付网关。这是制作和接受来自全球任何地方的客户支付的简单方法。
安装
通过composer安装 RECOMMENDED
composer require seunex17/flutterwave-php-payment-gateway
使用方法
结算页面
use Flutterwave\Transaction; require '../vendor/autoload.php'; $rave = new Transaction('YOUR-SEC-KEY', 'YOUR-PUBLIC-KEY'); $request = [ 'tx_ref' => time(), //* A unique transaction references 'amount' => 500, //* Amount to be charged 'currency' => 'NGN', //* Payment currency 'payment_options' => 'card', //* Payment options 'redirect_url' => 'https:///repo/flutterwave/example/verify.php', //* Redirect url to check payment status 'customer' => [ 'email' => 'user@mail.com', //* Customer email 'name' => 'Zubdev', //* Customer name, 'phone' => '' //* Customer phone number ], 'meta' => [ //* An array of an additional information ], 'customizations' => [ 'title' => 'Paying for a sample product', //* Payment title 'description' => 'sample', //* Payment description 'logo' => '' //* Your website logo url ] ]; //* Send data to Flutterwave hosted checkout page $rave->checkout($request);
支付验证
use Flutterwave\Transaction; require '../vendor/autoload.php'; $rave = new Transaction('YOUR-SEC-KEY', 'YOUR-PUBLIC-KEY'); //* Check payment status from the url get param if (isset($_GET['status']) && isset($_GET['transaction_id'])) { if ($_GET['status'] == 'successful') { //* Grab the transaction id $txnID = $_GET['transaction_id']; //* Validation example $response = $rave->verify($txnID); if ($response->status == 'success') { //* Extracted data $id = $response->data->id; $txRef = $response->data->tx_ref; $flwRef = $response->data->flw_ref; $deviceFingerPrint = $response->data->device_fingerprint; $amount = $response->data->amount; $currency = $response->data->currency; $chargeAmount = $response->data->charged_amount; $appFee = $response->data->app_fee; $merchantFee = $response->data->merchant_fee; $processorResponse = $response->data->processor_response; $authModel = $response->data->auth_model; $ip = $response->data->ip; $narration = $response->data->narration; $status = $response->data->status; $paymentType = $response->data->payment_type; $createdAt = $response->data->created_at; $accountId = $response->data->account_id; //* Payment card information $firstSixDigit = $response->data->card->first_6digits; $lastFourDigit = $response->data->card->last_4digits; $issuer = $response->data->card->issuer; $country = $response->data->card->country; $cardType = $response->data->card->type; $cardToken = $response->data->card->token; $cardExpire = $response->data->country; //* meta $meta = $response->meta; //* Customer $name = $response->data->customer->name; $phone = $response->data->customer->phone; $email = $response->data->customer->phone; //* hint check if amount paid correct $productPrice = "YOUR PRODUCT PRICE FROM DATABASE"; if($chargeAmount >= $productPrice) { //* Give item } else { //* Don't give item } } } //* Throw user to error page } //* Throw user to error page
贡献
欢迎提交拉取请求。对于重大更改,请先提交问题以讨论您想进行哪些更改。
请确保适当更新测试。