PaypalService.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. package com.fdkankan.pay.util.paypal.sdk;
  2. import cn.hutool.core.date.DateTime;
  3. import cn.hutool.core.date.DateUtil;
  4. import com.alibaba.fastjson.JSONArray;
  5. import com.alibaba.fastjson.JSONObject;
  6. import com.fdkankan.pay.common.ResultCode;
  7. import com.fdkankan.pay.entity.*;
  8. import com.fdkankan.pay.entity.Order;
  9. import com.fdkankan.pay.exception.BusinessException;
  10. import com.fdkankan.pay.response.OpenPayResponse;
  11. import com.fdkankan.pay.service.IAutopayOrderService;
  12. import com.fdkankan.pay.service.IAutopayPlanService;
  13. import com.fdkankan.pay.service.IOrderService;
  14. import com.fdkankan.pay.service.IPaypalConfigService;
  15. import com.fdkankan.pay.util.CacheUtil;
  16. import com.fdkankan.pay.util.DateUtils;
  17. import com.fdkankan.pay.util.UrlUtils;
  18. import com.fdkankan.pay.util.paypal.restApi.RestApiPaypalService;
  19. import com.fdkankan.pay.util.paypal.restApi.vo.Product;
  20. import com.fdkankan.pay.util.paypal.restApi.vo.plan.PlanVo;
  21. import com.fdkankan.pay.util.paypal.restApi.vo.subscription.ApplicationContext;
  22. import com.fdkankan.pay.util.paypal.restApi.vo.subscription.PaymentMethod;
  23. import com.fdkankan.pay.util.paypal.restApi.vo.subscription.SubscriptionVo;
  24. import com.paypal.api.payments.*;
  25. import com.paypal.base.codec.binary.Base64;
  26. import com.paypal.base.rest.APIContext;
  27. import com.paypal.base.rest.PayPalRESTException;
  28. import lombok.extern.log4j.Log4j2;
  29. import org.apache.commons.lang.StringUtils;
  30. import org.springframework.beans.factory.annotation.Autowired;
  31. import org.springframework.stereotype.Service;
  32. import org.springframework.transaction.annotation.Transactional;
  33. import javax.servlet.http.HttpServletRequest;
  34. import javax.servlet.http.HttpServletResponse;
  35. import java.io.*;
  36. import java.math.BigDecimal;
  37. import java.net.HttpURLConnection;
  38. import java.net.URL;
  39. import java.net.URLEncoder;
  40. import java.time.format.DateTimeFormatter;
  41. import java.util.*;
  42. @Log4j2
  43. @Service
  44. public class PaypalService {
  45. @Autowired
  46. IPaypalConfigService paypalConfigService;
  47. @Autowired
  48. IOrderService orderService;
  49. public Object openPay(Order param, String ip) throws Exception {
  50. String orderSn = param.getOrderSn();
  51. BigDecimal amount = param.getOrderMoney();
  52. String subject = param.getOrderType();
  53. PaypalConfig paypalConfig = paypalConfigService.getByServeId(param.getServeId());
  54. if(paypalConfig == null){
  55. throw new BusinessException(ResultCode.PAYPAL_CONFIG_ERROR);
  56. }
  57. paypalConfig.setSuccessUrl( CacheUtil.mainUrl + paypalConfig.getCallBackUrl() +"/"+orderSn+"/"+param.getPayType()+"/success");
  58. paypalConfig.setCancelUrl( CacheUtil.mainUrl + paypalConfig.getCallBackUrl() +"/"+orderSn+"/"+param.getPayType()+"/cancel");
  59. String body = subject;
  60. //paypal支付,未开启自动订阅
  61. if(param.getPayType() == 5 && param.getAutoPay() == 0){
  62. return this.payPalPay(orderSn, body, amount,paypalConfig);
  63. }
  64. //paypal支付,开启自动订阅
  65. if(param.getPayType() == 5 && param.getAutoPay() == 1){
  66. return this.autoPay(param,paypalConfig);
  67. }
  68. throw new BusinessException(ResultCode.WX_ORDER_PAY_TYPE_ERROR);
  69. }
  70. public OpenPayResponse payPalPay(String orderSn, String body, BigDecimal totalFee, PaypalConfig paypalConfig) throws Exception {
  71. PayPalmentEx payPalmentEx = new PayPalmentEx();
  72. payPalmentEx.setOrderSn(orderSn);
  73. payPalmentEx.setOrderTotal(totalFee);
  74. payPalmentEx.setSubTotal(totalFee);
  75. payPalmentEx.setDescription(body);
  76. Payment payment = this.createPayment(payPalmentEx,paypalConfig);
  77. for(Links links : payment.getLinks()){
  78. if(links.getRel().equals("approval_url")){
  79. // 客户付款登陆地址
  80. OpenPayResponse openPayResponse = new OpenPayResponse();
  81. openPayResponse.setH5Url(links.getHref());
  82. openPayResponse.setQrCodeUrl(links.getHref());
  83. openPayResponse.setOrderSn(orderSn);
  84. openPayResponse.setPayType(5);
  85. return openPayResponse;
  86. }
  87. }
  88. throw new BusinessException(ResultCode.PAYPAL_ERROR);
  89. }
  90. public Boolean callBack(HttpServletRequest request, HttpServletResponse response, Order order,String result) {
  91. log.info("paypal-callBack--order:{}",order);
  92. Boolean payFlag = false;
  93. String trade_no = null;
  94. String openId = null;
  95. if("cancel".equals(result)){
  96. return false;
  97. }
  98. try {
  99. Map<String, String[]> parameterMap = request.getParameterMap();
  100. for (String key : parameterMap.keySet()) {
  101. log.info("paypal-callBack--request:{},{}",key,request.getParameter(key));
  102. }
  103. String subscription_id = request.getParameter("subscription_id");
  104. if(StringUtils.isNotBlank(subscription_id)){
  105. payFlag= true;
  106. trade_no = subscription_id;
  107. openId = request.getParameter("token");
  108. return true;
  109. }
  110. String paymentId = request.getParameter("paymentId");//商品名
  111. String payerId = request.getParameter("PayerID");//购买数量
  112. PaypalConfig paypalConfig = paypalConfigService.getByServeId(order.getServeId());
  113. if(paypalConfig == null){
  114. log.error("paypal-callBack--paypalConfig-notexist");
  115. return false;
  116. }
  117. Payment payment = this.executePayment(paymentId, payerId,paypalConfig);
  118. if (payment.getState().equals("approved")) {
  119. log.info("paypal支付成功回调");
  120. String custom = payment.getTransactions().get(0).getCustom();
  121. String txnId = payment.getTransactions().get(0).getRelatedResources().get(0).getSale().getId();
  122. String payerEmail = payment.getTransactions().get(0).getPayee().getEmail();
  123. log.info("paypal-callBack:custom:{},txnid:{},payerEmail:{}",custom,txnId,payerEmail);
  124. String orderSn = custom.split("_")[0];
  125. if(custom.split("_").length > 2 && custom.split("_")[2].matches("^-?[0-9]+")){
  126. orderSn += "_" + custom.split("_")[2];
  127. }
  128. payFlag = true;
  129. trade_no = txnId;
  130. openId = payerEmail;
  131. }
  132. }catch (Exception e) {
  133. log.error("paypal支付回调异常,errorMsg:{}", e.getMessage());
  134. return false;
  135. }finally {
  136. orderService.payResult(order,payFlag,trade_no,openId);
  137. }
  138. return true;
  139. }
  140. // public Boolean callBack(HttpServletRequest request, HttpServletResponse response, Order order) {
  141. // log.info("paypal-callBack--order:{}",order);
  142. // Boolean payFlag = false;
  143. // String trade_no = null;
  144. // String openId = null;
  145. // try {
  146. // Enumeration en = request.getParameterNames();
  147. // String str = "cmd=_notify-validate";
  148. // while (en.hasMoreElements()) {
  149. // String paramName = (String) en.nextElement();
  150. // String paramValue = request.getParameter(paramName);
  151. // try {
  152. // str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue, "utf-8");
  153. // } catch (UnsupportedEncodingException e) {
  154. // StringWriter trace=new StringWriter();
  155. // e.printStackTrace(new PrintWriter(trace));
  156. // log.error(trace.toString());
  157. // }
  158. // //此处的编码一定要和自己的网站编码一致,不然会出现乱码,paypal回复的通知为‘INVALID’
  159. // }
  160. // final String itemName = request.getParameter("item_name");//商品名
  161. // final String itemNumber = request.getParameter("item_number");//购买数量
  162. // final String paymentDate = request.getParameter("payment_date");//交易时间
  163. // final String receiverEmail = request.getParameter("receiver_email");//收款人email
  164. // final String payerEmail = request.getParameter("payer_email");//付款人email
  165. // final String paymentAmount = request.getParameter("mc_gross");//交易钱数
  166. // final String paymentCurrency = request.getParameter("mc_currency");//货币种类
  167. // final String paymentStatus = request.getParameter("payment_status");//交易状态
  168. // final String txnId = request.getParameter("txn_id");//交易id
  169. // String custom = request.getParameter("custom");//发送payment请求时候自定义的业务服务器订单号
  170. // log.info("paypal回调参数:itemName:{},itemNumber:{},paymentDate:{},receiverEmail:{}," +
  171. // "payerEmail:{},paymentAmount:{},paymentCurrency:{},paymentStatus:{},txnId:{},custom:{}",
  172. // itemName,itemNumber,paymentDate,receiverEmail,payerEmail,paymentAmount,paymentCurrency,paymentStatus,txnId,custom);
  173. //
  174. // trade_no = txnId;
  175. // openId = payerEmail;
  176. // if ("Completed".equals(paymentStatus)) {
  177. // //根据自己业务进行处理(修改订单状态,支付时间等等操作)
  178. // log.info("paypal支付成功回调");
  179. // //表示续费,有消费记录id
  180. // payFlag = true;
  181. // }
  182. // }catch (Exception e) {
  183. // log.error("paypal支付回调异常,errorMsg:{}", e.getMessage());
  184. // return false;
  185. // }finally {
  186. // orderService.payResult(order,payFlag,trade_no,openId);
  187. // }
  188. // return true;
  189. // }
  190. /**
  191. * 创建支付
  192. *
  193. * @param paymentEx
  194. * @return
  195. * @throws PayPalRESTException
  196. */
  197. @Transactional(rollbackFor = Exception.class)
  198. public Payment createPayment(PayPalmentEx paymentEx, PaypalConfig paypalConfig) throws PayPalRESTException {
  199. Transaction transaction = new Transaction();
  200. transaction.setDescription(paymentEx.getDescription());
  201. // 将我们的订单ID保存到支付信息中,用于后面支付回传
  202. if (null != paymentEx.getOrderSn()) {
  203. transaction.setCustom(paymentEx.getOrderSn());
  204. }
  205. //订单价格
  206. Amount amount = new Amount();
  207. amount.setCurrency(paypalConfig.getCurrency());
  208. // 支付的总价,paypal会校验 total = subTotal + tax + ...
  209. amount.setTotal(paymentEx.getOrderTotal().toString());
  210. // 设置各种费用
  211. Details details = new Details();
  212. // 商品总价
  213. if (paymentEx.getSubTotal() != null) {
  214. details.setSubtotal(paymentEx.getSubTotal().toString());
  215. }
  216. // 税费
  217. if (paymentEx.getTax() != null) {
  218. details.setTax(paymentEx.getTax().toString());
  219. }
  220. amount.setDetails(details);
  221. transaction.setAmount(amount);
  222. ItemList itemList = new ItemList();
  223. // 收货地址
  224. PaypalOrderAddressEx orderAddress = paymentEx.getPaypayOrderAddressEx();
  225. if (orderAddress != null) {
  226. ShippingAddress shippingAddress = new ShippingAddress();
  227. if (StringUtils.isNotEmpty(orderAddress.getFirstName()) && StringUtils.isNotEmpty(orderAddress.getLastName())) {
  228. shippingAddress.setRecipientName(orderAddress.getFirstName() + "." + orderAddress.getLastName());
  229. }
  230. shippingAddress.setCountryCode(orderAddress.getCountryCode());
  231. shippingAddress.setState(orderAddress.getState());
  232. shippingAddress.setCity(orderAddress.getCity());
  233. shippingAddress.setLine1(orderAddress.getAddress());
  234. shippingAddress.setPhone(orderAddress.getPhone());
  235. shippingAddress.setPostalCode(orderAddress.getPostalCode());
  236. itemList.setShippingAddress(shippingAddress);
  237. itemList.setShippingPhoneNumber(orderAddress.getPhone());
  238. }
  239. // 商品明细
  240. List<PaypalOrderItemEx> orderItemList = paymentEx.getPaypalOrderItemExList();
  241. if (orderItemList != null && orderItemList.size() > 0) {
  242. List<Item> items = new ArrayList<>();
  243. for (PaypalOrderItemEx orderItemEx : orderItemList) {
  244. Item item = new Item();
  245. item.setSku(orderItemEx.getSku());
  246. item.setName(orderItemEx.getName());
  247. item.setPrice(orderItemEx.getPrice().toString());
  248. item.setQuantity(String.valueOf(orderItemEx.getQuantity()));
  249. item.setCurrency(paypalConfig.getCurrency());
  250. items.add(item);
  251. }
  252. itemList.setItems(items);
  253. transaction.setItemList(itemList);
  254. }
  255. List<Transaction> transactions = new ArrayList<>();
  256. transactions.add(transaction);
  257. // 支付信息
  258. Payer payer = new Payer();
  259. payer.setPaymentMethod(PaypalPaymentMethod.paypal.toString());
  260. Payment payment = new Payment();
  261. //刷新accessToken时间;
  262. APIContext apiContext = new APIContext(paypalConfig.getClientId(),paypalConfig.getSecret(),paypalConfig.getMode());
  263. Map<String, String> sdkConfig = new HashMap<>();
  264. sdkConfig.put("mode", paypalConfig.getMode());
  265. apiContext.setConfigurationMap(sdkConfig);
  266. payment.setIntent(PaypalPaymentIntent.sale.toString());
  267. payment.setPayer(payer);
  268. payment.setTransactions(transactions);
  269. //回调地址
  270. RedirectUrls redirectUrls = new RedirectUrls();
  271. redirectUrls.setReturnUrl(paypalConfig.getSuccessUrl());
  272. redirectUrls.setCancelUrl(paypalConfig.getCancelUrl());
  273. payment.setRedirectUrls(redirectUrls);
  274. return payment.create(apiContext);
  275. }
  276. /**
  277. * 执行支付
  278. *
  279. * @param paymentId
  280. * @param payerId
  281. * @return
  282. * @throws PayPalRESTException
  283. */
  284. public Payment executePayment(String paymentId, String payerId,PaypalConfig paypalConfig) throws PayPalRESTException {
  285. Payment payment = new Payment();
  286. payment.setId(paymentId);
  287. PaymentExecution paymentExecute = new PaymentExecution();
  288. paymentExecute.setPayerId(payerId);
  289. APIContext apiContext = new APIContext(paypalConfig.getClientId(),paypalConfig.getSecret(),paypalConfig.getMode());
  290. Map<String, String> sdkConfig = new HashMap<>();
  291. sdkConfig.put("mode", paypalConfig.getMode());
  292. apiContext.setConfigurationMap(sdkConfig);
  293. return payment.execute(apiContext, paymentExecute);
  294. }
  295. /**
  296.      * 获取token
  297.      * 了解更多:https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
  298.      * @return
  299.      */
  300. private String getAccessToken(PaypalConfig paypalConfig) {
  301. BufferedReader reader = null;
  302. try {
  303. URL url = new URL(UrlUtils.TOKEN_URL);
  304. String authorization = paypalConfig.getClientId() + ":" + paypalConfig.getSecret();
  305. authorization = Base64.encodeBase64String(authorization.getBytes());
  306. HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  307. conn.setRequestMethod("POST");// 提交模式
  308. //设置请求头header
  309. conn.setRequestProperty("Accept", "application/json");
  310. conn.setRequestProperty("Accept-Language", "en_US");
  311. conn.setRequestProperty("Authorization", "Basic " + authorization);
  312. // conn.setConnectTimeout(10000);//连接超时 单位毫秒
  313. // conn.setReadTimeout(2000);//读取超时 单位毫秒
  314. conn.setDoOutput(true);// 是否输入参数
  315. String params = "grant_type=client_credentials";
  316. conn.getOutputStream().write(params.getBytes());// 输入参数
  317. InputStreamReader inStream = new InputStreamReader(conn.getInputStream());
  318. reader = new BufferedReader(inStream);
  319. StringBuilder result = new StringBuilder();
  320. String lineTxt = null;
  321. while ((lineTxt = reader.readLine()) != null) {
  322. result.append(lineTxt);
  323. }
  324. reader.close();
  325. //log.info("getAccessToken:" + accessTokey);
  326. return JSONObject.parseObject(result.toString()).getString("access_token");
  327. } catch (Exception err) {
  328. err.printStackTrace();
  329. } finally {
  330. if (reader != null){
  331. try {
  332. reader.close();
  333. } catch (IOException e) {
  334. e.printStackTrace();
  335. }
  336. }
  337. }
  338. return null;
  339. }
  340. public String getPaymentDetails(String paymentId,PaypalConfig paypalConfig) {
  341. BufferedReader reader = null;
  342. try {
  343. URL url = new URL(UrlUtils.PAYMENT_DETAIL + paymentId);
  344. HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  345. conn.setRequestMethod("GET");// 提交模式
  346. //设置请求头header
  347. conn.setRequestProperty("Accept", "application/json");
  348. conn.setRequestProperty("Authorization", "Bearer " + getAccessToken(paypalConfig));
  349. // conn.setConnectTimeout(10000);//连接超时 单位毫秒
  350. // conn.setReadTimeout(2000);//读取超时 单位毫秒
  351. InputStreamReader inStream = new InputStreamReader(conn.getInputStream());
  352. reader = new BufferedReader(inStream);
  353. StringBuilder result = new StringBuilder();
  354. String lineTxt = null;
  355. while ((lineTxt = reader.readLine()) != null) {
  356. result.append(lineTxt);
  357. }
  358. reader.close();
  359. return result.toString();
  360. } catch (Exception err) {
  361. err.printStackTrace();
  362. }finally {
  363. if (reader != null){
  364. try {
  365. reader.close();
  366. } catch (IOException e) {
  367. e.printStackTrace();
  368. }
  369. }
  370. }
  371. return null;
  372. }
  373. public boolean verifyPayment(String paymentId,PaypalConfig paypalConfig){
  374. //从PayPal获取付款详情
  375. String str = getPaymentDetails(paymentId,paypalConfig);
  376. JSONObject detail = JSONObject.parseObject(str);
  377. //校验订单是否完成
  378. if("approved".equals(detail.getString("state"))){
  379. JSONObject transactions = detail.getJSONArray("transactions").getJSONObject(0);
  380. JSONObject amount = transactions.getJSONObject("amount");
  381. JSONArray relatedResources = transactions.getJSONArray("related_resources");
  382. //从数据库查询总金额与Paypal校验支付总金额
  383. double total = 0;
  384. if( total != amount.getDouble("total") ){
  385. return false;
  386. }
  387. //校验交易货币类型
  388. String currency = "USD";
  389. if( !currency.equals(amount.getString("currency")) ){
  390. return false;
  391. }
  392. //校验每个子订单是否完成
  393. for (int i = 0,j = relatedResources.size(); i < j; i++) {
  394. JSONObject sale = relatedResources.getJSONObject(i).getJSONObject("sale");
  395. if( !"completed".equals(sale.getString("state")) ){
  396. System.out.println("子订单未完成,订单状态:"+sale.getString("state"));
  397. }
  398. }
  399. return true;
  400. }
  401. return false;
  402. }
  403. @Autowired
  404. RestApiPaypalService restApiPaypalService;
  405. @Autowired
  406. IAutopayOrderService autopayOrderService;
  407. @Autowired
  408. IAutopayPlanService autopayPlanService;
  409. public Object autoPay(Order order, PaypalConfig paypalConfig) {
  410. AutopayOrder autopayOrder = autopayOrderService.getByOrderSn(order.getOrderSn());
  411. OpenPayResponse openPayResponse = new OpenPayResponse();
  412. openPayResponse.setOrderSn(order.getOrderSn());
  413. openPayResponse.setPayType(5);
  414. openPayResponse.setAutoPay(1);
  415. if(autopayOrder !=null){
  416. openPayResponse.setH5Url(autopayOrder.getSubscriptionHref());
  417. openPayResponse.setQrCodeUrl(autopayOrder.getSubscriptionHref());
  418. return openPayResponse;
  419. }
  420. autopayOrder = new AutopayOrder();
  421. AutopayPlan autopayPlan = autopayPlanService.getByOrder(order);
  422. if(autopayPlan == null){
  423. Product product = new Product();
  424. product.setName(order.getOrderType());
  425. product.setDescription(order.getGoodsInfo().toJSONString());
  426. product.setType("SERVICE");
  427. String productId = restApiPaypalService.createProduct(paypalConfig, product);
  428. log.info("创建商品:"+productId);
  429. PlanVo plan = new PlanVo();
  430. plan.setProductId(productId);
  431. plan.setPlanName(order.getOrderType());
  432. plan.setTimeUnit(order.getAutoPayTime());
  433. plan.setCurrencyCode("USD");
  434. plan.setPrice(order.getOrderMoney().toString());
  435. String planId = restApiPaypalService.createPlan(paypalConfig, plan);
  436. log.info("创建订阅计划:"+planId);
  437. autopayPlan = new AutopayPlan();
  438. autopayPlan.setServeId(order.getServeId());
  439. autopayPlan.setAutoPayTime(order.getAutoPayTime());
  440. autopayPlan.setOrderType(order.getOrderType());
  441. autopayPlan.setPayType(order.getPayType());
  442. autopayPlan.setOrderMoney(order.getOrderMoney());
  443. autopayPlan.setProductId(productId);
  444. autopayPlan.setPlanId(planId);
  445. autopayPlanService.save(autopayPlan);
  446. }
  447. autopayOrder.setProductId(autopayPlan.getProductId());
  448. autopayOrder.setPlanId(autopayPlan.getPlanId());
  449. autopayOrder.setOrderSn(order.getOrderSn());
  450. DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss+08:00"); //ISO8601
  451. String time = null;
  452. Date parse = DateUtil.parse(order.getAutoStartTime(), "yyyy-MM-dd HH:mm:ss");
  453. if("DAY".equals(order.getAutoPayTime())){
  454. time = dateTimeFormatter2.format(new DateTime(DateUtils.nextDay(parse)).toLocalDateTime());
  455. }
  456. if("MONTH".equals(order.getAutoPayTime())){
  457. time = dateTimeFormatter2.format(new DateTime(DateUtils.nextMouth(parse)).toLocalDateTime());
  458. }
  459. if("YEAR".equals(order.getAutoPayTime())){
  460. time = dateTimeFormatter2.format(new DateTime(DateUtils.nextYear(parse)).toLocalDateTime());
  461. }
  462. order.setPlanId(autopayPlan.getPlanId());
  463. order.setStartTime(time);
  464. SubscriptionVo subscription = restApiPaypalService.createSubscription(paypalConfig, order);
  465. log.info("创建订阅支付链接:"+subscription);
  466. autopayOrder.setSubscriptionId(subscription.getSubscriptionId());
  467. autopayOrder.setSubscriptionHref(subscription.getSubscriptionHref());
  468. autopayOrderService.saveOrUpdate(autopayOrder);
  469. openPayResponse.setH5Url(subscription.getSubscriptionHref());
  470. openPayResponse.setQrCodeUrl(subscription.getSubscriptionHref());
  471. return openPayResponse;
  472. }
  473. }