-
Notifications
You must be signed in to change notification settings - Fork 316
payment_unifiedorder
thenbsp edited this page Mar 5, 2016
·
3 revisions
use Thenbsp\Wechat\Payment\Unifiedorder;
$unifiedorder = new Unifiedorder('appid', 'mch_id', 'key');
// 必填
$unifiedorder->set('body', '微信支付测试商品');
$unifiedorder->set('total_fee', 1);
$unifiedorder->set('openid', 'OPENID');
$unifiedorder->set('trade_type', 'JSAPI');
$unifiedorder->set('out_trade_no', date('YmdHis').mt_rand(10000, 99999));
$unifiedorder->set('notify_url', 'http://example.com/your-notify.php');
// 选填
$unifiedorder->set('device_info', 'WEB');
$unifiedorder->set('detail', '商品详情');
$unifiedorder->set('attach', '自定义附加数据');
$unifiedorder->set('fee_type', 'CNY');
$unifiedorder->set('time_start', '20091225091010');
$unifiedorder->set('time_expire', '20091227091010');
$unifiedorder->set('goods_tag', 'WXG');
$unifiedorder->set('limit_pay', 'no_credit');
try {
$response = $unifiedorder->getResponse();
} catch (\Exception $e) {
exit($e->getMessage());
}
// 下单结果
print_r($response->toArray());