定制 edwardmuss/flutterwave-laravel 二次开发

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

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

edwardmuss/flutterwave-laravel

Composer 安装命令:

composer require edwardmuss/flutterwave-laravel

包简介

A Laravel Package for Flutterwave Rave

README 文档

README

Latest Version on Packagist Software License Total Downloads

Implement Flutterwave Rave payment gateway easily with Laravel framework

Documentation

Installation

Prerequisite

PHP, Laravel and composer

To get the latest version of Flutterwave, simply use composer

composer require edwardmuss/flutterwave-laravel

Configuration

Publish the configuration file using this command:

php artisan vendor:publish --provider="EdwardMuss\Rave\RaveServiceProvider"

A configuration-file named flutterwave.php will be placed in your config directory

Open your .env file and add your public key, secret key, secret hash like so:

Get your keys form here

FLW_PUBLIC_KEY=FLWPUBK-xxxxxxxxxxxxxxxxxxxxx-X
FLW_SECRET_KEY=FLWSECK-xxxxxxxxxxxxxxxxxxxxx-X
FLW_SECRET_HASH='My_lovelysite123'
  • FLW_PUBLIC_KEY - This is the api public key gotten from your dashboard(compulsory)
  • FLW_SECRET_KEY - This is the api secret key gotten from your dashboard(compulsory)
  • FLW_SECRET_HASH - This is the secret hash for your webhook

USage

1. Setup Routes

// The page that displays the payment form
Route::get('/', function () {
    return view('welcome');
});
// The route that the button calls to initialize payment
Route::post('/pay', [FlutterwaveController::class, 'initialize'])->name('paynow');
// The callback url after a payment
Route::get('/rave/callback', [FlutterwaveController::class, 'callback'])->name('callback');
  1. Setup the Payment Page

A sample payment button will look like so:

welcome.blade.php
<h3>Buy me Coffee</h3>
<form method="POST" action="{{ route('paynow') }}">
    {{ csrf_field() }}

    <input name="name" placeholder="Name" />
    <input name="email" type="email" placeholder="Your Email" />
    <input name="phone" type="tel" placeholder="Phone number" />

    <input type="submit" value="Buy me Coffee" />
</form>

  1. Setup your Controller

    Setup your controller to handle the routes. I created the FlutterwaveController. Use the Rave as Flutterwave facade.

Example

<?php

namespace App\Http\Controllers;

use EdwardMuss\Rave\Facades\Rave as Flutterwave;

class FlutterwaveController extends Controller
{
    /**
     * Initialize Rave payment process
     * @return void
     */
    public function initialize()
    {
        //This generates a payment reference
        $reference = Flutterwave::generateReference();

        // Enter the details of the payment
        $data = [
            'payment_options' => 'card,banktransfer',
            'amount' => 500,
            'email' => request()->email,
            'tx_ref' => $reference,
            'currency' => "KES",
            'redirect_url' => route('callback'),
            'customer' => [
                'email' => request()->email,
                "phone_number" => request()->phone,
                "name" => request()->name
            ],

            "customizations" => [
                "title" => 'Buy Me Coffee',
                "description" => "Let express love of coffee"
            ]
        ];

        $payment = Flutterwave::initializePayment($data);


        if ($payment['status'] !== 'success') {
            // notify something went wrong
            return;
        }

        return redirect($payment['data']['link']);
    }

    /**
     * Obtain Rave callback information
     * @return void
     */
    public function callback()
    {
        
        $status = request()->status;

        //if payment is successful
        if ($status ==  'successful') {
        
        $transactionID = Flutterwave::getTransactionIDFromCallback();
        $data = Flutterwave::verifyTransaction($transactionID);

        dd($data);
        }
        elseif ($status ==  'cancelled'){
            //Put desired action/code after transaction has been cancelled here
        }
        else{
            //Put desired action/code after transaction has failed here
        }
        // 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
        // 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 (including 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

    }
}

Credits

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities. I will appreciate that a lot. Also please add your name to the credits.

Kindly follow me on Instagram!

Features

The current features have been implemented

  • Payment
  • Verification
  • Transfers
  • Banks
  • Beneficiaries

If there are features you need urgently, I will be willing to prioritize them, please reach out to my twitter account

License

The MIT License (MIT). Please see License File for more information.

edwardmuss/flutterwave-laravel 适用场景与选型建议

edwardmuss/flutterwave-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.96k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「github」 「payments」 「laravel」 「open source」 「laravel 5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 edwardmuss/flutterwave-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 edwardmuss/flutterwave-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 edwardmuss/flutterwave-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-22