PHP code example of nonfu / payjs-laravel

1. Go to this page and download the library: Download nonfu/payjs-laravel 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/ */

    

nonfu / payjs-laravel example snippets


return [
    'wechat' => [
        'mchid' => '', // 填写商户号
        'key'   => '', // 填写通信KEY
    ],
    'alipay' => [
        'mchid' => '', // 填写商户号
        'key'   => '', // 填写通信KEY
    ]
];

use Nonfu\Payjs\Facades\Payjs;

// 构造订单基础信息
$data = [
    'body' => '订单测试',                                // 订单标题
    'total_fee' => 2,                                   // 订单标题
    'out_trade_no' => time(),                           // 订单号
    'attach' => 'test_order_attach',                    // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',     // 异步通知地址(可选参数)
];
Payjs::setPayType('wechat');
return Payjs::native($data);

// 支付宝
$data = [
    'body' => '订单测试',   
    'type' => 'alipay',                                 // 支付方式
    'total_fee' => 2,                                   // 订单标题
    'out_trade_no' => time(),                           // 订单号
    'attach' => 'test_order_attach',                    // 订单附加信息(可选参数)
    'notify_url' => 'https://www.baidu.com/notify',     // 异步通知地址(可选参数)
];
Payjs::setPayType('alipay');
return Payjs::native($data);
shell
php artisan vendor:publish --provider="Nonfu\Payjs\PayjsServiceProvider"