PHP code example of monster / wechatpay

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

    

monster / wechatpay example snippets




onster\WeChatPay;

$config = new WeChatPay\Config(
    'wx08fea2xxxxxxxx',
    '1284xxxxx',
    '4e3a3ee44006xxxxxxxxxxxx',
    '64dc8c89f7310xxxxxxxxxxxx',
    'http://example.com/wechatpay/notify'
);

$order = new WeChatPay\Order($config);

$order->setBody('buy some product');
$order->setTotalFee(0.01);
$order->setProductId('20151212120434234435');
$order->setOutTradeNo('2015121213232424323523');

$unifiedOrder = new WeChatPay\Order\UnifiedOrder($order);

$response = $unifiedOrder->send();
var_dump($response);
$prePayOrder = $unifiedOrder->getPrePayOrder();
var_dump($prePayOrder);