PHP code example of easy-pay / sdk-laravel

1. Go to this page and download the library: Download easy-pay/sdk-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/ */

    

easy-pay / sdk-laravel example snippets



// routes/web.php

Route::get('wechat/qr', function () {
    $trade = app('wechat.qr.pay');

    $trade->attach = 'wechat pay test';
    $trade->body = '微信扫码支付,测试订单';
    $trade->out_trade_no = substr(md5(uniqid()), 0, 18) . date("YmdHis");
    $trade->total_fee = 1;
    $trade->spbill_create_ip = $_SERVER['REMOTE_ADDR'];
    $trade->product_id = 123;

    $url = $trade->execute();
    // 生成二维码
    $qrCode = (new Endroid\QrCode\QrCode($url))->setSize(300);

    return response($qrCode->get('png'), 200, ['Content-Type' => 'image/png']);
});