stalinko/laravel-mpay24 问题修复 & 功能扩展

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

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

stalinko/laravel-mpay24

Composer 安装命令:

composer require stalinko/laravel-mpay24

包简介

README 文档

README

This package is a plugin for Laravel 5 for working with mpay24.com payments.

Installation

Install using composer: composer require stalinko/laravel-mpay24

Then add this to providers list in config/app.php:

    'LaravelMPay24\LaravelMPay24ServiceProvider',

Give settings for the new service in config/services.php:

    'mpay24' => [
        'merchantId' => 'XXXXXXX', //required
        'password' => 'XXXXXXXX', //required
        'test' => true, //optional
        'debug' => true, //optional
        'successUrl' => 'WelcomeController@anySuccess', //optional
        'errorUrl' => 'WelcomeController@anyError', //optional
        'confirmationUrl' => 'WelcomeController@anyConfirmation', //optional
    ],

Usage

Now you have a service app()->mpay24 which is object of \LaravelMPay24\Shop class. This object initiates MPay24Shop class for you with settings given in the config. To define logic of the shop you must create your own shop class extending \LaravelMPay24\Models\AbstractShop, instantiate an object of that class and pass it to app()->mpay24 service:

    $shopDelegator = new BasicShop();
    app()->mpay24->setShopDelegator($shopDelegator);

Thus mpay24 will delegate all it's actions to your shop. BasicShop is an example implementation of the delegator shop, you can find it in the package.

app()->mpay24 sets callback urls to the ORDER object using the service settings. But you are free to set it in your custom shop class, app()->mpay24 won't override these setting.

Working example

Example controller (WelcomeController.php):

namespace App\Http\Controllers;

use LaravelMPay24\Models\BasicShop;
use LaravelMPay24\ORDER;
use LaravelMPay24\PaymentResponse;
use LaravelMPay24\Transaction;

class WelcomeController extends Controller {
    /**
     * Show the application welcome screen to the user.
     *
     * @return \Illuminate\Http\Response
     */
    public function getIndex()
    {
        return view('welcome');
    }

    /**
     * Create a test transaction and redirect user to mpay24 page
     */
    public function postIndex()
    {
        $transaction = new Transaction('test transaction');
        $transaction->PRICE = 100.11;

        $order = new ORDER();
        $order->Order->Tid   = $transaction->TID;
        $order->Order->Price = $transaction->PRICE;

        $shopDelegator = new BasicShop();
        $shopDelegator->setTransaction($transaction);
        $shopDelegator->setOrder($order);

        /** @var \LaravelMPay24\Shop $mpay24 */
        $mpay24 = app()->mpay24;
        $mpay24->setShopDelegator($shopDelegator);
        /** @var PaymentResponse $result */
        $result = app()->mpay24->pay();

        if($result->getGeneralResponse()->getStatus() == 'OK') {
            $url = $result->getLocation();
            header('Location: '.$url);
        } else {
            echo "Return Code: " . $result->getGeneralResponse()->getReturnCode();
        }
    }

    public function anySuccess()
    {
        echo 'Success';
    }

    public function anyError()
    {
        echo 'Error';
    }

    public function anyConfirmation()
    {
        echo 'Confirmation';
    }
}

Code of welcome.blade.php:

<html>
 	<head>
 		<title>Payment Test</title>
 	</head>
 	<body>
         <form method="POST">
             <input type="hidden" name="_token" value="{{ csrf_token() }}">
             <input type="submit" value="Try it" />
         </form>
 	</body>
 </html>

stalinko/laravel-mpay24 适用场景与选型建议

stalinko/laravel-mpay24 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 486 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 05 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 stalinko/laravel-mpay24 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-05-27