$o->authorize(Util::currentUrl()); } else { $token = $o->getAccessToken($_GET['code']); $_SESSION['openid'] = $token->openid; } } /** * 第 1 步:定义商户 * 设置商户证书路径请使用 setClientCert/setClientKey * $business->setClientCert('/your/path/to/apiclient_cert.pem'); * $business->setClientKey('/your/path/to/apiclient_key.pem'); */ $business = new Business(); $business->appid(APPID); $business->appsecret(APPSECRET); $business->mch_id(MCHID); $business->mch_key(MCHKEY); // print_r($business->getParams()); /** * 第 2 步:定义订单 */ $order = new Order(); $order->body('iphone 6 plus'); $order->out_trade_no(date('Y-m-dHis') . mt_rand(10000, 99999)); $order->total_fee('1'); // $order->openid($_SESSION['openid']); $order->openid('oWY-5jjLjo7pYUK86JPpwvcnF2Js'); $order->notify_url('http://code.1999.me/Wechat/example/payment_notify.php'); // print_r($order->getParams()); /** * 第 3 步:统一下单