AlipayConfig.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.fdkankan.ucenter.pay.alipay.sdk;
  2. import com.alipay.demo.trade.service.AlipayTradeService;
  3. import com.alipay.demo.trade.service.impl.AlipayTradeServiceImpl;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.stereotype.Component;
  6. @Component
  7. public abstract class AlipayConfig {
  8. /** 签名类型 */
  9. private String signType = "RSA2";
  10. /** 格式 */
  11. private String formate = "json";
  12. /** 编码 */
  13. private String charset = "UTF-8";
  14. /** 最大查询次数 */
  15. private int maxQueryRetry = 5;
  16. /** 查询间隔(毫秒) */
  17. private long queryDuration = 5000;
  18. /** 最大撤销次数 */
  19. private int maxCancelRetry = 3;
  20. /** 撤销间隔(毫秒) */
  21. private long cancelDuration = 3000;
  22. /** 支付宝gatewayUrl */
  23. abstract public String getGatewayUrl();
  24. /** 商户应用id */
  25. abstract public String getAppid();
  26. /** RSA私钥,用于对商户请求报文加签 */
  27. abstract public String getAppPrivateKey();
  28. /** 支付宝RSA公钥,用于验签支付宝应答 */
  29. abstract public String getAlipayPublicKey();
  30. /** 同步地址 */
  31. abstract public String getReturnUrl();
  32. /** 异步地址 */
  33. abstract public String getNotifyUrl();
  34. public String getSignType(){
  35. return signType;
  36. }
  37. public String getFormate(){
  38. return formate;
  39. }
  40. public String getCharset(){
  41. return charset;
  42. }
  43. public int getMaxQueryRetry() {
  44. return maxQueryRetry;
  45. }
  46. public long getQueryDuration() {
  47. return queryDuration;
  48. }
  49. public int getMaxCancelRetry() {
  50. return maxCancelRetry;
  51. }
  52. public long getCancelDuration() {
  53. return cancelDuration;
  54. }
  55. @Bean
  56. public AlipayTradeService alipayTradeService() {
  57. return new AlipayTradeServiceImpl.ClientBuilder()
  58. .setGatewayUrl(getGatewayUrl())
  59. .setAppid(getAppid())
  60. .setPrivateKey(getAppPrivateKey())
  61. .setAlipayPublicKey(getAlipayPublicKey())
  62. .setSignType(getSignType())
  63. .build();
  64. }
  65. }