malico / laravel-mesomb
此包已被废弃且不再维护。没有建议的替代包。
MeSomb 支付 API 之上的 Laravel 包装器
1.6
2023-07-22 18:24 UTC
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.0|^8.0|^9.0
- illuminate/database: ^7.0|^8.0|^9.0|^10.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.0
- malico/mobile-cm-php: ^1.2
Requires (Dev)
- laravel/pint: ^1.10
- orchestra/testbench: ^7.0|^8.0
- pestphp/pest: ^1.19
- pestphp/pest-plugin-laravel: ^1.1
- spatie/ray: ^1.30
This package is auto-updated.
Last update: 2024-02-22 19:55:01 UTC
README
MeSomb 支付 API 之上的 Laravel 包装器
路线图
API 特性和它们的实现 https://mesomb.hachther.com/en/api/schema/
特性 | 状态 |
---|---|
支付 | ☑ |
交易状态 | ☑ |
应用状态 | ☑ |
存款 | ☑ |
测试 | ☐ |
更好的文档 | ☐ |
安装
安装包
composer require malico/laravel-mesomb
发布配置文件
php artisan vendor:publish --tag=mesomb-configuration
在 https://mesomb.hachther.com/ 上注册并创建新的应用。根据仪表板上的配置为 config/mesomb.php
提供相应的配置;
<?php return [ /** * Api Version * * @var string */ 'version' => 'v1.0', /** * MeSomb Application Key * Copy from https://mesomb.hachther.com/en/applications/{id} * * @var string */ 'key' => env('MeSomb_APP_KEY'), /** * MeSomb API Application Key * Copy from https://mesomb.hachther.com/en/applications/{id} * * @var string */ 'api_key' => env('MeSomb_API_KEY'), /** * PIN used for MeSomb Pin * Configure @ https://mesomb.hachther.com/en/applications/{id}/settings/setpin/ * * @var int|string */ 'pin' => env('MeSomb_PIN', null), /** * Supported Payment Methods * * @var array */ 'currencies' => ['XAF', 'XOF'], /** * Support Payment Methods * Array in order of preference * * @var array */ 'services' => ['MTN', 'ORANGE'], /** * Set to True if your application uses uuid instead auto-incrmenting ids * * @var bool */ 'uses_uuid' => false, /* * Used to store the application Status */ 'application_cache_key' => 'mesomb_application_status', /* * You can choose to wait till the application to wait till the payment is approved * or queue the payment request check later * enum: asynchronous, synchronous */ 'mode' => 'synchronous', 'throw_exceptions' => true, ];
迁移 MeSomb 交易表
php artisan migrate
使用
支付
示例
-
简单支付
// OrderController.php use Malico\MeSomb\Payment; class OrderController extends Controller { public function confirmOrder() { $request = new Payment('+23767xxxxxxx', 1000); $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 } }
-
直接将支付附加到模型上
// Order.php use Malico\MeSomb\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('+23767xxxxxxx', $order->amount)->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; } }
作者
Malico (Desmond Yong) hi@malico.me