setMerId('777290058167387'); //商户号 $gateway->setCertPath(to_linux_path(app_path()) . '/certs/700000000000001_acp.p12'); // 商户私钥证书 $gateway->setCertDir(to_linux_path(app_path()) . '/certs/verify_sign_acp.cer'); //测试环境银联公钥证书 $gateway->setCertPassword('000000'); // 密码 $gateway->setReturnUrl(route('web.unpay.return')); // 支付后同步通知页面地址 $gateway->setNotifyUrl(route('web.unpay.return')); return $gateway; } public function pay() { $order = [ 'orderId' => date('YmdHis') . mt_rand(1000, 9999), // 订单号 'txnTime' => date('YmdHis'), 'orderDesc' => 'UnionPay Test', //订单名称 'txnAmt' => ('15' * 100), //订单价格,单位是:"分" 1x100 ]; $gateway = $this->UnionPayConfig(); $response = $gateway->purchase($order)->send(); //$response->redirect(); // 发起银联支付请求 // $response = $gateway->purchase($order)->send(); echo '
'.$response->getRedirectHtml().'
'; } public function result(Request $request) { dump($request->all()); echo $request->input('orderId'); $gateway = Omnipay\Omnipay::create('UnionPay_Express'); $gateway->setMerId('777290058167387'); $gateway->setPublicKey(to_linux_path(app_path()) . '/certs/verify_sign_acp.cer'); // path or content $response = $gateway->completePurchase(['request_params' => $_REQUEST])->send(); if ($response->isPaid()) { //pay success $data = $response->getData(); dump($data); //dump($response); echo 'respcode=00,success!'; } else { echo 111; } } }