承接 webcraft/lunar-mollie 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

webcraft/lunar-mollie

Composer 安装命令:

composer create-project webcraft/lunar-mollie

包简介

Mollie payment driver for Lunar.

README 文档

README

MIT Licensed GitHub Workflow Status

Lunar is a leading package that brings e-commerce functionality to Laravel.

Mollie is a payment provider that offers support for a diverse range of payment methods, such as: Apple Pay, Bancontact, Bank Transfer, Belfius, Credit Card, Direct Debit, EPS, Gift Card, Giropay, iDEAL, KBC, MyBank, PayPal, Paysafecard, Przelewy24 and Sofort.

This addon provides an implementation of Lunar's AbstractPayment interface for Mollie, and a payment component to be used in your storefront. It is built using Laravel Livewire and Tailwind.

Requirements

  • Lunar >= 0.4
  • A Mollie account
  • Laravel Livewire (if using frontend components)

Installation

Require the composer package

composer require webcraft/lunar-mollie

Publish the configuration

This will publish the configuration under config/lunar/mollie.php.

php artisan vendor:publish --tag=lunar.mollie.config

Publish the views (optional)

Lunar Mollie comes with a helper component for you to use on your checkout, if you intend to edit the views it provides, you can publish them.

php artisan vendor:publish --tag=lunar.mollie.components

Publish the translations (optional)

The checkout component uses translations for the buttons, payment methods, etc. If you want to edit these, you can publish them.

php artisan vendor:publish --tag=lunar.mollie.translations

Enable the driver

Set the driver in config/lunar/payments.php

<?php

return [
    // ...
    'types' => [
        'mollie' => [
            'driver' => 'mollie',
        ],
    ],
];

Add your Mollie credentials and other config

Take a look at the configuration in config/mollie.php. Where approriate, edit or set the environment variables in your .env file. At least the keys will need to be set.

MOLLIE_LIVE_KEY=
MOLLIE_TEST_KEY=

Keys can be found in your Mollie account: https://my.mollie.com/dashboard/developers/api-keys

You can use the MOLLIE_TEST_MODE environment variable to switch between live and test mode.

Storefront Usage

This addon provides a payment component to be used in your storefront. It is built using Laravel Livewire and Tailwind. Make sure these dependencies are installed and configured before continuing.

Add the payment component

Payment component screenshot

Wherever you want the payment form to appear, add this component:

@livewire('mollie.payment', [
    'cart' => $cart,
])

If you are using Lunar's Livewire Starter Kit, you can add this code to the payment.blade.php view, e.g.:

<div class="bg-white border border-gray-100 rounded-xl">
    <div class="flex items-center h-16 px-6 border-b border-gray-100">
        <h3 class="text-lg font-medium">
            Payment
        </h3>
    </div>

    @if ($currentStep >= $step)
        <div class="p-6 space-y-4">
            @livewire('mollie.payment', [
                'cart' => $cart,
            ])
        </div>
    @endif

</div>

By default, the component will just show a Proceed to payment button, redirecting the user to Mollie's hosted payment method selection screen.

If you want the available payment methods to be shown straight from your checkout form, go to config/lunar/mollie.php, set specify_payment_methods to true and uncomment all your available payment methods in payment_methods. Don't forget these payment methods will need to be enabled in your Mollie account as well.

[
    //...
    
    'specify_payment_methods' => true,

    'payment_methods' => [
        'bancontact',
        'creditcard',
        'ideal',
        'paypal',
    ],
]

Webhooks

Mollie will send a webhook to your application after every payment attempt (whether successful or not). The route and logic for handling this webhook is already implemented. If you prefer to write your own logic however, you can create a named route for this yourself, and change the webhook_route config value to the name of your route.

Implement the redirect routes

After a payment attempt, Mollie will redirect the user back to your application. By default, the MollieRedirectController will handle this redirect and redirect the user to the checkout success or failure pages. If you want to implement your own logic, you can create a named route for this yourself, and change the redirect_route config value to the name of your route.

While the MollieRedirectController is already implemented by the package, this is just a pass-through controller that will redirect the user to the checkout success or failure pages. These status pages are not implemented by the package, since they probably are specific to your theme. There are 4 statuses that need a page: paid, canceled, open and failed. You need to create named routes for these yourself, named checkout-success.view, checkout-canceled.view, checkout-open.view and checkout-failure.view respectively. You can change these names in the config if you want to.

[
    //...
    
    'payment_paid_route' => 'checkout-success.view',
    'payment_canceled_route' => 'checkout-canceled.view',
    'payment_open_route' => 'checkout-open.view',
    'payment_failed_route' => 'checkout-failure.view',
]

Here is an example of how a component for the checkout success page could look like:

//app/Http/Livewire/CheckoutSuccessPage.php

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use Lunar\Facades\CartSession;
use Lunar\Models\Cart;
use Lunar\Models\Order;

class CheckoutSuccessPage extends Component
{
    public ?Cart $cart;

    public Order $order;

    public function mount()
    {
        $this->cart = CartSession::current();

        if (! $this->cart || ! $this->cart->completedOrder) {
            $this->redirect('/');

            return;
        }
        $this->order = $this->cart->completedOrder;

        CartSession::forget();
    }

    public function render()
    {
        return view('livewire.checkout-success-page');
    }
}
//resources/views/livewire/checkout-success-page.blade.php

<section class="bg-white">
    <div class="max-w-screen-xl px-4 py-32 mx-auto sm:px-6 lg:px-8 lg:py-48">
        <div class="max-w-xl mx-auto text-center">
            <h1 class="mt-8 text-3xl font-extrabold sm:text-5xl">
                <span class="block mt-1 text-blue-500">
                    Thank you for your order
                </span>
            </h1>

            <p class="mt-4 font-medium sm:text-lg">
                Your order reference number is

                <strong>
                    {{ $order->reference }}
                </strong>
            </p>

            <a class="inline-block px-8 py-3 mt-8 text-sm font-medium text-center text-white bg-blue-600 rounded-lg hover:ring-1 hover:ring-blue-600"
               href="{{ url('/') }}">
                Back Home
            </a>
        </div>
    </div>
</section>
//routes/web.php

Route::get('checkout/success', \App\Http\Livewire\CheckoutSuccessPage::class)->name('checkout-success.view');

You can do something similar for the other status pages.

Testing

composer test

Contributing

Contributions are welcome, if you are thinking of adding a feature, please submit an issue first.

About Webcraft

Webcraft is the company of Michiel Loncke, a freelance web developer from Belgium, specialized in building custom web applications and e-commerce solutions using Laravel and Lunar. If you need help with your project, feel free to get in touch.

webcraft/lunar-mollie 适用场景与选型建议

webcraft/lunar-mollie 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 265 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 08 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「shop」 「ecommerce」 「cart」 「store」 「paypal」 「headless」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 webcraft/lunar-mollie 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 webcraft/lunar-mollie 我们能提供哪些服务?
定制开发 / 二次开发

基于 webcraft/lunar-mollie 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 265
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-14