@@ -205,6 +205,21 @@ public boolean verifySource(String id) {
205205 return false ;
206206 }
207207
208+ /**
209+ * 订单超时时间。
210+ * 超过此时间后,除网银交易外,其他交易银联系统会拒绝受理,提示超时。 跳转银行网银交易如果超时后交易成功,会自动退款,大约5个工作日金额返还到持卡人账户。
211+ * 此时间建议取支付时的北京时间加15分钟。
212+ * 超过超时时间调查询接口应答origRespCode不是A6或者00的就可以判断为失败。
213+ * @param expirationTime 超时时间
214+ * @return 具体的时间字符串
215+ */
216+ private String getPayTimeout (Date expirationTime ) {
217+ //
218+ if (null != expirationTime ) {
219+ return DateUtils .formatDate (expirationTime , DateUtils .YYYYMMDDHHMMSS );
220+ }
221+ return DateUtils .formatDate (new Timestamp (System .currentTimeMillis () + 30 * 60 * 1000 ), DateUtils .YYYYMMDDHHMMSS );
222+ }
208223 /**
209224 * 返回创建的订单信息
210225 *
@@ -215,7 +230,11 @@ public boolean verifySource(String id) {
215230 @ Override
216231 public Map <String , Object > orderInfo (PayOrder order ) {
217232 Map <String , Object > params = this .getCommonParam ();
218-
233+ // if(order instanceof UnionPayOrder){
234+ // UnionPayOrder unionPayOrder = (UnionPayOrder)order;
235+ // //todo 其他参数
236+ //// params.put();
237+ // }
219238 UnionTransactionType type = (UnionTransactionType ) order .getTransactionType ();
220239
221240
@@ -230,18 +249,11 @@ public Map<String, Object> orderInfo(PayOrder order) {
230249 switch (type ) {
231250 case WAP :
232251 case WEB :
252+ //todo PCwap网关跳转支付特殊用法.txt
233253 case B2B :
234254 params .put (SDKConstants .param_txnAmt , Util .conversionCentAmount (order .getPrice ()));
235255 params .put ("orderDesc" , order .getSubject ());
236- // 订单超时时间。
237- // 超过此时间后,除网银交易外,其他交易银联系统会拒绝受理,提示超时。 跳转银行网银交易如果超时后交易成功,会自动退款,大约5个工作日金额返还到持卡人账户。
238- // 此时间建议取支付时的北京时间加15分钟。
239- // 超过超时时间调查询接口应答origRespCode不是A6或者00的就可以判断为失败。
240- if (null != order .getExpirationTime ()) {
241- params .put (SDKConstants .param_payTimeout , DateUtils .formatDate (order .getExpirationTime (), DateUtils .YYYYMMDDHHMMSS ));
242- } else {
243- params .put (SDKConstants .param_payTimeout , DateUtils .formatDate (new Timestamp (System .currentTimeMillis () + 30 * 60 * 1000 ), DateUtils .YYYYMMDDHHMMSS ));
244- }
256+ params .put (SDKConstants .param_payTimeout , getPayTimeout (order .getExpirationTime ()));
245257
246258 params .put (SDKConstants .param_frontUrl , payConfigStorage .getReturnUrl ());
247259 break ;
@@ -250,18 +262,15 @@ public Map<String, Object> orderInfo(PayOrder order) {
250262 params .put (SDKConstants .param_qrNo , order .getAuthCode ());
251263 break ;
252264 case APPLY_QR_CODE :
253- if (null != order .getPrice ()){
265+ if (null != order .getPrice ()) {
254266 params .put (SDKConstants .param_txnAmt , Util .conversionCentAmount (order .getPrice ()));
255267 }
256-
257- if (null != order .getExpirationTime ()) {
258- params .put (SDKConstants .param_payTimeout , DateUtils .formatDate (order .getExpirationTime (), DateUtils .YYYYMMDDHHMMSS ));
259- } else {
260- params .put (SDKConstants .param_payTimeout , DateUtils .formatDate (new Timestamp (System .currentTimeMillis () + 30 * 60 * 1000 ), DateUtils .YYYYMMDDHHMMSS ));
261- }
262-
268+ params .put (SDKConstants .param_payTimeout , getPayTimeout (order .getExpirationTime ()));
263269 break ;
264270 default :
271+ params .put (SDKConstants .param_txnAmt , Util .conversionCentAmount (order .getPrice ()));
272+ params .put (SDKConstants .param_payTimeout , getPayTimeout (order .getExpirationTime ()));
273+ params .put ("orderDesc" , order .getSubject ());
265274 }
266275
267276 return setSign (params );
@@ -370,7 +379,7 @@ public BufferedImage genQrPay(PayOrder order) {
370379 }
371380 if (this .verify (response )) {
372381 if (SDKConstants .OK_RESP_CODE .equals (response .get (SDKConstants .param_respCode ))) {
373- //成功,获取tn号
382+ //成功
374383 return MatrixToImageWriter .writeInfoToJpgBuff ((String ) response .get (SDKConstants .param_qrCode ));
375384 }
376385 throw new PayErrorException (new PayException ((String ) response .get (SDKConstants .param_respCode ), (String ) response .get (SDKConstants .param_respMsg ), responseStr ));
@@ -435,11 +444,11 @@ public PayOutMessage successPayOutMessage(PayMessage payMessage) {
435444 }
436445
437446 /**
438- * 获取输出消息,用户返回给支付端, 针对于web端
447+ * 功能:生成自动跳转的Html表单
439448 *
440449 * @param orderInfo 发起支付的订单信息
441450 * @param method 请求方式 "post" "get",
442- * @return 获取输出消息,用户返回给支付端, 针对于web端
451+ * @return 生成自动跳转的Html表单返回给支付端, 针对于PC端
443452 * @see MethodType 请求类型
444453 */
445454 @ Override
@@ -463,6 +472,30 @@ public String buildRequest(Map<String, Object> orderInfo, MethodType method) {
463472 return sf .toString ();
464473 }
465474
475+ /**
476+ * 功能:将订单信息进行签名并提交请求
477+ * 业务范围:手机控件支付产品(WAP),
478+ * @param order 订单信息
479+ * @return 成功:返回支付结果 失败:返回
480+ */
481+ public Map <String ,Object > sendHttpRequest (PayOrder order ){
482+ Map <String , Object > params = orderInfo (order );
483+ String responseStr = getHttpRequestTemplate ().postForObject (this .getBackTransUrl (), params , String .class );
484+ Map <String , Object > response = UriVariables .getParametersToMap (responseStr );
485+ if (response .isEmpty ()) {
486+ throw new PayErrorException (new PayException ("failure" , "响应内容有误!" , responseStr ));
487+ }
488+ if (this .verify (response )) {
489+ if (SDKConstants .OK_RESP_CODE .equals (response .get (SDKConstants .param_respCode ))) {
490+ // //成功,获取tn号
491+ // String tn = (String)response.get(SDKConstants.param_tn);
492+ // //TODO
493+ return response ;
494+ }
495+ throw new PayErrorException (new PayException ((String ) response .get (SDKConstants .param_respCode ), (String ) response .get (SDKConstants .param_respMsg ), responseStr ));
496+ }
497+ throw new PayErrorException (new PayException ("failure" , "验证签名失败" , responseStr ));
498+ }
466499
467500 /**
468501 * 交易查询接口
0 commit comments