wychoong/lunarphp-mpgs 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

wychoong/lunarphp-mpgs

最新稳定版本:v0.1.2

Composer 安装命令:

composer require wychoong/lunarphp-mpgs

包简介

MPGS payment adapter for Lunar

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

MPGS Hosted checkout integration for Lunar

Supported action

  • purchase

Not supported (PR welcome)

  • refund
  • authorize/capture

Installation

You can install the package via composer:

composer require wychoong/lunarphp-mpgs

You can publish the config file with:

php artisan vendor:publish --tag="lunarphp-mpgs-config"

Enable the driver

Set the driver in config/lunar/payments.php

<?php

return [
    // ...
    'types' => [
        'card' => [
            'driver' => 'stripe',
            'authorized' => 'payment-received',  # or any status key configured in lunar.orders.statuses
        ],
    ],
];

###Add your MPGS credentials Set your MPGS_ variable in .env

MPGS_MERCHANT_ID=
MPGS_API_PASSWORD=
MPGS_VERSION=

Setup

We use closure to return the data you want to pass to the api

use \WyChoong\Mpgs\Facades\Mpgs;

// in service provider `boot` method
Mpgs::initiateCheckoutUsing(function ($cart, $amount, $currency): array {
    if (!$order = $cart->order) {
        $order = $cart->createOrder();
    }

    $reference = $order->reference . date('Ymdhis');

    return  [
        // refer to the api spec for Initiate Checkout params
        'order' => [
            'id' => $reference,
            'currency' => $currency,
            'amount' => $amount,
            'description' => "Payment for #" . $order->reference,
            'reference' => $reference,
        ],
        'transaction' => [
            'reference' => $reference,
        ],
        'interaction' => [
            'merchant' => [
                'name' => 'Lunar store',
            ],
            'displayControl' => [
                'billingAddress' => 'HIDE',
            ]
        ]
    ];
});

Backend Usage

Creating a PaymentIntent

use \WyChoong\Mpgs\Facades\Mpgs;

Mpgs::createIntent(\Lunar\Models\Cart $cart);

This method will initiate a checkout session to be used by checkout.js Latest session and order.id are stored in cart's meta

'meta' => [
    'payment_intent' => `session`,
    'order_id' => `order.id`,
],

Storefront Usage

This package only provide basic blade components to interact with MPGS,, publish the views to fit your storefront design

php artisan vendor:publish --tag="lunarphp-mpgs-views"

Set up the scripts and payment component

In the your checkout page

@mpgsScripts

@if ($paymentType == 'card')
    <livewire:mpgs.payment :cart="$cart" />
@endif

The component will handle the success payment for you. To redirect or add handling after payment verified, set your route or listen to livewire event

// config/lunar-mpgs.php
'route' => [
    'payment-success' => null,
    'payment-failed' => null,
]

// livewire events
'mpgsPaymentSuccess'
'mpgsPaymentFailed'

Roadmap

  • support capture/refund if applicable
  • implement omnipay-mpgs adapter

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固