集成支付接口
- payJs
<dependency>
<groupId>com.seepine</groupId>
<artifactId>spring-boot-starter-pay</artifactId>
<version>0.1.0</version>
</dependency>
application.yml
pay-js:
m-ch-id: ${your mChId}
secret: ${your secret}
notify-url: ${your notifyUrl}
注入template
@Autowire
private PayJsTemplate payJsTemplate;
默认回调地址
PayJsRes payRes = payJsTemplate.channel().pay(String subject, //商品标题
String outTradeNo, //已方生成订单号
Double amount); //金额,单位元
手动填写回调地址
PayJsRes payRes = payJsTemplate.channel().pay(String subject, //商品标题
String outTradeNo, //已方生成订单号
Double amount, //金额,单位元
String notifyUrl); //异步通知回调地址
@ResponseBody
@PostMapping(value = "notify")
public Object fallback(PayJsReq payJsReq){
Boolean isSign = payJsTemplate.channel().checkSign(payJsReq);
//业务逻辑...
}
application.yml,以逗号隔开
pay-js:
m-ch-id: ${mChId1},${mChId2}
secret: ${secret1},${secret2}
notify-url: ${notifyUrl1},${notifyUrl1}
注入template
@Autowire
private PayJsTemplate payJsTemplate;
通过channel(index)来指定商户,从0开始
PayJsRes payRes = payJsTemplate.channel(${index}).pay(String subject, //商品标题
String outTradeNo, //已方生成订单号
Double amount); //金额,单位元