mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 12:56:28 +08:00
5.0
This commit is contained in:
90
README.md
90
README.md
@@ -38,7 +38,7 @@ public interface OpenPayment {
|
||||
"该结果用于跳转到页面,返回到用户浏览器渲染或重定向跳转到页面。" +
|
||||
"具体使用方法请参考 <a href=\"https://torna.cn\" target=\"_blank\">接入指南</a>"
|
||||
)
|
||||
@Open(value = "pay.trade.wap.pay", version = "1.0")
|
||||
@Open("pay.trade.wap.pay")
|
||||
PayTradeWapPayResponse tradeWapPay(PayTradeWapPayRequest request);
|
||||
|
||||
}
|
||||
@@ -70,42 +70,66 @@ public class OpenPaymentImpl implements OpenPayment {
|
||||
调用:
|
||||
|
||||
```java
|
||||
@Test
|
||||
public void testGet() throws Exception {
|
||||
@Test
|
||||
public void testGet() throws Exception {
|
||||
// 公共请求参数
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("app_id", appId);
|
||||
params.put("method", "pay.trade.wap.pay");
|
||||
params.put("format", "json");
|
||||
params.put("charset", "utf-8");
|
||||
params.put("sign_type", "RSA2");
|
||||
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
params.put("version", "1.0");
|
||||
|
||||
// 业务参数
|
||||
Map<String, Object> bizContent = new HashMap<>();
|
||||
bizContent.put("outTradeNo", "70501111111S001111119");
|
||||
bizContent.put("totalAmount", "9.00");
|
||||
bizContent.put("subject", "衣服");
|
||||
bizContent.put("productCode", "QUICK_WAP_WAY");
|
||||
|
||||
params.put("biz_content", JSON.toJSONString(bizContent));
|
||||
String content = AlipaySignature.getSignContent(params);
|
||||
String sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8");
|
||||
params.put("sign", sign);
|
||||
|
||||
System.out.println("----------- 请求信息 -----------");
|
||||
System.out.println("请求参数:" + buildParamQuery(params));
|
||||
System.out.println("商户秘钥:" + privateKey);
|
||||
System.out.println("待签名内容:" + content);
|
||||
System.out.println("签名(sign):" + sign);
|
||||
System.out.println("URL参数:" + buildUrlQuery(params));
|
||||
|
||||
System.out.println("----------- 返回结果 -----------");
|
||||
String responseData = postJson(url, params);// 发送请求
|
||||
System.out.println(responseData);
|
||||
}
|
||||
```
|
||||
|
||||
// 公共请求参数
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("app_id", appId);
|
||||
params.put("method", "pay.trade.wap.pay");
|
||||
params.put("format", "json");
|
||||
params.put("charset", "utf-8");
|
||||
params.put("sign_type", "RSA2");
|
||||
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
params.put("version", "2.0");
|
||||
SDK调用
|
||||
|
||||
// 业务参数
|
||||
Map<String, Object> bizContent = new HashMap<>();
|
||||
bizContent.put("out_trade_no", "70501111111S001111119");
|
||||
bizContent.put("total_amount", "9.00");
|
||||
bizContent.put("subject", "衣服");
|
||||
bizContent.put("product_code", "QUICK_WAP_WAY");
|
||||
```java
|
||||
@Test
|
||||
public void test() {
|
||||
PayTradeWapPayRequest request = new PayTradeWapPayRequest();
|
||||
|
||||
PayTradeWapPayModel model = new PayTradeWapPayModel();
|
||||
model.setOutTradeNo("70501111111S001111119");
|
||||
model.setTotalAmount(new BigDecimal("1000"));
|
||||
model.setSubject("衣服");
|
||||
model.setProductCode("QUICK_WAP_WAY");
|
||||
|
||||
request.setBizModel(model);
|
||||
|
||||
params.put("biz_content", JSON.toJSONString(bizContent));
|
||||
String content = AlipaySignature.getSignContent(params);
|
||||
String sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8");
|
||||
params.put("sign", sign);
|
||||
|
||||
System.out.println("----------- 请求信息 -----------");
|
||||
System.out.println("请求参数:" + buildParamQuery(params));
|
||||
System.out.println("商户秘钥:" + privateKey);
|
||||
System.out.println("待签名内容:" + content);
|
||||
System.out.println("签名(sign):" + sign);
|
||||
System.out.println("URL参数:" + buildUrlQuery(params));
|
||||
|
||||
System.out.println("----------- 返回结果 -----------");
|
||||
String responseData = postJson(url, params);// 发送请求
|
||||
System.out.println(responseData);
|
||||
Result<PayTradeWapPayResponse> result = client.execute(request);
|
||||
if (result.isSuccess()) {
|
||||
PayTradeWapPayResponse response = result.getData();
|
||||
System.out.println(response);
|
||||
} else {
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 整体架构
|
||||
|
Reference in New Issue
Block a user