赵彼得熊 / laravel-mollie
Laravel 5 对支付提供商 mollie 的包装
Requires
- illuminate/support: 5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0
- mollie/mollie-api-php: ~1.0
Requires (Dev)
- php: >=5.5.9
- graham-campbell/testbench: ~3.0
- illuminate/contracts: 5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^4.8|^5.0
- scrutinizer/ocular: ~1.1
README
这是一个将 Mollie 与 Laravel 5.x 集成的包。您可以使用它轻松管理您的配置,并使用 Facade 提供对 Mollie 客户端的快捷方式。
要求
要使用 Mollie API 客户端,需要以下内容
- 获取免费的 Mollie 账户。无需注册费用。
- 创建一个新的 网站配置文件 以生成 API 密钥(实时和测试模式)并设置您的 webhook。
- 现在您可以使用 Mollie API 客户端进行测试模式了。
- 为了在实时模式下接受支付,必须在您的账户中激活支付方式。按照 几个步骤 操作,其余的由我们处理。
- PHP >= 5.2,尽管 Laravel 本身需要更高的 PHP 版本
- PHP cURL 扩展
- 最新的 OpenSSL(或其它 SSL/TLS 工具包)
- 禁用 SSL v3。Mollie 不再支持 SSL v3。
安装
通过 Composer
$ composer require petericebear/laravel-mollie
更新 composer 后,将 MollieServiceProvider 添加到 config/app.php 中的 providers 数组
PeterIcebear\Mollie\Providers\MollieServiceProvider::class,
您需要发布此包的配置。提供了一个示例配置。默认值将与网关特定的配置合并。
$ php artisan vendor:publish --provider="PeterIcebear\Mollie\Providers\MollieServiceProvider"
要使用 Facade(使用 \Mollie::getMethods()
而不是 App::make('mollie')->getMethods()
),将其添加到 facades 数组。
'Mollie' => PeterIcebear\Mollie\Facades\Mollie::class,
包装的使用
创建一个新的支付。
$payment = Mollie::getPayments()->create([ "amount" => 10.00, "description" => "My first API payment", "redirectUrl" => "https://webshop.example.org/order/12345/", ]);
创建后,支付 ID 可在 $payment->id
属性中找到。您应该将此 ID 与您的订单一起存储。
检索支付。
$payment = Mollie::getPayments()->get($payment->id); if ($payment->isPaid()) { echo "Payment received."; }
完全集成的 iDEAL 支付
如果您想在您的网站上完全集成 iDEAL 支付,则需要执行一些额外的步骤。首先,您需要检索支持 iDEAL 的发行商(银行)列表,并让您的客户选择他们想要用于支付的发行商。
检索发行商列表
$issuers = Mollie::getIssuers()->all();
_$issuers
将是一个包含 Mollie_API_Object_Issuer
对象的列表。在 API 调用中使用该对象的 $id
属性,并使用 $name
属性来向您的客户显示发行商。
使用所选发行商创建支付
$payment = Mollie::getPayments()->create(array( "amount" => 10.00, "description" => "My first API payment", "redirectUrl" => "https://webshop.example.org/order/12345/", "method" => Mollie_API_Object_Method::IDEAL, "issuer" => $selected_issuer_id, // e.g. "ideal_INGBNL2A" ));
$payment
对象的 links
属性将包含一个指向所选发行商在线银行环境的 paymentUrl
字符串。
退款支付
API 还支持退款支付。请注意,没有确认,所有退款都是即时和最终的。目前仅支持 iDEAL、信用卡、Bancontact/Mister Cash、SOFORT Banking 和银行转账支付退款。其他类型的支付目前不能通过我们的 API 退款。
$payment = Mollie::getPayments()->get($payment->id); // Refund € 15 of this payment $refund = Mollie::getPayments()->refund($payment, 15.00);
更多信息
请使用 Mollie 的官方文档或以下资源之一