Skip to content

Commit

Permalink
Update Consume
Browse files Browse the repository at this point in the history
  • Loading branch information
hookszhang committed Jul 26, 2016
1 parent 4c046f5 commit ae24cdf
Showing 1 changed file with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,36 @@
import java.util.Map;

/**
* 消费
* 消费是指境内外持卡人在境内外商户网站进行购物等消费时用银行卡结算的交易,经批准的消费额将即时地反映到该持卡人的账户余额上。
*
* @author hookszhang on 7/26/16.
*/
public class Consume {

private Logger log = LoggerFactory.getLogger(Consume.class);

public Map<String, String> consume(String merId, String orderId, String txnTime, String txnAmt, String token) throws HttpException, SignValidateFailException {
/**
* 消费是指境内外持卡人在境内外商户网站进行购物等消费时用银行卡结算的交易,经批准的消费额将即时地反映到该持卡人的账户余额上。
* 交易步骤:
* <p>
* 1、商户组织消费交易报文,发送报文给全渠道系统;
* <p>
* 2、全渠道系统完成商户的交易处理;
* <p>
* 3、全渠道系统组织受理结果报文,返回给商户;
* <p>
* 4、因消费交易涉及资金清算,全渠道系统发送后台通知(交易结果)给商户。
*
* @param orderId 商户订单号,8-40位数字字母,不能含“-”或“_”,可以自行定制规则
* @param txnAmt 交易金额,单位分,不要带小数点
* @param token 从前台开通的后台通知中获取或者后台开通的返回报文中获取
* @param smsCode 短信验证码
* @param reqReserved 请求方保留域,透传字段(可以实现商户自定义参数的追踪)本交易的后台通知,对本交易的交易状态查询交易、对账文件中均会原样返回,商户可以按需上传,长度为1-1024个字节
* @return 应答报文
* @throws HttpException
* @throws SignValidateFailException
*/
public Map<String, String> consume(String orderId, String txnAmt, String token, String smsCode, String reqReserved) throws HttpException, SignValidateFailException {
Map<String, String> contentData = new HashMap<>();

/***银联全渠道系统,产品参数,除了encoding自行选择外其他不需修改***/
Expand All @@ -33,10 +54,10 @@ public Map<String, String> consume(String merId, String orderId, String txnTime,
contentData.put("channelType", "07"); //渠道类型07-PC

/***商户接入参数***/
contentData.put("merId", merId); //商户号码(本商户号码仅做为测试调通交易使用,该商户号配置了需要对敏感信息加密)测试时请改成自己申请的商户号,【自己注册的测试777开头的商户号不支持代收产品】
contentData.put("merId", Acp.merId); //商户号码(本商户号码仅做为测试调通交易使用,该商户号配置了需要对敏感信息加密)测试时请改成自己申请的商户号,【自己注册的测试777开头的商户号不支持代收产品】
contentData.put("accessType", "0"); //接入类型,商户接入固定填0,不需修改
contentData.put("orderId", orderId); //商户订单号,8-40位数字字母,不能含“-”或“_”,可以自行定制规则
contentData.put("txnTime", txnTime); //订单发送时间,格式为YYYYMMDDhhmmss,必须取当前时间,否则会报txnTime无效
contentData.put("txnTime", Acp.getCurrentTime()); //订单发送时间,格式为YYYYMMDDhhmmss,必须取当前时间,否则会报txnTime无效
contentData.put("currencyCode", "156"); //交易币种(境内商户一般是156 人民币)
contentData.put("txnAmt", txnAmt); //交易金额,单位分,不要带小数点
contentData.put("accType", "01"); //账号类型
Expand All @@ -49,13 +70,13 @@ public Map<String, String> consume(String merId, String orderId, String txnTime,
contentData.put("backUrl", Acp.backUrl);

//消费:token号(从前台开通的后台通知中获取或者后台开通的返回报文中获取),验证码看业务配置(默认要短信验证码)。
contentData.put("tokenPayData", "{token=" + token + "&trId=62000000001}");
contentData.put("tokenPayData", "{token=" + token + "&trId=" + Acp.trId + "}");
Map<String, String> customerInfoMap = new HashMap<>();
customerInfoMap.put("smsCode", "111111"); //短信验证码
customerInfoMap.put("smsCode", smsCode); //短信验证码
//customerInfoMap不送pin的话 该方法可以不送 卡号
String customerInfoStr = AcpService.getCustomerInfo(customerInfoMap, null, Acp.encoding_UTF8);
contentData.put("customerInfo", customerInfoStr);
//contentData.put("reqReserved", "透传字段"); //请求方保留域,透传字段(可以实现商户自定义参数的追踪)本交易的后台通知,对本交易的交易状态查询交易、对账文件中均会原样返回,商户可以按需上传,长度为1-1024个字节
contentData.put("reqReserved", reqReserved); //请求方保留域,透传字段(可以实现商户自定义参数的追踪)本交易的后台通知,对本交易的交易状态查询交易、对账文件中均会原样返回,商户可以按需上传,长度为1-1024个字节

//分期付款用法(商户自行设计分期付款展示界面):
//修改txnSubType=03,增加instalTransInfo域
Expand Down

0 comments on commit ae24cdf

Please sign in to comment.