tchdev / monetbil
这将显示monetbil(MTN/ORANGE/EU MONEY)的支付界面
v1.0.3
2019-11-06 15:10 UTC
This package is auto-updated.
Last update: 2024-09-08 22:19:05 UTC
README
此仓库包含允许您从laravel应用访问Monetbil平台的开源PHP SDK。
要求
PHP 5.2及更高版本。
下载SDK
https://github.com/Monetbil/monetbil-php/archive/master.zip
安装
Composer安装
使用 composer 安装monetbil是快速且简单的方法。
要安装最新版本,运行以下命令。
composer require tchdev/monetbil
Laravel
如果您不使用自动发现,请打开您的应用配置,并将服务提供者添加到 $providers
数组
'providers' => [ ... Propaganistas\LaravelPhone\PhoneServiceProvider::class, ],
并将别名添加到 $aliases
数组
'aliases' => [ ... 'Monetbil' => Tchdev\Monetbil\Facades\Monetbil::class, ],
使用命令发布文件
php artisan vendor:publish Which provider or tag's files would you like to publish?: [0 ] Publish files from all providers and tags listed below [1 ] Provider: Facade\Ignition\IgnitionServiceProvider [2 ] Provider: Fideloper\Proxy\TrustedProxyServiceProvider [3 ] Provider: Illuminate\Foundation\Providers\FoundationServiceProvider [4 ] Provider: Illuminate\Mail\MailServiceProvider [5 ] Provider: Illuminate\Notifications\NotificationServiceProvider [6 ] Provider: Illuminate\Pagination\PaginationServiceProvider [7 ] Provider: Laravel\Tinker\TinkerServiceProvider [8 ] Provider: Tchdev\Monetbil\MonetbilServiceProvider [9 ] Tag: flare-config [10] Tag: ignition-config [11] Tag: laravel-errors [12] Tag: laravel-mail [13] Tag: laravel-notifications [14] Tag: laravel-pagination [15] Tag: public > Enter the number of the package (Tchdev\Monetbil\MonetbilServiceProvider) and press "enter"
现在转到您的 .env
文件,并添加以下内容
MONETBIL_KEY=YOUR_MONETBIL_KEY MONETBIL_SECRET=YOUR_MONEBIL_SECRET_KEY MONETBIL_VERSION=YOUR_MONETBIL_VERSION
支付小部件使用
示例 1
<?php use Tchdev\Monetbil\Facades\Monetbil; // Setup Monetbil arguments Monetbil::setAmount(500); Monetbil::setCurrency('XAF'); Monetbil::setLocale('en'); // Display language fr or en Monetbil::setPhone(''); Monetbil::setCountry(''); Monetbil::setItem_ref('2536'); Monetbil::setPayment_ref(md5(uniqid())); Monetbil::setUser(12); Monetbil::setFirst_name('KAMDEM'); Monetbil::setLast_name('Jean'); Monetbil::setEmail('jean.kamdem@email.com'); Monetbil::setReturn_url('your_redirect_url_after_payment'); Monetbil::setNotify_url('your_notification_url_to_receive_payment_data'); Monetbil::setLogo('https://storage.googleapis.com/cdn.ucraft.me/userFiles/ukuthulamovies/images/937-your-logo.png'); // Start a payment // You will be redirected to the payment page Monetbil::startPayment();
或示例 2
<?php use Tchdev\Monetbil\Facades\Monetbil; // Setup Monetbil arguments $monetbil_args = array( 'amount' => 500, 'phone' => '', 'locale' => 'en', // Display language fr or en 'country' => '', 'currency' => 'XAF', 'item_ref' => '2536', 'payment_ref' => md5(uniqid()), 'user' => 12, 'first_name' => 'KAMDEM', 'last_name' => 'Jean', 'email' => 'jean.kamdem@email.com', 'return_url' => 'your_redirect_url_after_payment', 'notify_url' => 'your_notification_url_to_receive_payment_data', 'logo' => 'https://storage.googleapis.com/cdn.ucraft.me/userFiles/ukuthulamovies/images/937-your-logo.png' ); // Start a payment // You will be redirected to the payment page Monetbil::startPayment($monetbil_args);
您可以得到支付URL。
示例 3
<?php use Tchdev\Monetbil\Facades\Monetbil; // Setup Monetbil arguments Monetbil::setAmount(500); Monetbil::setCurrency('XAF'); Monetbil::setLocale('en'); // Display language fr or en Monetbil::setPhone(''); Monetbil::setCountry(''); Monetbil::setItem_ref('2536'); Monetbil::setPayment_ref(md5(uniqid())); Monetbil::setUser(12); Monetbil::setFirst_name('KAMDEM'); Monetbil::setLast_name('Jean'); Monetbil::setEmail('jean.kamdem@email.com'); Monetbil::setReturn_url('your_redirect_url_after_payment'); Monetbil::setNotify_url('your_notification_url_to_receive_payment_data'); Monetbil::setLogo('https://storage.googleapis.com/cdn.ucraft.me/userFiles/ukuthulamovies/images/937-your-logo.png'); // This example show payment url echo Monetbil::url();
或示例 4
<?php use Tchdev\Monetbil\Facades\Monetbil; // Setup Monetbil arguments $monetbil_args = array( 'amount' => 500, 'phone' => '', 'locale' => 'en', // Display language fr or en 'country' => '', 'currency' => 'XAF', 'item_ref' => '2536', 'payment_ref' => md5(uniqid()), 'user' => 12, 'first_name' => 'KAMDEM', 'last_name' => 'Jean', 'email' => 'jean.kamdem@email.com', 'return_url' => 'your_redirect_url_after_payment', 'notify_url' => 'your_notification_url_to_receive_payment_data', 'logo' => 'https://storage.googleapis.com/cdn.ucraft.me/userFiles/ukuthulamovies/images/937-your-logo.png' ); ); // This example show payment url echo Monetbil::url($monetbil_args);
示例 3 和 4 的响应:
https://www.monetbil.com/pay/v2.1/UXaJoEvDiVBrQX9p9FGoFanlmp6t3H
您可以在自己的页面上集成支付小部件。
示例 5
<?php use Tchdev\Monetbil\Facades\Monetbil; // Setup Monetbil arguments Monetbil::setAmount(500); Monetbil::setCurrency('XAF'); Monetbil::setLocale('en'); // Display language fr or en Monetbil::setPhone(''); Monetbil::setCountry(''); Monetbil::setItem_ref('2536'); Monetbil::setPayment_ref(md5(uniqid())); Monetbil::setUser(12); Monetbil::setFirst_name('KAMDEM'); Monetbil::setLast_name('Jean'); Monetbil::setEmail('jean.kamdem@email.com'); Monetbil::setReturn_url('your_redirect_url_after_payment'); Monetbil::setNotify_url('your_notification_url_to_receive_payment_data'); Monetbil::setLogo('https://storage.googleapis.com/cdn.ucraft.me/userFiles/ukuthulamovies/images/937-your-logo.png'); // This example show payment button $payment_url = Monetbil::url(); ?> <style type="text/css"> .btnmnb { background: #3498db; background-image: -webkit-linear-gradient(top, #3498db, #2980b9); background-image: -moz-linear-gradient(top, #3498db, #2980b9); background-image: -ms-linear-gradient(top, #3498db, #2980b9); background-image: -o-linear-gradient(top, #3498db, #2980b9); background-image: linear-gradient(to bottom, #3498db, #2980b9); font-family: Arial; color: #ffffff; font-size: 20px; padding: 10px 20px 10px 20px; text-decoration: none; cursor: pointer; } .btnmnb:hover { background: #3cb0fd; background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db); background-image: -moz-linear-gradient(top, #3cb0fd, #3498db); background-image: -ms-linear-gradient(top, #3cb0fd, #3498db); background-image: -o-linear-gradient(top, #3cb0fd, #3498db); background-image: linear-gradient(to bottom, #3cb0fd, #3498db); text-decoration: none; } </style> <?php if (Monetbil::MONETBIL_WIDGET_VERSION_V2 == Monetbil::getWidgetVersion()): ?> <form action="<?php echo $payment_url; ?>" method="post" data-monetbil="form"> <button type="submit" class="btnmnb" id="monetbil-payment-widget">Pay By Mobile Money</button> </form> <?php else : ?> <a class="btnmnb" href="<?php echo $payment_url; ?>" id="monetbil-payment-widget">Pay By Mobile Money</a> <?php endif; ?> <!-- To open widget, add JS files --> <?php echo Monetbil::js(); ?> <!-- To auto open widget, add JS files --> <?php echo Monetbil::js(true); ?>
如果您有任何问题或需要帮助,请随时通过 ramostchambia@gmail.com 联系我们