承接 freethinkerz/laravel-pay 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

freethinkerz/laravel-pay

最新稳定版本:1.2.0

Composer 安装命令:

composer require freethinkerz/laravel-pay

包简介

A laravel Payment Gateway wrapper for MeSomb and NotchPay

README 文档

README

A laravel Payment Gateway wrapper for MeSomb and NotchPay

Roadmap

API Features and their implementations https://mesomb.hachther.com/en/api/v1.1/schema/

Feature Status Documentation
Payment Check the documentation
Transaction Status Check the documentation
Application Status Check the documentation
Deposits Check the documentation
Test
Better Documentation

Installation

Before you start, you must register your service and MeSomb and get API Access keys. Please follow this tutorial.

Install Package

composer require freethinkerz/laravel-pay

Publish Configuration Files

Setting the following parameters from MeSomb

Get the information below from MeSomb after following the above tutorial.

MESOMB_APP_KEY=<ApplicationKey>
MESOMB_API_HOST=https://mesomb.hachther.com
MESOMB_API_VERSION=v1.1
MESOMB_ACCESS_KEY=<AccessKey>
MESOMB_SECRET_KEY=<SecretKey>
MESOMB_SSL_VERIFY=true

Publish configurations file

php artisan vendor:publish --tag=mesomb-configuration

Migrate Mesomb Transaction Tables

php artisan migrate

Usage

Quick Examples

Simple Collect

// OrderController.php
use FreeThinkerz\LaravelPay\Operation\Payment\Collect;

class OrderController extends Controller {

    public function confirmOrder()
    {
        $request = new Collect('67xxxxxxx', 1000, 'MTN', 'CM');

        $payment = $request->pay();

        if($payment->success){
            // Fire some event,Pay someone, Alert user
        } else {
            // fire some event, redirect to error page
        }

        // get Transactions details $payment->transactions
    }
}

Simple Deposit

// OrderController.php
use FreeThinkerz\LaravelPay\Operation\Payment\Deposit;

class OrderController extends Controller {

    public function makeDeposit()
    {
        $request = new Deposit('67xxxxxxx', 1000, 'MTN', 'CM');

        $payment = $request->pay();

        if($payment->success){
            // Fire some event,Pay someone, Alert user
        } else {
            // fire some event, redirect to error page
        }

        // get Transactions details $payment->transactions
    }
}

Attaching Payments to Models Directly

// Order.php

use FreeThinkerz\LaravelPay\Helper\HasPayments;

class Order extends Model
{
    use HasPayments;
}

// OrderController.php

class OrderController extends Controller {

    public function confirmOrder(){

        $order = Order::create(['amount' => 100]);

        $payment  = $order->payment('67xxxxxxx', $order->amount, 'MTN', 'CM')->pay();

        if($payment->success){
            // Fire some event,Pay someone, Alert user
        } else {
            // fire some event, redirect to error page
        }

        // View Order payments via $order->payments

        // Get payment transaction with $payment->transaction

        return $payment;
    }
}

Handle multiple applications

This is how you process if you want to handle multiple MeSomb applications with the same project.

  1. Set up your configuration file with the default application and other information as specified below.
  2. Update the applicationKey (the accessKey and the secretKey if needed) on the fly as you can see below.
// OrderController.php
use FreeThinkerz\LaravelPay\Operation\Payment\Collect;

class OrderController extends Controller {

    public function confirmOrder()
    {
        $request = new Collect('67xxxxxxx', 1000, 'MTN', 'CM');

        // Update applicationKey before process the payment
        // You also have setAccessKey and setSecretKey
        $payment = $request->setApplicationKey('<applicationKey>')->pay();

        if($payment->success){
            // Fire some event,Pay someone, Alert user
        } else {
            // fire some event, redirect to error page
        }

        // get Transactions details $payment->transactions
    }
}

Author

FreeThinkerz https://github.com/FreeThinkerz

Apreciations

Thank you to Malico (hi@malico.me) for starting this module.

Hachther LLC (For Adding updates to the module) contact@hachther.com

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-08