hitpay_payment($out_trade_no,$money,$notifyurl); dump($rs); //payorder 保存 $rs['id'] 为 payment_request_id } public function hitpay_payment($out_trade_no,$money,$notifyurl) { $return = [ 'status' => false, 'msg' => '', 'url' => '', 'id' => 0, ]; $apiKey = config('hitpay.apikey'); try { $hitPayClient = new \HitPay\Client($apiKey, true); $request = new \HitPay\Request\CreatePayment(); $request->setAmount($money) ->setCurrency('SGD') ->setWebhook($notifyurl) ->setReferenceNumber($out_trade_no); $result = $hitPayClient->createPayment($request); $return['status'] = true; $return['url'] = $result->getUrl(); $return['id'] = $result->getId(); //print_r($result); /*$data = $hitPayClient->getPaymentStatus($result->getId()); dump($data); dump($data->status);*/ /*$data = $hitPayClient->deletePaymentRequest($data->getId()); print_r($data);*/ } catch (\Exception $e) { $return['msg'] = $e->getMessage(); } return $return; } /** * 需要登录的接口 * */ public function test2() { $url = 'https://api.hit-pay.com/v1/payment-requests'; $data = [ 'amount' => 1, //'payment_method' => ['paynow_online', 'card', 'wechat', 'alipay', 'grabpay', 'fave_duit', 'shopback', 'atome'], 'currency' => 'SGD', //'webhook' => '', ]; $header = array( 'X-BUSINESS-API-KEY' => '096a06e94fb1e0a8b015485bb76ef5dd63c167679297e07331a687327bd8b12e', 'Content-Type' => 'application/x-www-form-urlencoded', 'X-Requested-With' => 'XMLHttpRequest' ); $rs = curl_post($url,$data,$header); dump($rs); } /** * 需要登录且需要验证有相应组的权限 * */ public function test3() { $this->success('返回成功', ['action' => 'test3']); } }