定制 obinnaakaolisa/flutterwave-pay 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

obinnaakaolisa/flutterwave-pay

最新稳定版本:v1.0.1

Composer 安装命令:

composer require obinnaakaolisa/flutterwave-pay

包简介

This is a PHP package for intializing and verifying Fluttwerwave transactions via the Flutterwave transactions API

README 文档

README

This is a PHP package for intializing and verifying Flutterwave transactions via the Flutterave transactions API

Requirements

The package requires the folowing resources:

  1. PHP ^8.0
  2. Composer
  3. Curl

Getting started

Installation

Navigate to your project's directory

    cd folder/my-project

In your project folder, run the following command

    composer require obinnaakaolisa/flutterwave-pay

Set your api key

    $apiKey = "FLWSECK_TEST-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-X";

Instantiate a new transaction object

Pass in the API_KEY upon instantiation.

    $transaction = new FlutterwavePay($apiKey);

Define your payload data for a POST request.

    $payload = [
    'tx_ref' => 'FLW_TEST_'.bin2hex(random_bytes(5)),
    'amount' => 2000, //in naira
    'redirect_url' => "https://{$_SERVER['SERVER_NAME']}/verify.php",
    'currency' => 'NGN',
    'customer' => [
        'name' => 'Firstname' .' '.'Lastname',
        'email' => 'customer@email.com',
        'phone_number' => '08031010101',
    ],
    'payment_options' => "card, banktransfer, ussd",
    'customizations' => [
        'title' => 'Some Payment',
    ],
    'meta' => [
        'field_name' => 'field_value',
    ],
    'subaccounts' => []
];

Note:

  1. The customizations field is optional. Define it if you want to customize the look and feel of the payment page. See documentation for reference.
  2. The subaccounts field is optional. It is only defined when you want to split the transaction into different settlement accounts. See documentation for reference.
  3. The meta field is optional. It is only defined when you want to save additional info about the customer or the transaction. See documentation for reference.

Intialize the transaction

The response you get for a request is a json encoded object, so you need to decode it thus:

$response = json_decode($transaction->initialize($payload));

or

$request = $transaction->initialize($payload);

$response = json_decode($request);

Verifying a transaction

Upon a successfull transaction or close of the payment page, the customer will be redirected to the redirect_url you set when initiating the transaction. Normally, that's the url where you'll verify the status of the transaction.

It is advised to verify a transaction before you give value to the customer.

Define your API_KEY

    $apiKey = "FLWSECK_TEST-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-X";

Instantiate a new transaction object and pass in the API_KEY upon instantiation.

    $transaction = new FlutterwavePay($apiKey);

Pass in the transaction reference that was defined while intiating the transaction.

You can also get this from the query parameter of the get request returned along with the redirect_url.

$response = json_decode($transaction->verify($_GET['tx_ref']));

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.

License

MIT

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-11