pixelpillow / lunar-api-mollie-adapter
此插件允许在使用 Lunar API 包时在您的 Lunar 商店上启用 Mollie 支付。
Requires
- php: ^8.2
- dystcz/lunar-api: ^0.8
- illuminate/contracts: ^10.0
- mollie/laravel-mollie: ^2.25
Requires (Dev)
- laravel-json-api/testing: ^2.1
- laravel/pint: ^1.13
- nunomaduro/collision: ^7.8
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.32
This package is auto-updated.
Last update: 2024-09-07 11:45:21 UTC
README
目录
描述
此包旨在无缝地将 Mollie 支付集成到您的 Lunar 商店中。通过利用 Lunar API,此适配器使得通过流行的支付服务提供商 Mollie 接受和管理支付变得非常简单。
无论您是运行电子商务平台还是订阅服务,此适配器都将帮助您高效、安全地处理支付。通过简单的安装和配置,您可以在很短的时间内将 Mollie 支付集成到您的 Lunar 商店。
请按照安装部分中的说明开始。
依赖关系
此包依赖于以下包
特性
- 多种支付方式,包括 iDEAL、信用卡、PayPal、Apple Pay 等
- 在 API 中公开支付方式
- 在 API 中公开理想的支付发行商
安装
- 通过 composer 安装此包
composer require pixelpillow/lunar-api-mollie-adapter
- 发布配置文件
php artisan vendor:publish --tag="lunar-api-mollie-adapter-config"
- 将您的 Mollie API 密钥(您可以在 Mollie 网站上注册来获取您的 API 密钥。)添加到
.env
文件中
MOLLIE_API_KEY=your-api-key
- 将 Mollie 支付类型添加到
config/lunar/payments.php
文件中
<?php return [ 'default' => env('PAYMENTS_TYPE', 'cash-in-hand'), 'types' => [ 'cash-in-hand' => [ 'driver' => 'offline', 'authorized' => 'payment-offline', ], // Add the Mollie payment type here: 'mollie' => [ 'driver' => 'mollie', 'authorized' => 'payment-received', ], ], ];
- 通过在
config/lunar-api-mollie-adapter.php
文件中定义自己的生成器来在您的自己的RedirectOnSuccessUrlGenerator
中管理成功的重定向
<?php namespace App\Mollie\Generators; use Dystcz\LunarApi\Domain\Carts\Models\Cart; use Pixelpillow\LunarApiMollieAdapter\Generators\RedirectOnSuccessUrlGenerator; class CustomRedirectOnSuccessUrlGenerator extends RedirectOnSuccessUrlGenerator { /** * @var Cart */ protected $cart; public function __construct(Cart $cart) { $this->cart = $cart; } /** * Generate the webhook URL. */ public function generate(): string { $order = $this->cart->orders()->first(); if (! $order) { throw new \Exception('Order not found'); } // Return your own redirect URL here return 'https://example.com/checkout/success?order_id=' . $order->id; } }
- 通过在
config/lunar-api-mollie-adapter.php
文件中定义自己的生成器来在您的RedirectOnFailureUrlGenerator
中管理失败的重定向
<?php namespace App\Mollie\Generators; use Dystcz\LunarApi\Domain\Carts\Models\Cart; use Lunar\Models\Order; use Pixelpillow\LunarApiMollieAdapter\Generators\RedirectOnSuccessUrlGenerator; class CustomRedirectOnFailureUrlGenerator extends RedirectOnSuccessUrlGenerator { /** * @var Cart */ protected $cart; /** * @var Order */ protected $order; public function __construct(Cart $cart) { $this->cart = $cart; } /** * Generate the webhook URL. */ public function generate(): string { $order = $this->cart->orders()->first(); if (! $order) { throw new \Exception('Order not found'); } // Return your own redirect URL here return 'https://example.com/checkout/failure?order_id=' . $order->id; } }
示例 JSON:API 请求创建 Mollie IDEAL paymentIntent
创建支付意图的 URL 是一个签名 URL,可以在 POST /api/v1/carts/{cart}/-actions/checkout 请求的响应中找到。
POST api/v1/orders/{order}/-actions/create-payment-intent
{ "data": { "type": "orders", "id": 1, "attributes": { "payment_method": "mollie", "meta": { "payment_method_type": "ideal", "payment_method_issuer": "ideal_ABNANL2A" } } } }
示例 JSON:API 请求创建 Mollie Bancontact paymentIntent
创建支付意图的 URL 是一个签名 URL,可以在 POST /api/v1/carts/{cart}/-actions/checkout 请求的响应中找到。
POST api/v1/orders/{order}/-actions/create-payment-intent
{ "data": { "type": "orders", "id": 1, "attributes": { "payment_method": "mollie", "meta": { "payment_method_type": "bancontact" } } } }
端点
此包扩展了 Lunar API,以下端点
GET /api/v1/payment-methods
返回 Mollie 控制台中启用的支付方式列表。结果没有分页。有关更多信息,请参阅 Mollie API 文档。
示例响应
{ "jsonapi": { "version": "1.0" }, "data": [ { "type": "payment-methods", "id": "ideal", "attributes": { "name": "iDEAL", "method_id": "ideal", "image": [ "https://www.mollie.com/external/icons/payment-methods/ideal.png", "https://www.mollie.com/external/icons/payment-methods/ideal%402x.png", "https://www.mollie.com/external/icons/payment-methods/ideal.svg" ] }, "links": { "self": "https://api.monoz.test/api/v1/payment-methods/ideal" } } ] }
POST /api/v1/payment-issuers
返回理想支付的可用的支付发行商列表,包括发行商 ID、发行商名称等。有关更多信息,请参阅 Mollie API 文档。
示例响应
{ "jsonapi": { "version": "1.0" }, "data": [ { "type": "payment-issuers", "id": "ideal_ABNANL2A", "attributes": { "resource": "issuer", "name": "ABN AMRO", "issuer_id": "ideal_ABNANL2A", "image": [ "https://www.mollie.com/external/icons/ideal-issuers/ABNANL2A.png", "https://www.mollie.com/external/icons/ideal-issuers/ABNANL2A%402x.png", "https://www.mollie.com/external/icons/ideal-issuers/ABNANL2A.svg" ] }, "links": { "self": "https://api.monoz.test/api/v1/payment-issuers/ideal_ABNANL2A" } } ] }
安全
如果您发现任何安全相关的问题,请通过电子邮件 security[at]pixelpillow.nl 而不是使用问题跟踪器。
致谢
- 所有贡献者
- Lunar 为提供出色的电子商务包。
- Dystcz 为创建 Lunar API 包。
- Laravel JSON:API,这是 Laravel 应用程序的杰出 JSON:API 层
- Mollie 为提供出色的支付服务。
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。