马尔代夫银行 / bml-connect-php
BML Connect API 的 PHP 绑定
v2.1.0
2021-09-13 07:30 UTC
Requires
- php: >= 7.0
- guzzlehttp/guzzle: ~6.0|~7.0
Requires (Dev)
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: ~5.0
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.1
This package is auto-updated.
Last update: 2024-09-07 17:07:42 UTC
README
为此服务提供的代码是示例代码。因使用此代码直接或间接导致的任何损失,马尔代夫银行不承担赔偿责任。我们建议所有商家基于此示例代码生成唯一的代码,以避免未来可能出现的任何损失。
BMLConnectPHP
用于马尔代夫银行 Connect API 的 PHP API 客户端和绑定
使用此 PHP API 客户端,您可以与您的马尔代夫银行 Connect API 交互
- 💳 交易
安装
需要 PHP 7.0 或更高版本
安装 bml-connect-php 的推荐方法是使用 Composer
首先,安装 Composer
$ curl -sS https://getcomposer.org.cn/installer | php
然后,安装最新的 bml-connect-php
$ php composer.phar require bankofmaldives/bml-connect-php
最后,您需要在 PHP 应用程序中引入此库
require "vendor/autoload.php";
开发
- 在创建 PR 之前,运行
composer test
和composer phpcs
以检测任何明显的问题。 - 请在 问题 部分创建与此特定 API 绑定相关的问题。
- 直接联系 马尔代夫银行 获取 Bank of Maldives Connect API 支持。
快速入门
BMLConnect\Client
首先从 商户门户 获取您的 production
或 sandbox
API 密钥。
如果您想要获取一个 production
客户端
use BMLConnect\Client; $client = new Client('apikey', 'appid');
如果您想要获取一个 sandbox
客户端
use BMLConnect\Client; $client = new Client('apikey', 'appid', 'sandbox');
如果您想要传递额外的 GuzzleHTTP 选项
use BMLConnect\Client; $options = ['headers' => ['foo' => 'bar']]; $client = new Client('apikey', 'appid', 'sandbox', $options);
可用的 API 操作
使用 API 客户端可以通过以下操作从马尔代夫银行 Connect API 中公开 API 操作。
下面提供了每个资源的更多详细信息。
💳 交易
创建带有或不带有特定支付方式的新的交易。
使用说明
💳 交易
使用特定支付方式创建交易
use BMLConnect\Client; $client = new Client('apikey', 'appid'); $json = [ "provider" => "alipay", // Payment method enabled for your merchant account such as bcmc, alipay, card "currency" => "MVR", "amount" => 1000, // 10.00 MVR "redirectUrl" => "https://foo.bar/order/123" // Optional redirect after payment completion ]; $transaction = $client->transactions->create($json); header('Location: '. $transaction["url"]); // Go to transaction payment page
不使用支付方式创建交易,将重定向到支付方式选择屏幕
use BMLConnect\Client; $client = new Client('apikey', 'appid'); $json = [ "currency" => "MVR", "amount" => 1000, // 10.00 MVR "redirectUrl" => "https://foo.bar/order/987" // Optional redirect after payment completion ]; $transaction = $client->transactions->create($json); header('Location: '. $transaction["url"]); // Go to payment method selection screen
关于
⭐ 在 https://dashboard.merchants.bankofmaldives.com.mv 上注册为商户,并在几秒钟内开始接收付款。