PHP code example of sungmee / laravel-payment

1. Go to this page and download the library: Download sungmee/laravel-payment library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sungmee / laravel-payment example snippets


// 默认支付平台
'gateway' => env('PAY_GATEWAY', 'example'),

// 支付平台商户数据
'gateways' => [
    'example' => []
],

// 用户模型的命名空间
'userModel' => env('PAY_USER_MODEL', 'App\User'),

// 同步、异步通知地址
'returnUrl' => env('PAY_RETURN_URL', "$appUrl/payment/notify/page"),
'notifyUrl' => env('PAY_NOTIFY_URL', "$appUrl/payment/notify/offline"),

// 支付成功同步通知后跳转到的网址
'redirectTo' => env('PAY_REDIRECT_TO', $appUrl),

use Sungmee\LaraPay\Facade as Pay;

// 支付参数
$params = [];

// 银联支付,返回 POST 表单数组,用于前台组装跳转到支付页面
Pay::bankPay($params);

// 联合支付,返回 POST 表单数组,用于前台组装跳转到支付页面
Pay::unionPay($params);

// 扫码支付,返回二维码图片链接或二维码数据字符串
Pay::scanPay($params);

// 订单状态查询,返回 \Sungmee\LaraPay\Payment $payment 与查询结果数组组合
$order_no = 888; // 订单号,等同于 payments ID
Pay::query($order_no);

use Sungmee\LaraPay\Pay;

$pay = new Pay;
$gateway = $pay->Example();

$gateway->bankPay();
$gateway->unionPay();
$gateway->scanPay();
...