文章目录
- 1、前置
- 2、准备工作
- 3、Kapitalbank 绑卡
- 4、Kapitalbank 创建交易
- 5、Kapitalbank 交易付款
- 6、Kapitalbank 查询付款状态
- 7:杂谈
1、前置
1、乌兹别克斯坦的一个支付, 这也是一个非常简单的支付, 很赞! Kapitalbank这是一家银行. 官网地址:https://developer.authorize.net/
2、案列采用java编写
3、网站进不去, 有白名单, 需要配置白名单进行:
文档可以自行询问客户
参考地址:kapitalbank.az/birbank
4、会对一些可能出现的坑,或者说我碰到的坑进行标记
5、介最后贴图验证以及做好后的样子
6、流程: 绑卡 ---- 创建交易 ----- 付款 — 查询订单
7、代码已上传码云,如果起到帮助还请star一下地址:https://gitee.com/xmaxm/payments_hodgepodge
2、准备工作
没有, 因为没有登录不进去, 我也不知道
需要说明一点, 测试金额从5000, 还是10000才是最小金额
很重要一点: 因为需要白名单, 我贴不了对应的结果, 懒得去服务器上面把结果贴出来, 代码都是一样的
3、Kapitalbank 绑卡
public CommonResult kapitalbankTiedCard(String cardNumber, String expYearMonth) {Map<String, String> map = new HashMap<>();map.put("content-type", "application/json");map.put("Authorization", TOKEN);try {String getToken = GET_TOKEN.replaceAll("PAN", cardNumber.replace(" ", "")).replaceAll("EXPIRY", expYearMonth.replace("/", ""));String post = HttpsUtils.HttpsRequest(getToken, "GET", null, map);JSONObject jsonObject = JSONObject.parseObject(post);if (!"OK".equals(jsonObject.getString("status"))) {return CommonResult.failMessage(500, "FAIL", jsonObject.getString("errorMessage"));}// 获取 tokenString data = jsonObject.getString("data");JSONObject jsonObjectData = JSONObject.parseObject(data);// 这个token值很重要, 会在后面的付款中使用到return CommonResult.success("SUCCESS", jsonObjectData.getString("token"));} catch (Exception e) {log.error("Kapitalbank 绑卡操作异常: " + e);return CommonResult.fail(500, "NetworkTimeout");}}
4、Kapitalbank 创建交易
// token 绑卡后返回的值
public CommonResult createKapitalbank(int amount, String token) {Map<String, String> map = new HashMap<>();map.put("content-type", "application/json");map.put("Authorization", TOKEN);JSONObject jsonObjectRequest = new JSONObject();jsonObjectRequest.put("amount", amount);jsonObjectRequest.put("cashId", CASH_ID);jsonObjectRequest.put("token", token);jsonObjectRequest.put("userData", "jsonObject");try {String post = HttpsUtils.HttpsRequest(CREATE_ORDER, "POST", jsonObjectRequest.toString(), map);JSONObject jsonObjectResponse = JSONObject.parseObject(post);if (!"OK".equals(jsonObjectResponse.getString("status"))) {return CommonResult.failMessage(500, "FAIL", jsonObjectResponse.getString("errorMessage"));}// 返回data, 里面有电话号码(maskedPhoneNumber), 还有一个订单号(id):这个ID值很重要, 后面会使用到String data = jsonObjectResponse.getString("data");return CommonResult.success("SUCCESS", data);} catch (Exception e) {log.error("Kapitalbank 创建交易操作异常: " + e);return CommonResult.fail(500, "NetworkTimeout");}}
5、Kapitalbank 交易付款
// transactionId: 创建交易时返回的数据 smsCode:短信验证码, 创建交易后会向那个手机号码发送一条短信
public CommonResult payKapitalbank(String smsCode, String transactionId) {Map<String, String> map = new HashMap<>();map.put("content-type", "application/json");map.put("Authorization", TOKEN);JSONObject jsonObjectRequest = new JSONObject();jsonObjectRequest.put("cashId", CASH_ID);jsonObjectRequest.put("sms", smsCode);jsonObjectRequest.put("transactionId", transactionId);try {String post = HttpsUtils.HttpsRequest(PAY_ORDER, "POST", jsonObjectRequest.toString(), map);JSONObject jsonObjectResponse = JSONObject.parseObject(post);if (!"OK".equals(jsonObjectResponse.getString("status")) || !"success".equals(jsonObjectResponse.getString("data"))) {return CommonResult.failMessage(500, "FAIL", jsonObjectResponse.getString("errorMessage"));}return CommonResult.success("SUCCESS");} catch (Exception e) {log.error("Kapitalbank 交易付款操作异常: " + e);return CommonResult.fail(500, "NetworkTimeout");}}
6、Kapitalbank 查询付款状态
// transactionId: 创建交易时返回的数据
public CommonResult quyerKapitalbank(String transactionId) {Map<String, String> map = new HashMap<>();map.put("content-type", "application/json");map.put("Authorization", TOKEN);JSONObject jsonObjectRequest = new JSONObject();jsonObjectRequest.put("cashId", CASH_ID);jsonObjectRequest.put("transactionId", transactionId);try {String post = HttpsUtils.HttpsRequest(QUERY_ORDER, "POST", jsonObjectRequest.toString(), map);JSONObject jsonObjectResponse = JSONObject.parseObject(post);if (!"OK".equals(jsonObjectResponse.getString("status"))) {return CommonResult.failMessage(500, "FAIL", jsonObjectResponse.getString("errorMessage"));}return CommonResult.success("SUCCESS");} catch (Exception e) {log.error("Kapitalbank 查询付款状态操作异常: " + e);return CommonResult.fail(500, "NetworkTimeout");}}
7:杂谈
1、很简单的一个支付, 客户给人的感觉很有亲和力!
2、捕获和授权的流程, 如果不清楚, 可以参考我支付系列的文章PayPal支付
3、简单贴一下文档的截图, 因为涉及到很多客户隐私
提供一个群:807770565,欢迎各位进来尬聊 (人不多, 进了就不要退了, 要不就不进, 跪求留一点人, 人多了就活跃了, 跪谢)