ryandadeng/securepay-secureframe

SecurePay SecureFrame for Laravel 5

dev-master 2018-08-14 05:47 UTC

This package is auto-updated.

Last update: 2024-09-24 21:22:17 UTC


README

SecurePay 的 SecureFrame 解决方案。

安装

将以下行添加到 composer.json 的 require 部分

{
    "require": {
        "ryandadeng/securepay-secureframe": "dev-master"
    }
}

针对 Laravel <= 5.4 的设置

  1. 在 /config/app.php 中,添加以下内容到 providers
Ryandadeng\Securepayframe\SecurePayFrameServiceProvider::class
  1. 运行 php artisan vendor:publish --provider="Ryandadeng\Securepayframe\SecurePayFrameServiceProvider"

针对 Laravel >= 5.5 的设置

只需运行 php artisan vendor:publish --provider="Ryandadeng\Securepayframe\SecurePayFrameServiceProvider"

指南 - 如何使用

  1. 为 SecurePayCustomDataInterface 创建一个实现类
  2. 实现您自己的自定义动态数据
  3. 对于返回 URL,请提供您自己的路由 URL。
  4. 创建一个控制器以发送和接收来自 SecurePay 的数据

示例

namespace App\Http\Controllers;


use Illuminate\Http\Request;
use Ryandadeng\Securepayframe\Services\SecurePayFactory;

class SecurePayFrameController
{


    // GET - used to populate SecurePay by using SecureFrame
    public function send()
    {
        $send = SecurePayFactory::send(new SecurePaySecurePayCustomData());
        return view('welcome', ['sender' => $send]);
    }


    // POST - This route will be hooked when SecurePay return response. This request should not be accessed publicly which means it should not be have any auth middleware attached.
    public function receive(Request $request)
    {
        // test received data
        $receiver = SecurePayFactory::receive($request->all());

        if ($receiver->fails()) {
            return $receiver->errors();
        } else {
            return 'success';
        }
    }
}
  1. 注册您的两个路由,分别用于发送和接收请求。