| @@ 38-64 (lines=27) @@ | ||
| 35 | * @author kaylv <[email protected]> |
|
| 36 | * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string |
|
| 37 | */ |
|
| 38 | public function barPay(AlipayTradePayContentBuilder $builder) |
|
| 39 | { |
|
| 40 | //创建 |
|
| 41 | $request = new AlipayTradePayRequest(); |
|
| 42 | $request->setBizContent($builder->getBizContent()); |
|
| 43 | ||
| 44 | //请求 |
|
| 45 | $response = $this->httpPost($request, $builder->getAppAuthToken()); |
|
| 46 | ||
| 47 | //获取 |
|
| 48 | $data = $response->alipay_trade_pay_response; |
|
| 49 | $sign = $response->sign; |
|
| 50 | ||
| 51 | //组装返回数据 |
|
| 52 | $result = new AlipayF2FPayResult($data, $sign); |
|
| 53 | ||
| 54 | //处理 |
|
| 55 | if (tradeSuccess($data)) { |
|
| 56 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS); |
|
| 57 | } elseif (tradeError($data)) { |
|
| 58 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN); |
|
| 59 | } else { |
|
| 60 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED); |
|
| 61 | } |
|
| 62 | ||
| 63 | return $this->formatResponseToType($result); |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * 统一收单线下交易预创建(扫码支付) |
|
| @@ 120-149 (lines=30) @@ | ||
| 117 | * @author kaylv <[email protected]> |
|
| 118 | * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string |
|
| 119 | */ |
|
| 120 | public function query(AlipayTradeQueryContentBuilder $builder) |
|
| 121 | { |
|
| 122 | //查询 |
|
| 123 | $request = new AlipayTradeQueryRequest(); |
|
| 124 | $request->setBizContent($builder->getBizContent()); |
|
| 125 | ||
| 126 | //请求 |
|
| 127 | $response = $this->httpPost($request, $builder->getAppAuthToken()); |
|
| 128 | ||
| 129 | //获取 |
|
| 130 | $data = $response->alipay_trade_query_response; |
|
| 131 | $sign = $response->sign; |
|
| 132 | ||
| 133 | //组装返回数据 |
|
| 134 | $result = new AlipayF2FPayResult($data, $sign); |
|
| 135 | ||
| 136 | //处理 |
|
| 137 | if (querySuccess($data)) { |
|
| 138 | // 查询返回该订单交易支付成功 |
|
| 139 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS); |
|
| 140 | } elseif (tradeError($data)) { |
|
| 141 | //查询发生异常或无返回,交易状态未知 |
|
| 142 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN); |
|
| 143 | } else { |
|
| 144 | //其他情况均表明该订单号交易失败 |
|
| 145 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED); |
|
| 146 | } |
|
| 147 | ||
| 148 | return $this->formatResponseToType($result); |
|
| 149 | } |
|
| 150 | ||
| 151 | /** |
|
| 152 | * 统一收单交易撤销接口 |
|
| @@ 162-190 (lines=29) @@ | ||
| 159 | * @author kaylv <[email protected]> |
|
| 160 | * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string |
|
| 161 | */ |
|
| 162 | public function cancel(AlipayTradeCancelContentBuilder $builder) |
|
| 163 | { |
|
| 164 | $request = new AlipayTradeCancelRequest(); |
|
| 165 | $request->setBizContent($builder->getBizContent()); |
|
| 166 | ||
| 167 | //请求 |
|
| 168 | $response = $this->httpPost($request, $builder->getAppAuthToken()); |
|
| 169 | ||
| 170 | //获取 |
|
| 171 | $data = $response->alipay_trade_cancel_response; |
|
| 172 | $sign = $response->sign; |
|
| 173 | ||
| 174 | //组装返回数据 |
|
| 175 | $result = new AlipayF2FPayResult($data, $sign); |
|
| 176 | ||
| 177 | //处理 |
|
| 178 | if (tradeSuccess($data)) { |
|
| 179 | // 查询返回该订单交易支付成功 |
|
| 180 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS); |
|
| 181 | } elseif (tradeError($data)) { |
|
| 182 | //查询发生异常或无返回,交易状态未知 |
|
| 183 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN); |
|
| 184 | } else { |
|
| 185 | //其他情况均表明该订单号交易失败 |
|
| 186 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED); |
|
| 187 | } |
|
| 188 | ||
| 189 | return $this->formatResponseToType($result); |
|
| 190 | } |
|
| 191 | ||
| 192 | /** |
|
| 193 | * 统一收单交易关闭接口 |
|
| @@ 201-229 (lines=29) @@ | ||
| 198 | * @author kaylv <[email protected]> |
|
| 199 | * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string |
|
| 200 | */ |
|
| 201 | public function close(AlipayTradeCloseContentBuilder $builder) |
|
| 202 | { |
|
| 203 | $request = new AlipayTradeCloseRequest(); |
|
| 204 | $request->setBizContent($builder->getBizContent()); |
|
| 205 | ||
| 206 | //请求 |
|
| 207 | $response = $this->httpPost($request, $builder->getAppAuthToken()); |
|
| 208 | ||
| 209 | //获取 |
|
| 210 | $data = $response->alipay_trade_close_response; |
|
| 211 | $sign = $response->sign; |
|
| 212 | ||
| 213 | //组装返回数据 |
|
| 214 | $result = new AlipayF2FPayResult($data, $sign); |
|
| 215 | ||
| 216 | //处理 |
|
| 217 | if (tradeSuccess($data)) { |
|
| 218 | // 查询返回该订单交易支付成功 |
|
| 219 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS); |
|
| 220 | } elseif (tradeError($data)) { |
|
| 221 | //查询发生异常或无返回,交易状态未知 |
|
| 222 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN); |
|
| 223 | } else { |
|
| 224 | //其他情况均表明该订单号交易失败 |
|
| 225 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED); |
|
| 226 | } |
|
| 227 | ||
| 228 | return $this->formatResponseToType($result); |
|
| 229 | } |
|
| 230 | } |
|
| 231 | ||
| @@ 30-58 (lines=29) @@ | ||
| 27 | * @author kaylv <[email protected]> |
|
| 28 | * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string |
|
| 29 | */ |
|
| 30 | public function refund(AlipayTradeRefundContentBuilder $builder) |
|
| 31 | { |
|
| 32 | $request = new AlipayTradeRefundRequest(); |
|
| 33 | $request->setBizContent($builder->getBizContent()); |
|
| 34 | ||
| 35 | //请求 |
|
| 36 | $response = $this->httpPost($request, $builder->getAppAuthToken()); |
|
| 37 | ||
| 38 | //获取 |
|
| 39 | $data = $response->alipay_trade_refund_response; |
|
| 40 | $sign = $response->sign; |
|
| 41 | ||
| 42 | //组装返回数据 |
|
| 43 | $result = new AlipayF2FPayResult($data, $sign); |
|
| 44 | ||
| 45 | //处理 |
|
| 46 | if (tradeSuccess($data)) { |
|
| 47 | // 查询返回该订单交易支付成功 |
|
| 48 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS); |
|
| 49 | } elseif (tradeError($data)) { |
|
| 50 | //查询发生异常或无返回,交易状态未知 |
|
| 51 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN); |
|
| 52 | } else { |
|
| 53 | //其他情况均表明该订单号交易失败 |
|
| 54 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED); |
|
| 55 | } |
|
| 56 | ||
| 57 | return $this->formatResponseToType($result); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||