PHP code example of siganushka / wxpay-api

1. Go to this page and download the library: Download siganushka/wxpay-api 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/ */

    

siganushka / wxpay-api example snippets


// src/Controller/DefaultController.php

use Siganushka\ApiFactory\Wxpay\Unifiedorder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class DefaultController extends AbstractController
{
    public function index(Unifiedorder $request)
    {
        $options = [
            'body' => '统一下单测试订单',
            'notify_url' => 'http://localhost',
            'out_trade_no' => uniqid(),
            'total_fee' => 1,
            'trade_type' => 'APP',
        ];

        $result = $request->send($options);
        var_dump($result);
    }
}