4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.github.thierrysquirrel.alipay.container; 18 | 19 | /** 20 | * ClassName: PayCheckFactoryContainer 21 | * Description: 22 | * Date:2024/8/6 23 | * 24 | * @author ThierrySquirrel 25 | * @since JDK21 26 | */ 27 | public final class PayCheckFactoryContainer { 28 | /** 29 | * MAP_DEFAULT_SIZE 30 | *
31 | * 默认Map大小 32 | */ 33 | public static final int MAP_DEFAULT_SIZE = 16; 34 | /** 35 | * Reload Join 36 | *
37 | * 重置拼接符 38 | */ 39 | public static final String RELOAD_JOIN = ","; 40 | 41 | private PayCheckFactoryContainer() { 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/github/thierrysquirrel/alipay/container/PayClientConstant.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024/8/6 ThierrySquirrel 3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.github.thierrysquirrel.alipay.container; 18 | 19 | import lombok.Getter; 20 | 21 | /** 22 | * ClassName: PayClientConstant 23 | * Description: 24 | * Date:2024/8/6 25 | * 26 | * @author ThierrySquirrel 27 | * @since JDK21 28 | */ 29 | @Getter 30 | public enum PayClientConstant { 31 | /** 32 | * AliPay Online Environment Gateway 33 | *
34 | * AliPay线上环境网关 35 | */ 36 | PAY_GATEWAY("https://openapi.alipay.com/gateway.do"), 37 | /** 38 | * AliPay Sandbox Environment Gateway 39 | *
40 | * AliPay沙箱环境网关 41 | */ 42 | DEV_PAY_GATEWAY("https://openapi-sandbox.dl.alipaydev.com/gateway.do"), 43 | /** 44 | * Support ONLY JSON 45 | *
46 | * 仅支持JSON 47 | */ 48 | PAY_FORMAT("JSON"), 49 | /** 50 | * Encoding Format Requested, Default UTF-8 51 | *
52 | * 请求使用的编码格式,默认UTF-8 53 | */ 54 | PAY_CHARSET("UTF-8"), 55 | /** 56 | * Signature Algorithm, Default RSA2 57 | *
58 | * 签名算法,默认RSA2 59 | */ 60 | PAY_SIGN_TYPE("RSA2"); 61 | private final String value; 62 | 63 | PayClientConstant(String value) { 64 | this.value = value; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/github/thierrysquirrel/alipay/container/PayParamConstant.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024/8/6 ThierrySquirrel 3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.github.thierrysquirrel.alipay.container; 18 | 19 | import lombok.Getter; 20 | 21 | /** 22 | * ClassName: PayParamConstant 23 | * Description: 24 | * Date:2024/8/6 25 | * 26 | * @author ThierrySquirrel 27 | * @since JDK21 28 | */ 29 | @Getter 30 | public enum PayParamConstant { 31 | /** 32 | * Product Code, Product Code Signed By AliPay And Merchants, 33 | * Fixed Value QUICK_MSECURITY_PAY 34 | *
35 | * 销售产品码,商家和支付宝签约的产品码, 36 | * 为固定值 QUICK_MSECURITY_PAY 37 | */ 38 | APP_PAY_PARAM_PRODUCT_CODE("QUICK_MSECURITY_PAY"), 39 | /** 40 | * Product Code, The Product Code Signed By AliPay And Merchants. 41 | * Please Fill In The Fixed Value Of The Product: QUICK_WAP_WAY 42 | *
43 | * 销售产品码,商家和支付宝签约的产品码. 44 | * 该产品请填写固定值:QUICK_WAP_WAY 45 | */ 46 | WAP_PAY_PARAM_PRODUCT_CODE("QUICK_WAP_WAY"), 47 | /** 48 | * Sell Product Code, Name Of Product Code Signed With AliPay. 49 | * Note: Currently Only Supported:FAST_INSTANT_TRADE_PAY 50 | *
51 | * 销售产品码,与支付宝签约的产品码名称. 52 | * 注:目前仅支持FAST_INSTANT_TRADE_PAY 53 | */ 54 | PAGE_PAT_PARAM_PRODUCT_CODE("FAST_INSTANT_TRADE_PAY"); 55 | private final String value; 56 | 57 | PayParamConstant(String value) { 58 | this.value = value; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/github/thierrysquirrel/alipay/factory/PayCheckFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024/8/6 ThierrySquirrel 3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.github.thierrysquirrel.alipay.factory; 18 | 19 | import com.alipay.api.AlipayApiException; 20 | import com.alipay.api.internal.util.AlipaySignature; 21 | import com.github.thierrysquirrel.alipay.container.PayCheckFactoryContainer; 22 | import com.github.thierrysquirrel.alipay.container.PayClientConstant; 23 | 24 | import java.util.Map; 25 | import java.util.concurrent.ConcurrentHashMap; 26 | 27 | /** 28 | * ClassName: PayCheckFactory 29 | * Description: Document Address Document Address 30 | * 文档地址: 文档地址 31 | *
32 | * Date:2024/8/6 33 | * 34 | * @author ThierrySquirrel 35 | * @since JDK21 36 | */ 37 | public class PayCheckFactory { 38 | private PayCheckFactory() { 39 | } 40 | 41 | /** 42 | * Call This Method Before Using {@linkplain #check(Map, String)} 43 | * Response Parameter Document Address https://opendocs.alipay.com/open/270/105902?pathHash=d5cd617e 44 | *
45 | * 使用 {@linkplain #check(Map, String)} 之前,请先调用此方法
46 | * 响应参数,文档地址 https://opendocs.alipay.com/open/270/105902?pathHash=d5cd617e
47 | *
48 | * @param parameterMap Feedback From AliPay: For Example HttpServletRequest request.getParameterMap()
49 | * 支付宝的反馈信息:例如 HttpServletRequest request.getParameterMap()
50 | * @return Map
51 | */
52 | public static Map
73 | * 验签为一次验签,请结合业务二次验签
74 | * 1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号,
75 | * 2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
76 | * 3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方
77 | * (有的时候,一个商户可能有多个seller_id/seller_email),
78 | * 4、验证app_id是否为该商户本身.
79 | * 上述1、2、3、4有任何一个验证不通过,则表明本次通知是异常通知,务必忽略.
80 | * 在上述验证通过后商户必须根据支付宝不同类型的业务通知,
81 | * 正确的进行不同的业务处理,并且过滤重复的通知结果数据.
82 | * 在支付宝的业务通知中,
83 | * 只有交易通知状态为TRADE_SUCCESS或TRADE_FINISHED时,支付宝才会认定为买家付款成功.
84 | *
85 | * @param reloadMap Come From {@linkplain #reload(Map)}
86 | * 来自 {@linkplain #reload(Map)}
87 | * @param publicKey publicKey
88 | * 支付宝公钥
89 | * @return boolean
90 | * @throws AlipayApiException AlipayApiException
91 | */
92 | public static boolean check(Map
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.factory;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.DefaultAlipayClient;
21 | import com.github.thierrysquirrel.alipay.container.PayClientConstant;
22 | import com.github.thierrysquirrel.alipay.pay.DefaultPayChain;
23 |
24 | /**
25 | * ClassName: PayRootChainFactory
26 | * Description:
27 | * Date:2024/8/6
28 | *
29 | * @author ThierrySquirrel
30 | * @since JDK21
31 | */
32 | public class PayRootChainFactory {
33 |
34 | private PayRootChainFactory() {
35 | }
36 |
37 | /**
38 | * Create Online Environment Pay Chain For, Default Parameters, See
39 | * {@linkplain com.github.thierrysquirrel.alipay.container.PayClientConstant PayClientConstant}
40 | *
41 | * 创建线上环境支付链,默认参数请参见
42 | * {@linkplain com.github.thierrysquirrel.alipay.container.PayClientConstant PayClientConstant}
43 | *
44 | * @param appId Application ID allocated to developers by AliPay
45 | * 支付宝分配给开发者的应用ID
46 | * @param privateKey privateKey
47 | * 应用私钥
48 | * @param publicKey publicKey
49 | * 支付宝公钥
50 | * @return DefaultPayChain
51 | */
52 | public static DefaultPayChain createdPayChain(String appId, String privateKey, String publicKey) {
53 | return new DefaultPayChain(new DefaultAlipayClient(PayClientConstant.PAY_GATEWAY.getValue(), appId, privateKey, PayClientConstant.PAY_FORMAT.getValue(), PayClientConstant.PAY_CHARSET.getValue(), publicKey, PayClientConstant.PAY_SIGN_TYPE.getValue()));
54 | }
55 |
56 | /**
57 | * Create Sandbox Environment Pay Chain For, Default Parameters, See
58 | * {@linkplain com.github.thierrysquirrel.alipay.container.PayClientConstant PayClientConstant}
59 | *
60 | * 创建沙箱环境支付链,默认参数请参见
61 | * {@linkplain com.github.thierrysquirrel.alipay.container.PayClientConstant PayClientConstant}
62 | *
63 | * @param appId Application ID allocated to developers by AliPay
64 | * 支付宝分配给开发者的应用ID
65 | * @param privateKey privateKey
66 | * 应用私钥
67 | * @param publicKey publicKey
68 | * 支付宝公钥
69 | * @return DefaultPayChain
70 | */
71 | public static DefaultPayChain createdDevPayChain(String appId, String privateKey, String publicKey) {
72 | return new DefaultPayChain(new DefaultAlipayClient(PayClientConstant.DEV_PAY_GATEWAY.getValue(), appId, privateKey, PayClientConstant.PAY_FORMAT.getValue(), PayClientConstant.PAY_CHARSET.getValue(), publicKey, PayClientConstant.PAY_SIGN_TYPE.getValue()));
73 | }
74 |
75 | /**
76 | * Create A Custom Payment Chain Suggested Use
77 | * {@linkplain com.alipay.api.DefaultAlipayClient DefaultAlipayClient}
78 | *
79 | * 创建自定义支付链,建议使用
80 | * {@linkplain com.alipay.api.DefaultAlipayClient DefaultAlipayClient}
81 | *
82 | * @param payClient payClient
83 | * @return DefaultPayChain
84 | */
85 | public static DefaultPayChain createdPayChain(AlipayClient payClient) {
86 | return new DefaultPayChain(payClient);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/AppPayChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay;
18 |
19 | import com.alipay.api.AlipayApiException;
20 | import com.alipay.api.AlipayClient;
21 | import com.alipay.api.domain.AlipayTradeAppPayModel;
22 | import com.alipay.api.request.AlipayTradeAppPayRequest;
23 | import lombok.Data;
24 |
25 | /**
26 | * ClassName: AppPayChain
27 | * Description:
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class AppPayChain {
35 | private AlipayClient alipayClient;
36 | private AlipayTradeAppPayModel alipayTradeAppPayModel;
37 |
38 | public AppPayChain(AlipayClient alipayClient, AlipayTradeAppPayModel alipayTradeAppPayModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayTradeAppPayModel = alipayTradeAppPayModel;
41 | }
42 |
43 | /**
44 | * AliPay Server Initiatively Tells The Http/Https Path Specified In The Merchant Server.
45 | *
46 | * 支付宝服务器主动通知商户服务器里指定的页面http/https路径
47 | *
48 | * @param notifyUrl notifyUrl
49 | * @return String
50 | * @throws AlipayApiException AlipayApiException
51 | */
52 | public String pay(String notifyUrl) throws AlipayApiException {
53 | AlipayTradeAppPayRequest payRequest = new AlipayTradeAppPayRequest();
54 | payRequest.setNotifyUrl(notifyUrl);
55 | payRequest.setBizModel(alipayTradeAppPayModel);
56 | return alipayClient.sdkExecute(payRequest).getBody();
57 | }
58 |
59 | /**
60 | * Custom Build PayRequest
61 | *
62 | * 自定义构建PayRequest
63 | *
64 | * @param payRequest payRequest
65 | * @return String
66 | * @throws AlipayApiException AlipayApiException
67 | */
68 | public String pay(AlipayTradeAppPayRequest payRequest) throws AlipayApiException {
69 | payRequest.setBizModel(alipayTradeAppPayModel);
70 | return alipayClient.sdkExecute(payRequest).getBody();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/DefaultPayChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.*;
21 | import com.github.thierrysquirrel.alipay.container.PayParamConstant;
22 | import com.github.thierrysquirrel.alipay.pay.close.param.PayCloseParamChain;
23 | import com.github.thierrysquirrel.alipay.pay.download.param.PayDownloadQueryParamChain;
24 | import com.github.thierrysquirrel.alipay.pay.param.AppPayParamChain;
25 | import com.github.thierrysquirrel.alipay.pay.param.PagePayParamChain;
26 | import com.github.thierrysquirrel.alipay.pay.param.WapPayParamChain;
27 | import com.github.thierrysquirrel.alipay.pay.query.param.PayQueryParamChain;
28 | import com.github.thierrysquirrel.alipay.pay.refund.param.PayRefundParamChain;
29 | import com.github.thierrysquirrel.alipay.pay.refund.query.param.PayRefundQueryParamChain;
30 | import lombok.Data;
31 |
32 | /**
33 | * ClassName: DefaultPayChain
34 | * Description:
35 | * Date:2024/8/6
36 | *
37 | * @author ThierrySquirrel
38 | * @since JDK21
39 | */
40 | @Data
41 | public class DefaultPayChain {
42 | private AlipayClient alipayClient;
43 |
44 | public DefaultPayChain(AlipayClient alipayClient) {
45 | this.alipayClient = alipayClient;
46 | }
47 |
48 | /**
49 | * Pay With App , Document Address https://docs.open.alipay.com/204
50 | *
51 | * 使用app支付,文档地址 https://docs.open.alipay.com/204
52 | *
53 | * @param outTradeNo Unique Order Number Of Merchant Website
54 | * 商户网站唯一订单号
55 | * @param totalAmount Total Order Amount, Unit: Yuan, Accurate To Two Decimal Places, Value Range [0.01100000000]
56 | * 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
57 | * @param subject Product Title / Transaction Title / Order Title / Order Keyword, Etc
58 | * 商品的标题/交易标题/订单标题/订单关键字等
59 | * @return AppPayParamChain
60 | */
61 | public AppPayParamChain appPay(String outTradeNo, String totalAmount, String subject) {
62 | AlipayTradeAppPayModel appPayModel = new AlipayTradeAppPayModel();
63 | appPayModel.setOutTradeNo(outTradeNo);
64 | appPayModel.setTotalAmount(totalAmount);
65 | appPayModel.setSubject(subject);
66 | appPayModel.setProductCode(PayParamConstant.APP_PAY_PARAM_PRODUCT_CODE.getValue());
67 | return new AppPayParamChain(alipayClient, appPayModel);
68 | }
69 |
70 | /**
71 | * Custom Payment Parameters, Recommended
72 | * {@linkplain com.alipay.api.domain.AlipayTradeAppPayModel AlipayTradeAppPayModel}
73 | *
74 | * 自定义支付参数,建议使用
75 | * {@linkplain com.alipay.api.domain.AlipayTradeAppPayModel AlipayTradeAppPayModel}
76 | *
77 | * @param appPayModel appPayModel
78 | * @return AppPayParamChain
79 | */
80 | public AppPayParamChain appPay(AlipayTradeAppPayModel appPayModel) {
81 | return new AppPayParamChain(alipayClient, appPayModel);
82 | }
83 |
84 | /**
85 | * Pay With Mobile Website, Document Address https://docs.open.alipay.com/203
86 | *
87 | * 使用手机网站支付,文档地址 https://docs.open.alipay.com/203
88 | *
89 | * @param outTradeNo Unique Order Number Of Merchant Website
90 | * 商户网站唯一订单号
91 | * @param totalAmount Total Order Amount, Unit: Yuan, Accurate To Two Decimal Places, Value Range [0.01100000000]
92 | * 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
93 | * @param subject Product Title / Transaction Title / Order Title / Order Keyword, Etc
94 | * 商品的标题/交易标题/订单标题/订单关键字等
95 | * @return WapPayParamChain
96 | */
97 | public WapPayParamChain wapPay(String outTradeNo, String totalAmount, String subject) {
98 | AlipayTradeWapPayModel payModel = new AlipayTradeWapPayModel();
99 | payModel.setOutTradeNo(outTradeNo);
100 | payModel.setTotalAmount(totalAmount);
101 | payModel.setSubject(subject);
102 | payModel.setProductCode(PayParamConstant.WAP_PAY_PARAM_PRODUCT_CODE.getValue());
103 | return new WapPayParamChain(alipayClient, payModel);
104 | }
105 |
106 | /**
107 | * Custom Payment Parameters,
108 | * Recommended {@linkplain com.alipay.api.domain.AlipayTradeWapPayModel AlipayTradeWapPayModel}
109 | *
110 | * 自定义支付参数,建议使用
111 | * {@linkplain com.alipay.api.domain.AlipayTradeWapPayModel AlipayTradeWapPayModel}
112 | *
113 | * @param payModel payModel
114 | * @return WapPayParamChain
115 | */
116 | public WapPayParamChain wapPay(AlipayTradeWapPayModel payModel) {
117 | return new WapPayParamChain(alipayClient, payModel);
118 | }
119 |
120 | /**
121 | * Pay By Computer Website, Document Address https://docs.open.alipay.com/270
122 | *
123 | * 使用电脑网站支付,文档地址 https://docs.open.alipay.com/270
124 | *
125 | * @param subject Product Title / Transaction Title / Order Title / Order Keyword, Etc
126 | * 商品的标题/交易标题/订单标题/订单关键字等
127 | * @param outTradeNo Unique Order Number Of Merchant Website
128 | * 商户网站唯一订单号
129 | * @param totalAmount Total Order Amount, Unit: Yuan, Accurate To Two Decimal Places, Value Range [0.01100000000]
130 | * 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
131 | * @return PagePayParamChain
132 | */
133 | public PagePayParamChain pagePay(String outTradeNo, String totalAmount, String subject) {
134 | AlipayTradePagePayModel payModel = new AlipayTradePagePayModel();
135 | payModel.setOutTradeNo(outTradeNo);
136 | payModel.setTotalAmount(totalAmount);
137 | payModel.setSubject(subject);
138 | payModel.setProductCode(PayParamConstant.PAGE_PAT_PARAM_PRODUCT_CODE.getValue());
139 | return new PagePayParamChain(alipayClient, payModel);
140 | }
141 |
142 | /**
143 | * Custom Payment Parameters,
144 | * Recommended {@linkplain com.alipay.api.domain.AlipayTradePagePayModel AlipayTradePagePayModel}
145 | *
146 | * 自定义支付参数,建议使用
147 | * {@linkplain com.alipay.api.domain.AlipayTradePagePayModel AlipayTradePagePayModel}
148 | *
149 | * @param payModel payModel
150 | * @return PagePayParamChain
151 | */
152 | public PagePayParamChain pagePay(AlipayTradePagePayModel payModel) {
153 | return new PagePayParamChain(alipayClient, payModel);
154 | }
155 |
156 | /**
157 | * Closing Transaction, Document Address https://docs.open.alipay.com/api_1/alipay.trade.close
158 | *
159 | * 关闭交易,文档地址 https://docs.open.alipay.com/api_1/alipay.trade.close
160 | *
161 | * @param tradeNo The Transaction In AliPay System Transaction Code.
162 | * The Shortest 16 Bits, The Longest 64 Bits.
163 | * And OutTradeNo Cannot Be Empty At The Same Time.
164 | * If OutTradeNo And TradeNo Are Passed At The Same Time,
165 | * TradeNo Shall Prevail.
166 | * 该交易在支付宝系统中的交易流水号.最短 16 位,最长 64 位.
167 | * 和OutTradeNo不能同时为空,
168 | * 如果同时传了 OutTradeNo和 TradeNo,
169 | * 则以 TradeNo为准.
170 | * @param outTradeNo When The Order Is Paid, The Incoming Merchant Order Number And The AliPay Transaction Number Can Not Be Empty At The Same Time.
171 | * TradeNo, OutTradeNo If Both Exist, Take TradeNo First
172 | * 订单支付时传入的商户订单号,和支付宝交易号不能同时为空.
173 | * TradeNo,OutTradeNo如果同时存在优先取TradeNo
174 | * @return PayCloseParamChain
175 | */
176 | public PayCloseParamChain closePay(String tradeNo, String outTradeNo) {
177 | AlipayTradeCloseModel closeModel = new AlipayTradeCloseModel();
178 | closeModel.setTradeNo(tradeNo);
179 | closeModel.setOutTradeNo(outTradeNo);
180 | return new PayCloseParamChain(alipayClient, closeModel);
181 | }
182 |
183 | /**
184 | * Custom Close Transaction,
185 | * Recommended {@linkplain com.alipay.api.domain.AlipayTradeCloseModel AlipayTradeCloseModel}
186 | *
187 | * 自定义关闭交易,建议使用
188 | * {@linkplain com.alipay.api.domain.AlipayTradeCloseModel AlipayTradeCloseModel}
189 | *
190 | * @param closeModel closeModel
191 | * @return PayCloseParamChain
192 | */
193 | public PayCloseParamChain closePay(AlipayTradeCloseModel closeModel) {
194 | return new PayCloseParamChain(alipayClient, closeModel);
195 | }
196 |
197 | /**
198 | * Query Payment,Document Address https://docs.open.alipay.com/api_1/alipay.trade.query
199 | *
200 | * 查询付款,文档地址 https://docs.open.alipay.com/api_1/alipay.trade.query
201 | *
202 | * @param outTradeNo When The Order Is Paid, The Incoming Merchant Order Number And The AliPay Transaction Number Can Not Be Empty At The Same Time.
203 | * TradeNo, OutTradeNo If There Is TradeNo Priority At The Same Time
204 | * 订单支付时传入的商户订单号,和支付宝交易号不能同时为空.
205 | * TradeNo,OutTradeNo如果同时存在优先取TradeNo
206 | * @param tradeNo AliPay Transaction Number And Merchant Order Number Can Not Be Empty At The Same Time.
207 | * 支付宝交易号,和商户订单号不能同时为空
208 | * @return PayQueryParamChain
209 | */
210 | public PayQueryParamChain queryPay(String outTradeNo, String tradeNo) {
211 | AlipayTradeQueryModel queryModel = new AlipayTradeQueryModel();
212 | queryModel.setOutTradeNo(outTradeNo);
213 | queryModel.setTradeNo(tradeNo);
214 | return new PayQueryParamChain(alipayClient, queryModel);
215 | }
216 |
217 | /**
218 | * Custom query payment,
219 | * Recommended {@linkplain com.alipay.api.domain.AlipayTradeQueryModel AlipayTradeQueryModel}
220 | *
221 | * 自定义查询付款,建议使用
222 | * {@linkplain com.alipay.api.domain.AlipayTradeQueryModel AlipayTradeQueryModel}
223 | *
224 | * @param queryModel queryModel
225 | * @return PayQueryParamChain
226 | */
227 | public PayQueryParamChain queryPay(AlipayTradeQueryModel queryModel) {
228 | return new PayQueryParamChain(alipayClient, queryModel);
229 | }
230 |
231 | /**
232 | * Transaction Refund,Document Address https://docs.open.alipay.com/api_1/alipay.trade.refund
233 | *
234 | * 交易退款,文档地址 https://docs.open.alipay.com/api_1/alipay.trade.refund
235 | *
236 | * @param refundAmount The Amount To Be Refunded Cannot Be Greater Than The Order Amount.
237 | * The Unit Is Yuan And Two Decimal Places Are Supported
238 | * 需要退款的金额,该金额不能大于订单金额,单位为元,支持两位小数
239 | * @param outTradeNo The Merchant Order Number Passed In During Order Payment Cannot Be Empty At The Same Time As TradeNo
240 | * 订单支付时传入的商户订单号,不能和 tradeNo同时为空.
241 | * @param tradeNo AliPay Transaction Number And Merchant Order Number Can Not Be Empty At The Same Time.
242 | * 支付宝交易号,和商户订单号不能同时为空
243 | * @return PayRefundParamChain
244 | */
245 | public PayRefundParamChain refundPay(String refundAmount, String outTradeNo, String tradeNo) {
246 | AlipayTradeRefundModel refundModel = new AlipayTradeRefundModel();
247 | refundModel.setRefundAmount(refundAmount);
248 | refundModel.setOutTradeNo(outTradeNo);
249 | refundModel.setTradeNo(tradeNo);
250 | return new PayRefundParamChain(alipayClient, refundModel);
251 | }
252 |
253 | /**
254 | * Custom Refund
255 | * Recommended {@linkplain com.alipay.api.domain.AlipayTradeRefundModel AlipayTradeRefundModel}
256 | *
257 | * 自定义退款,建议使用
258 | * {@linkplain com.alipay.api.domain.AlipayTradeRefundModel AlipayTradeRefundModel}
259 | *
260 | * @param refundModel refundModel
261 | * @return PayRefundParamChain
262 | */
263 | public PayRefundParamChain refundPay(AlipayTradeRefundModel refundModel) {
264 | return new PayRefundParamChain(alipayClient, refundModel);
265 | }
266 |
267 | /**
268 | * Refund Inquiry,Document Address https://docs.open.alipay.com/api_1/alipay.trade.fastpay.refund.query
269 | * 退款查询,文档地址 https://docs.open.alipay.com/api_1/alipay.trade.fastpay.refund.query
270 | *
271 | * @param outRequestNo When Requesting The Refund Interface, The Incoming Refund Request Number.
272 | * If It Is Not Passed In At The Time Of Refund Request,
273 | * The Value Is The External Transaction Number At The Time Of Transaction Creation
274 | * 请求退款接口时,传入的退款请求号,
275 | * 如果在退款请求时未传入,则该值为创建交易时的外部交易号
276 | * @param tradeNo AliPay Transaction Number And Merchant Order Number Can Not Be Empty At The Same Time.
277 | * 支付宝交易号,和商户订单号不能同时为空
278 | * @param outTradeNo When The Order Is Paid, The Incoming Merchant Order Number And The AliPay Transaction Number Can Not Be Empty At The Same Time.
279 | * OutTradeNo, OutRequestNo If There Is A Priority OutTradeNo At The Same Time
280 | * 订单支付时传入的商户订单号,和支付宝交易号不能同时为空.
281 | * OutTradeNo,OutRequestNo如果同时存在优先取OutTradeNo
282 | * @return PayRefundQueryParamChain
283 | */
284 | public PayRefundQueryParamChain refundQueryPay(String outRequestNo, String tradeNo, String outTradeNo) {
285 | AlipayTradeFastpayRefundQueryModel queryModel = new AlipayTradeFastpayRefundQueryModel();
286 | queryModel.setOutTradeNo(outTradeNo);
287 | queryModel.setTradeNo(tradeNo);
288 | queryModel.setOutRequestNo(outRequestNo);
289 | return new PayRefundQueryParamChain(alipayClient, queryModel);
290 | }
291 |
292 | /**
293 | * Custom Refund Query
294 | * Recommended {@linkplain com.alipay.api.domain.AlipayTradeFastpayRefundQueryModel AlipayTradeFastpayRefundQueryModel}
295 | *
296 | * 自定义退款查询,建议使用
297 | * {@linkplain com.alipay.api.domain.AlipayTradeFastpayRefundQueryModel AlipayTradeFastpayRefundQueryModel}
298 | *
299 | * @param queryModel queryModel
300 | * @return PayRefundQueryParamChain
301 | */
302 | public PayRefundQueryParamChain refundQueryPay(AlipayTradeFastpayRefundQueryModel queryModel) {
303 | return new PayRefundQueryParamChain(alipayClient, queryModel);
304 | }
305 |
306 | /**
307 | * Query Bill Download,Document Address https://docs.open.alipay.com/api_15/alipay.data.dataservice.bill.downloadurl.query
308 | *
309 | * 查询账单下载,文档地址 https://docs.open.alipay.com/api_15/alipay.data.dataservice.bill.downloadurl.query
310 | *
311 | * @param billType The Type Of Bill, The Merchant Through The Interface Or Merchant Authorized By The Open Platform,
312 | * Its Service Providers Through The Interface Can Get The Following Types Of Bills:
313 | * trade, signcustomer;
314 | * trade Refers To The Business Account Receipts Based On The AliPay Transaction;
315 | * signcustomer Refers To The Account Receipts Based On The Changes In The AliPay Balance Income And Expenditure.
316 | * 账单类型,
317 | * 商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:
318 | * trade、signcustomer;
319 | * trade指商户基于支付宝交易收单的业务账单;
320 | * signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单.
321 | * @param billDate Bill Time: The Format Of Daily Bill Is yyyy-MM-dd,
322 | * And The Earliest Daily Bill From January 1, 2016 Can Be Downloaded;
323 | * The Format Of Monthly Bill Is yyyy-MM, And The Earliest Monthly Bill From January 2016 Can Be Downloaded.
324 | * 账单时间:日账单格式为yyyy-MM-dd,最早可下载2016年1月1日开始的日账单;
325 | * 月账单格式为yyyy-MM,最早可下载2016年1月开始的月账单.
326 | * @return PayDownloadQueryParamChain
327 | */
328 | public PayDownloadQueryParamChain downloadQueryPay(String billType, String billDate) {
329 | AlipayDataDataserviceBillDownloadurlQueryModel queryModel = new AlipayDataDataserviceBillDownloadurlQueryModel();
330 | queryModel.setBillType(billType);
331 | queryModel.setBillDate(billDate);
332 | return new PayDownloadQueryParamChain(alipayClient, queryModel);
333 | }
334 |
335 | /**
336 | * Custom Query Bill Download
337 | * Recommended {@linkplain com.alipay.api.domain.AlipayDataDataserviceBillDownloadurlQueryModel AlipayDataDataserviceBillDownloadurlQueryModel}
338 | *
339 | * 自定义查询账单下载,建议使用
340 | * {@linkplain com.alipay.api.domain.AlipayDataDataserviceBillDownloadurlQueryModel AlipayDataDataserviceBillDownloadurlQueryModel}
341 | *
342 | * @param queryModel queryModel
343 | * @return PayDownloadQueryParamChain
344 | */
345 | public PayDownloadQueryParamChain downloadQueryPay(AlipayDataDataserviceBillDownloadurlQueryModel queryModel) {
346 | return new PayDownloadQueryParamChain(alipayClient, queryModel);
347 | }
348 |
349 | }
350 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/PagePayChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay;
18 |
19 | import com.alipay.api.AlipayApiException;
20 | import com.alipay.api.AlipayClient;
21 | import com.alipay.api.domain.AlipayTradePagePayModel;
22 | import com.alipay.api.request.AlipayTradePagePayRequest;
23 | import lombok.Data;
24 |
25 | /**
26 | * ClassName: PagePayChain
27 | * Description:
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class PagePayChain {
35 | private AlipayClient alipayClient;
36 | private AlipayTradePagePayModel alipayTradePagePayModel;
37 |
38 | public PagePayChain(AlipayClient alipayClient, AlipayTradePagePayModel alipayTradePagePayModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayTradePagePayModel = alipayTradePagePayModel;
41 | }
42 |
43 | /**
44 | * Generate Payment Page
45 | *
46 | * 生成支付页面
47 | *
48 | * @param returnUrl After the transaction is completed, the page will take the initiative to jump to the HTTP / HTTPS path specified in the merchant server
49 | * 交易完成后页面主动跳转,商户服务器里指定的页面http/https路径
50 | * @param notifyUrl AliPay Server Initiatively Tells The Http/Https Path Specified In The Merchant Server.
51 | * 支付宝服务器主动通知商户服务器里指定的页面http/https路径
52 | * @return pay
53 | * @throws AlipayApiException AlipayApiException
54 | */
55 | public String pay(String returnUrl, String notifyUrl) throws AlipayApiException {
56 | AlipayTradePagePayRequest pagePayRequest = new AlipayTradePagePayRequest();
57 | pagePayRequest.setReturnUrl(returnUrl);
58 | pagePayRequest.setNotifyUrl(notifyUrl);
59 | pagePayRequest.setBizModel(alipayTradePagePayModel);
60 | return alipayClient.pageExecute(pagePayRequest).getBody();
61 | }
62 |
63 | /**
64 | * Custom Build PayRequest
65 | *
66 | * 自定义构建PayRequest
67 | *
68 | * @param pagePayRequest pagePayRequest
69 | * @return String
70 | * @throws AlipayApiException AlipayApiException
71 | */
72 | public String pay(AlipayTradePagePayRequest pagePayRequest) throws AlipayApiException {
73 | pagePayRequest.setBizModel(alipayTradePagePayModel);
74 | return alipayClient.pageExecute(pagePayRequest).getBody();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/WapPayChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay;
18 |
19 | import com.alipay.api.AlipayApiException;
20 | import com.alipay.api.AlipayClient;
21 | import com.alipay.api.domain.AlipayTradeWapPayModel;
22 | import com.alipay.api.request.AlipayTradeWapPayRequest;
23 | import lombok.Data;
24 |
25 | /**
26 | * ClassName: WapPayChain
27 | * Description:
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class WapPayChain {
35 | private AlipayClient alipayClient;
36 | private AlipayTradeWapPayModel alipayTradeWapPayModel;
37 |
38 | public WapPayChain(AlipayClient alipayClient, AlipayTradeWapPayModel alipayTradeWapPayModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayTradeWapPayModel = alipayTradeWapPayModel;
41 | }
42 |
43 | /**
44 | * Generate Forms
45 | *
46 | * 生成表单
47 | *
48 | * @param returnUrl After the transaction is completed, the page will take the initiative to jump to the HTTP / HTTPS path specified in the merchant server
49 | * 交易完成后页面主动跳转,商户服务器里指定的页面http/https路径
50 | * @param notifyUrl AliPay Server Initiatively Tells The Http/Https Path Specified In The Merchant Server.
51 | * 支付宝服务器主动通知商户服务器里指定的页面http/https路径
52 | * @return String
53 | * @throws AlipayApiException AlipayApiException
54 | */
55 | public String pay(String returnUrl, String notifyUrl) throws AlipayApiException {
56 | AlipayTradeWapPayRequest payRequest = new AlipayTradeWapPayRequest();
57 | payRequest.setReturnUrl(returnUrl);
58 | payRequest.setNotifyUrl(notifyUrl);
59 | payRequest.setBizModel(alipayTradeWapPayModel);
60 | return alipayClient.pageExecute(payRequest).getBody();
61 | }
62 |
63 | /**
64 | * Custom Build PayRequest
65 | *
66 | * 自定义构建PayRequest
67 | *
68 | * @param payRequest payRequest
69 | * @return String
70 | * @throws AlipayApiException AlipayApiException
71 | */
72 | public String pay(AlipayTradeWapPayRequest payRequest) throws AlipayApiException {
73 | payRequest.setBizModel(alipayTradeWapPayModel);
74 | return alipayClient.pageExecute(payRequest).getBody();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/close/PayCloseChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.close;
18 |
19 | import com.alipay.api.AlipayApiException;
20 | import com.alipay.api.AlipayClient;
21 | import com.alipay.api.domain.AlipayTradeCloseModel;
22 | import com.alipay.api.request.AlipayTradeCloseRequest;
23 | import lombok.Data;
24 |
25 | /**
26 | * ClassName: PayCloseChain
27 | * Description:
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class PayCloseChain {
35 | private AlipayClient alipayClient;
36 | private AlipayTradeCloseModel alipayTradeCloseModel;
37 |
38 | public PayCloseChain(AlipayClient alipayClient, AlipayTradeCloseModel alipayTradeCloseModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayTradeCloseModel = alipayTradeCloseModel;
41 | }
42 |
43 | /**
44 | * Build Closing Transaction
45 | *
46 | * 构建关闭交易
47 | *
48 | * @return String
49 | * @throws AlipayApiException AlipayApiException
50 | */
51 | public String close() throws AlipayApiException {
52 | AlipayTradeCloseRequest closeRequest = new AlipayTradeCloseRequest();
53 | closeRequest.setBizModel(alipayTradeCloseModel);
54 | return alipayClient.execute(closeRequest).getBody();
55 | }
56 |
57 | /**
58 | * Custom Build CloseRequest
59 | *
60 | * 自定义构建CloseRequest
61 | *
62 | * @param closeRequest closeRequest
63 | * @return String
64 | * @throws AlipayApiException AlipayApiException
65 | */
66 | public String close(AlipayTradeCloseRequest closeRequest) throws AlipayApiException {
67 | return alipayClient.execute(closeRequest).getBody();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/close/param/PayCloseParamChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.close.param;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.AlipayTradeCloseModel;
21 | import com.github.thierrysquirrel.alipay.pay.close.PayCloseChain;
22 | import lombok.Data;
23 |
24 | /**
25 | * ClassName: PayCloseParamChain
26 | * Description: Document Address Document Address
27 | * 文档地址 文档地址
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class PayCloseParamChain {
35 | private AlipayClient alipayClient;
36 | private AlipayTradeCloseModel alipayTradeCloseModel;
37 |
38 | public PayCloseParamChain(AlipayClient alipayClient, AlipayTradeCloseModel alipayTradeCloseModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayTradeCloseModel = alipayTradeCloseModel;
41 | }
42 |
43 | /**
44 | * Builder PayCloseChain
45 | *
46 | * 构建 PayCloseChain
47 | *
48 | * @return PayCloseChain
49 | */
50 | public PayCloseChain builder() {
51 | return new PayCloseChain(alipayClient, alipayTradeCloseModel);
52 | }
53 |
54 | /**
55 | * Mandatory
56 | * Transaction serial number of the transaction in Alipay system
57 | *
58 | * 必选
59 | * 该交易在支付宝系统中的交易流水号
60 | *
61 | * @param tradeNo tradeNo
62 | * @return PayCloseParamChain
63 | */
64 | public PayCloseParamChain builderTradeNo(String tradeNo) {
65 | alipayTradeCloseModel.setTradeNo(tradeNo);
66 | return this;
67 | }
68 |
69 | /**
70 | * Mandatory
71 | * The order number of the merchant passed in during order payment and the Alipay transaction number cannot be blank at the same time
72 | *
73 | * 必选
74 | * 订单支付时传入的商户订单号,和支付宝交易号不能同时为空
75 | *
76 | * @param outTradeNo outTradeNo
77 | * @return PayCloseParamChain
78 | */
79 | public PayCloseParamChain builderOutTradeNo(String outTradeNo) {
80 | alipayTradeCloseModel.setOutTradeNo(outTradeNo);
81 | return this;
82 | }
83 |
84 | /**
85 | * Merchant operator ID, customized by the merchant
86 | *
87 | * 商家操作员编号 id,由商家自定义
88 | *
89 | * @param operatorId operatorId
90 | * @return PayCloseParamChain
91 | */
92 | public PayCloseParamChain builderOperatorId(String operatorId) {
93 | alipayTradeCloseModel.setOperatorId(operatorId);
94 | return this;
95 | }
96 |
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/download/PayDownloadQueryChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.download;
18 |
19 | import com.alipay.api.AlipayApiException;
20 | import com.alipay.api.AlipayClient;
21 | import com.alipay.api.domain.AlipayDataDataserviceBillDownloadurlQueryModel;
22 | import com.alipay.api.request.AlipayDataDataserviceBillDownloadurlQueryRequest;
23 | import lombok.Data;
24 |
25 | /**
26 | * ClassName: PayDownloadQueryChain
27 | * Description:
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class PayDownloadQueryChain {
35 | private AlipayClient alipayClient;
36 | private AlipayDataDataserviceBillDownloadurlQueryModel alipayDataDataserviceBillDownloadurlQueryModel;
37 |
38 | public PayDownloadQueryChain(AlipayClient alipayClient, AlipayDataDataserviceBillDownloadurlQueryModel alipayDataDataserviceBillDownloadurlQueryModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayDataDataserviceBillDownloadurlQueryModel = alipayDataDataserviceBillDownloadurlQueryModel;
41 | }
42 |
43 | /**
44 | * Build Query Bill Download
45 | *
46 | * 构建查询账单下载
47 | *
48 | * @return String
49 | * @throws AlipayApiException AlipayApiException
50 | */
51 | public String downloadQuery() throws AlipayApiException {
52 | AlipayDataDataserviceBillDownloadurlQueryRequest queryRequest = new AlipayDataDataserviceBillDownloadurlQueryRequest();
53 | queryRequest.setBizModel(alipayDataDataserviceBillDownloadurlQueryModel);
54 | return alipayClient.execute(queryRequest).getBillDownloadUrl();
55 | }
56 |
57 | /**
58 | * Custom Build QueryRequest
59 | *
60 | * 自定义构建 QueryRequest
61 | *
62 | * @param queryRequest queryRequest
63 | * @return String
64 | * @throws AlipayApiException AlipayApiException
65 | */
66 | public String downloadQuery(AlipayDataDataserviceBillDownloadurlQueryRequest queryRequest) throws AlipayApiException {
67 | queryRequest.setBizModel(alipayDataDataserviceBillDownloadurlQueryModel);
68 | return alipayClient.execute(queryRequest).getBillDownloadUrl();
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/download/param/PayDownloadQueryParamChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.download.param;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.AlipayDataDataserviceBillDownloadurlQueryModel;
21 | import com.github.thierrysquirrel.alipay.pay.download.PayDownloadQueryChain;
22 | import lombok.Data;
23 |
24 | /**
25 | * ClassName: PayDownloadQueryParamChain
26 | * Description: Document Address Document Address
27 | * 文档地址 文档地址
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class PayDownloadQueryParamChain {
35 | private AlipayClient alipayClient;
36 | private AlipayDataDataserviceBillDownloadurlQueryModel alipayDataDataserviceBillDownloadurlQueryModel;
37 |
38 | public PayDownloadQueryParamChain(AlipayClient alipayClient, AlipayDataDataserviceBillDownloadurlQueryModel alipayDataDataserviceBillDownloadurlQueryModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayDataDataserviceBillDownloadurlQueryModel = alipayDataDataserviceBillDownloadurlQueryModel;
41 | }
42 |
43 | /**
44 | * Builder PayDownloadQueryChain
45 | *
46 | * 构建 PayDownloadQueryChain
47 | *
48 | * @return PayDownloadQueryChain
49 | */
50 | public PayDownloadQueryChain builder() {
51 | return new PayDownloadQueryChain(alipayClient, alipayDataDataserviceBillDownloadurlQueryModel);
52 | }
53 |
54 | /**
55 | * Mandatory
56 | * Bill types, merchants can obtain the following bill types through interfaces or through interfaces authorized by the open platform for their affiliated service providers
57 | *
58 | * 必选
59 | * 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型
60 | *
61 | * @param billType billType
62 | * @return PayDownloadQueryParamChain
63 | */
64 | public PayDownloadQueryParamChain builderBillType(String billType) {
65 | alipayDataDataserviceBillDownloadurlQueryModel.setBillType(billType);
66 | return this;
67 | }
68 |
69 | /**
70 | * Mandatory
71 | * Billing time: * Daily billing format is yyyy MM dd, and the earliest daily billing format available for download is January 1, 2016
72 | *
73 | * 必选
74 | * 账单时间: * 日账单格式为yyyy-MM-dd,最早可下载2016年1月1日开始的日账单
75 | *
76 | * @param billDate billDate
77 | * @return PayDownloadQueryParamChain
78 | */
79 | public PayDownloadQueryParamChain builderBillDate(String billDate) {
80 | alipayDataDataserviceBillDownloadurlQueryModel.setBillDate(billDate);
81 | return this;
82 | }
83 |
84 | /**
85 | * Second level merchant smid, this parameter can only be used when bill-type is trade_zft_merchant
86 | *
87 | * 二级商户smid,这个参数只在bill_type是trade_zft_merchant时才能使用
88 | *
89 | * @param smId smId
90 | * @return PayDownloadQueryParamChain
91 | */
92 | public PayDownloadQueryParamChain builderSmId(String smId) {
93 | alipayDataDataserviceBillDownloadurlQueryModel.setSmid(smId);
94 | return this;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/param/AppPayParamChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.param;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.AlipayTradeAppPayModel;
21 | import com.alipay.api.domain.ExtUserInfo;
22 | import com.alipay.api.domain.ExtendParams;
23 | import com.alipay.api.domain.GoodsDetail;
24 | import com.github.thierrysquirrel.alipay.pay.AppPayChain;
25 | import lombok.Data;
26 |
27 | import java.util.List;
28 |
29 | /**
30 | * ClassName: AppPayParamChain
31 | * Description: Document Address
32 | * 文档地址:文档地址
33 | *
34 | * Date:2024/8/6
35 | *
36 | * @author ThierrySquirrel
37 | * @since JDK21
38 | */
39 | @Data
40 | public class AppPayParamChain {
41 | private AlipayClient alipayClient;
42 | private AlipayTradeAppPayModel alipayTradeAppPayModel;
43 |
44 | public AppPayParamChain(AlipayClient alipayClient, AlipayTradeAppPayModel alipayTradeAppPayModel) {
45 | this.alipayClient = alipayClient;
46 | this.alipayTradeAppPayModel = alipayTradeAppPayModel;
47 | }
48 |
49 | /**
50 | * Builder AppPayChain
51 | *
52 | * 构建 AppPayChain
53 | *
54 | * @return AppPayChain
55 | */
56 | public AppPayChain builder() {
57 | return new AppPayChain(alipayClient, alipayTradeAppPayModel);
58 | }
59 |
60 | /**
61 | * Mandatory
62 | * Unique order number on merchant website
63 | *
64 | * 必选
65 | * 商户网站唯一订单号
66 | *
67 | * @param outTradeNo outTradeNo
68 | * @return AppPayParamChain
69 | */
70 | public AppPayParamChain builderOutTradeNo(String outTradeNo) {
71 | alipayTradeAppPayModel.setOutTradeNo(outTradeNo);
72 | return this;
73 | }
74 |
75 | /**
76 | * Mandatory
77 | * The total amount of the order is in yuan, accurate to two decimal places, with a value range of [0.01100000000], and the amount cannot be 0
78 | *
79 | * 必选
80 | * 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000],金额不能为0
81 | *
82 | * @param totalAmount totalAmount
83 | * @return AppPayParamChain
84 | */
85 | public AppPayParamChain builderTotalAmount(String totalAmount) {
86 | alipayTradeAppPayModel.setTotalAmount(totalAmount);
87 | return this;
88 | }
89 |
90 | /**
91 | * Mandatory
92 | * Order Title
93 | *
94 | * 必选
95 | * 订单标题
96 | *
97 | * @param subject subject
98 | * @return AppPayParamChain
99 | */
100 | public AppPayParamChain builderSubject(String subject) {
101 | alipayTradeAppPayModel.setSubject(subject);
102 | return this;
103 | }
104 |
105 | /**
106 | * Sales product code, the product code signed by the merchant and Alipay QUICK_MSECURITY_PAY
107 | *
108 | * 销售产品码,商家和支付宝签约的产品码 QUICK_MSECURITY_PAY
109 | *
110 | * @param productCode productCode
111 | * @return AppPayParamChain
112 | */
113 | public AppPayParamChain builderProductCode(String productCode) {
114 | alipayTradeAppPayModel.setProductCode(productCode);
115 | return this;
116 | }
117 |
118 | /**
119 | * The product list information included in the order is in JSON format. For other details, please refer to the product details GoodsDetail[]
120 | *
121 | * 订单包含的商品列表信息,json格式,其它说明详见商品明细说明 GoodsDetail[]
122 | *
123 | * @param goodsDetail goodsDetail
124 | * @return AppPayParamChain
125 | */
126 | public AppPayParamChain builderGoodsDetail(List
134 | * 绝对超时时间,格式为yyyy-MM-dd HH:mm:ss
135 | *
136 | * @param timeoutExpress timeoutExpress
137 | * @return AppPayParamChain
138 | */
139 | public AppPayParamChain builderTimeoutExpress(String timeoutExpress) {
140 | alipayTradeAppPayModel.setTimeExpire(timeoutExpress);
141 | return this;
142 | }
143 |
144 | /**
145 | * Business Expansion Parameters
146 | *
147 | * 业务扩展参数
148 | *
149 | * @param extendParams extendParams
150 | * @return AppPayParamChain
151 | */
152 | public AppPayParamChain builderExtendParams(ExtendParams extendParams) {
153 | alipayTradeAppPayModel.setExtendParams(extendParams);
154 | return this;
155 | }
156 |
157 | /**
158 | * Common return parameters, if passed during the request, will be returned to the merchant. Alipay will only return this parameter as is when returning synchronously (including jumping back to the merchant website) and asynchronously notifying. This parameter can be sent to Alipay only after UrlEncoding.
159 | *
160 | * 公用回传参数,如果请求时传递了该参数,则返回给商户时会回传该参数。支付宝只会在同步返回(包括跳转回商户网站)和异步通知时将该参数原样返回。本参数必须进行UrlEncode之后才可以发送给支付宝。
161 | *
162 | * @param passBackParams passBackParams
163 | * @return AppPayParamChain
164 | */
165 | public AppPayParamChain builderPassBackParams(String passBackParams) {
166 | alipayTradeAppPayModel.setPassbackParams(passBackParams);
167 | return this;
168 | }
169 |
170 | /**
171 | * Merchant's original order number, maximum length limit of 32 digits
172 | *
173 | * 商户原始订单号,最大长度限制32位
174 | *
175 | * @param merchantOrderNo merchantOrderNo
176 | * @return AppPayParamChain
177 | */
178 | public AppPayParamChain builderMerchantOrderNo(String merchantOrderNo) {
179 | alipayTradeAppPayModel.setMerchantOrderNo(merchantOrderNo);
180 | return this;
181 | }
182 |
183 | /**
184 | * External designated buyer
185 | *
186 | * 外部指定买家
187 | *
188 | * @param extUserInfo extUserInfo
189 | * @return AppPayParamChain
190 | */
191 | public AppPayParamChain builderExtUserInfo(ExtUserInfo extUserInfo) {
192 | alipayTradeAppPayModel.setExtUserInfo(extUserInfo);
193 | return this;
194 | }
195 |
196 | /**
197 | * Return parameter options. Merchants customize the information fields and array format that need to be returned for synchronization by passing this parameter.
198 | *
199 | * 返回参数选项。 商户通过传递该参数来定制同步需要额外返回的信息字段,数组格式。
200 | *
201 | * @param queryOptions queryOptions
202 | * @return AppPayParamChain
203 | */
204 | public AppPayParamChain builderQueryOptions(List
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.param;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.*;
21 | import com.github.thierrysquirrel.alipay.pay.PagePayChain;
22 | import lombok.Data;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * ClassName: PagePayParamChain
28 | * Description: Document Address
29 | * 文档地址 文档地址
30 | * Date:2024/8/6
31 | *
32 | * @author ThierrySquirrel
33 | * @since JDK21
34 | */
35 | @Data
36 | public class PagePayParamChain {
37 | private AlipayClient alipayClient;
38 | private AlipayTradePagePayModel alipayTradePagePayModel;
39 |
40 | public PagePayParamChain(AlipayClient alipayClient, AlipayTradePagePayModel alipayTradePagePayModel) {
41 | this.alipayClient = alipayClient;
42 | this.alipayTradePagePayModel = alipayTradePagePayModel;
43 | }
44 |
45 | /**
46 | * Builder PagePayChain
47 | *
48 | * 构建 PagePayChain
49 | *
50 | * @return PagePayChain
51 | */
52 | public PagePayChain builder() {
53 | return new PagePayChain(alipayClient, alipayTradePagePayModel);
54 | }
55 |
56 | /**
57 | * Mandatory
58 | * Customized by merchants, within 64 characters, only supports letters, numbers, underscores, and must ensure that they are not duplicated on the merchant side
59 | *
60 | * 必选
61 | * 由商家自定义,64个字符以内,仅支持字母、数字、下划线且需保证在商户端不重复
62 | *
63 | * @param outTradeNo outTradeNo
64 | * @return PagePayParam
65 | */
66 | public PagePayParamChain builderOutTradeNo(String outTradeNo) {
67 | alipayTradePagePayModel.setOutTradeNo(outTradeNo);
68 | return this;
69 | }
70 |
71 | /**
72 | * Mandatory
73 | * The total amount of the order is in yuan, accurate to two decimal places, with a value range of [0.01100000000]. The amount cannot be 0
74 | *
75 | * 必选
76 | * 订单总金额,单位为元,精确到小数点后两位,取值范围为 [0.01,100000000]。金额不能为0
77 | *
78 | * @param totalAmount totalAmount
79 | * @return PagePayParamChain
80 | */
81 | public PagePayParamChain builderTotalAmount(String totalAmount) {
82 | alipayTradePagePayModel.setTotalAmount(totalAmount);
83 | return this;
84 | }
85 |
86 | /**
87 | * Mandatory
88 | * Order Title
89 | *
90 | * 必选
91 | * 订单标题
92 | *
93 | * @param subject subject
94 | * @return PagePayParamChain
95 | */
96 | public PagePayParamChain builderSubject(String subject) {
97 | alipayTradePagePayModel.setSubject(subject);
98 | return this;
99 | }
100 |
101 | /**
102 | * Mandatory
103 | * Sales product code, the name of the product code signed with Alipay. FAST_INSTANT_TRADE_PAY
104 | *
105 | * 必选
106 | * 销售产品码,与支付宝签约的产品码名称 FAST_INSTANT_TRADE_PAY
107 | *
108 | * @param productCode productCode
109 | * @return PagePayParamChain
110 | */
111 | public PagePayParamChain builderProductCode(String productCode) {
112 | alipayTradePagePayModel.setProductCode(productCode);
113 | return this;
114 | }
115 |
116 | /**
117 | * PC scanning payment method
118 | *
119 | * PC扫码支付的方式
120 | *
121 | * @param qrPayMode qrPayMode
122 | * @return PagePayParamChain
123 | */
124 | public PagePayParamChain builderQrPayMode(String qrPayMode) {
125 | alipayTradePagePayModel.setQrPayMode(qrPayMode);
126 | return this;
127 | }
128 |
129 | /**
130 | * Merchant customized QR code width
131 | *
132 | * 商户自定义二维码宽度
133 | *
134 | * @param qrCodeWidth qrCodeWidth
135 | * @return PagePayParamChain
136 | */
137 | public PagePayParamChain builderQrCodeWidth(Long qrCodeWidth) {
138 | alipayTradePagePayModel.setQrcodeWidth(qrCodeWidth);
139 | return this;
140 | }
141 |
142 | /**
143 | * List of products included in the order, in JSON format
144 | *
145 | * 订单包含的商品列表信息,json格式
146 | *
147 | * @param goodsDetail goodsDetail
148 | * @return PagePayParamChain
149 | */
150 | public PagePayParamChain builderGoodsDetail(List
159 | * 订单绝对超时时间。
160 | * 格式为yyyy-MM-dd HH:mm:ss
161 | *
162 | * @param timeExpire timeExpire
163 | * @return PagePayParamChain
164 | */
165 | public PagePayParamChain builderTimeExpire(String timeExpire) {
166 | alipayTradePagePayModel.setTimeExpire(timeExpire);
167 | return this;
168 | }
169 |
170 | /**
171 | * Secondary Merchant Information
172 | *
173 | * 二级商户信息
174 | *
175 | * @param subMerchant subMerchant
176 | * @return PagePayParamChain
177 | */
178 | public PagePayParamChain builderSubMerchant(SubMerchant subMerchant) {
179 | alipayTradePagePayModel.setSubMerchant(subMerchant);
180 | return this;
181 | }
182 |
183 | /**
184 | * Business Expansion Parameters
185 | *
186 | * 业务扩展参数
187 | *
188 | * @param extendParams extendParams
189 | * @return PagePayParamChain
190 | */
191 | public PagePayParamChain builderExtendParams(ExtendParams extendParams) {
192 | alipayTradePagePayModel.setExtendParams(extendParams);
193 | return this;
194 | }
195 |
196 | /**
197 | * The specific value of the business information transferred by the merchant should be agreed with Alipay. It should be used in the scenario of direct transmission of parameters such as security and marketing, and the format should be json
198 | *
199 | * 商户传入业务信息,具体值要和支付宝约定,应用于安全,营销等参数直传场景,格式为json格式
200 | *
201 | * @param businessParams businessParams
202 | * @return PagePayParamChain
203 | */
204 | public PagePayParamChain builderBusinessParams(String businessParams) {
205 | alipayTradePagePayModel.setBusinessParams(businessParams);
206 | return this;
207 | }
208 |
209 | /**
210 | * Discount parameters
211 | *
212 | * 优惠参数
213 | *
214 | * @param promoParams promoParams
215 | * @return AppPayParamChain
216 | */
217 | public PagePayParamChain builderPromoParams(String promoParams) {
218 | alipayTradePagePayModel.setPromoParams(promoParams);
219 | return this;
220 | }
221 |
222 | /**
223 | * Integration method of page after request
224 | *
225 | * 请求后页面的集成方式
226 | *
227 | * @param integrationType integrationType
228 | * @return PagePayParamChain
229 | */
230 | public PagePayParamChain builderIntegrationType(String integrationType) {
231 | alipayTradePagePayModel.setIntegrationType(integrationType);
232 | return this;
233 | }
234 |
235 | /**
236 | * Request source address. If the integration method of ALIAPP is used, if the user cancels the payment midway, the address will be returned
237 | *
238 | * 请求来源地址。如果使用ALIAPP的集成方式,用户中途取消支付会返回该地址
239 | *
240 | * @param requestFromUrl requestFromUrl
241 | * @return PagePayParamChain
242 | */
243 | public PagePayParamChain builderRequestFromUrl(String requestFromUrl) {
244 | alipayTradePagePayModel.setRequestFromUrl(requestFromUrl);
245 | return this;
246 | }
247 |
248 | /**
249 | * Merchant Store Number
250 | *
251 | * 商户门店编号
252 | *
253 | * @param storeId storeId
254 | * @return PagePayParamChain
255 | */
256 | public PagePayParamChain builderStoredId(String storeId) {
257 | alipayTradePagePayModel.setStoreId(storeId);
258 | return this;
259 | }
260 |
261 | /**
262 | * Merchant's original order number, maximum length limit of 32 digits
263 | *
264 | * 商户原始订单号,最大长度限制 32 位
265 | *
266 | * @param merchantOrderNo merchantOrderNo
267 | * @return PagePayParamChain
268 | */
269 | public PagePayParamChain builderMerchantOrderNo(String merchantOrderNo) {
270 | alipayTradePagePayModel.setMerchantOrderNo(merchantOrderNo);
271 | return this;
272 | }
273 |
274 | /**
275 | * External designated buyer
276 | *
277 | * 外部指定买家
278 | *
279 | * @param extUserInfo extUserInfo
280 | * @return PagePayParamChain
281 | */
282 | public PagePayParamChain builderExtUserInfo(ExtUserInfo extUserInfo) {
283 | alipayTradePagePayModel.setExtUserInfo(extUserInfo);
284 | return this;
285 | }
286 |
287 | /**
288 | * Invoice information
289 | *
290 | * 开票信息
291 | *
292 | * @param invoiceInfo invoiceInfo
293 | * @return PagePayParamChain
294 | */
295 | public PagePayParamChain builderInvoiceInfo(InvoiceInfo invoiceInfo) {
296 | alipayTradePagePayModel.setInvoiceInfo(invoiceInfo);
297 | return this;
298 | }
299 |
300 | }
301 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/param/WapPayParamChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.param;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.AlipayTradeWapPayModel;
21 | import com.alipay.api.domain.ExtUserInfo;
22 | import com.alipay.api.domain.ExtendParams;
23 | import com.alipay.api.domain.GoodsDetail;
24 | import com.github.thierrysquirrel.alipay.pay.WapPayChain;
25 | import lombok.Data;
26 |
27 | import java.util.List;
28 |
29 | /**
30 | * ClassName: WapPayParamChain
31 | * Description: Document Address
32 | * 文档地址: 文档地址
33 | * Date:2024/8/6
34 | *
35 | * @author ThierrySquirrel
36 | * @since JDK21
37 | */
38 | @Data
39 | public class WapPayParamChain {
40 | private AlipayClient alipayClient;
41 | private AlipayTradeWapPayModel alipayTradeWapPayModel;
42 |
43 | public WapPayParamChain(AlipayClient alipayClient, AlipayTradeWapPayModel alipayTradeWapPayModel) {
44 | this.alipayClient = alipayClient;
45 | this.alipayTradeWapPayModel = alipayTradeWapPayModel;
46 | }
47 |
48 | /**
49 | * Builder WapPayChain
50 | *
51 | * 构建 WapPayChain
52 | *
53 | * @return WapPayChain
54 | */
55 | public WapPayChain builder() {
56 | return new WapPayChain(alipayClient, alipayTradeWapPayModel);
57 | }
58 |
59 | /**
60 | * Mandatory
61 | * Unique order number on merchant website
62 | *
63 | * 必选
64 | * 商户网站唯一订单号
65 | *
66 | * @param outTradeNo outTradeNo
67 | * @return AppPayParamChain
68 | */
69 | public WapPayParamChain builderOutTradeNo(String outTradeNo) {
70 | alipayTradeWapPayModel.setOutTradeNo(outTradeNo);
71 | return this;
72 | }
73 |
74 | /**
75 | * Mandatory
76 | * The total amount of the order.
77 | * The unit is yuan, accurate to two decimal places, with a value range of [0.01100000000].
78 | *
79 | * 必选
80 | * 订单总金额。
81 | * 单位为元,精确到小数点后两位,取值范围:[0.01,100000000] 。
82 | *
83 | * @param totalAmount totalAmount
84 | * @return AppPayParamChain
85 | */
86 | public WapPayParamChain builderTotalAmount(String totalAmount) {
87 | alipayTradeWapPayModel.setTotalAmount(totalAmount);
88 | return this;
89 | }
90 |
91 | /**
92 | * Mandatory
93 | * Order Title
94 | *
95 | * 必选
96 | * 订单标题
97 | *
98 | * @param subject subject
99 | * @return AppPayParamChain
100 | */
101 | public WapPayParamChain builderSubject(String subject) {
102 | alipayTradeWapPayModel.setSubject(subject);
103 | return this;
104 | }
105 |
106 | /**
107 | * Mandatory
108 | * The sales product code of the order title, and the product code signed by the merchant and Alipay. Mobile website payment is: QUICK-WAP-WAY
109 | *
110 | * 必选
111 | * 销售产品码,商家和支付宝签约的产品码。手机网站支付为:QUICK_WAP_WAY
112 | *
113 | * @param productCode productCode
114 | * @return WapPayParamChain
115 | */
116 | public WapPayParamChain builderProductCode(String productCode) {
117 | alipayTradeWapPayModel.setProductCode(productCode);
118 | return this;
119 | }
120 |
121 | /**
122 | * For the user authorization interface, it is used to identify the user authorization relationship when obtaining user related data
123 | *
124 | * 针对用户授权接口,获取用户相关数据时,用于标识用户授权关系
125 | *
126 | * @param authToken authToken
127 | * @return WapPayParamChain
128 | */
129 | public WapPayParamChain builderAuthToken(String authToken) {
130 | alipayTradeWapPayModel.setAuthToken(authToken);
131 | return this;
132 | }
133 |
134 | /**
135 | * User exits midway through payment and returns to the merchant's website address
136 | *
137 | * 用户付款中途退出返回商户网站的地址
138 | *
139 | * @param quitUrl quitUrl
140 | * @return WapPayParamChain
141 | */
142 | public WapPayParamChain builderQuitUrl(String quitUrl) {
143 | alipayTradeWapPayModel.setQuitUrl(quitUrl);
144 | return this;
145 | }
146 |
147 | /**
148 | * The product list information included in the order is in JSON format. For other details, please refer to the product details
149 | *
150 | * 订单包含的商品列表信息,json格式,其它说明详见商品明细说明
151 | *
152 | * @param goodsDetail goodsDetail
153 | * @return AppPayParamChain
154 | */
155 | public WapPayParamChain builderGoodsType(List
163 | * 绝对超时时间,格式为yyyy-MM-dd HH:mm:ss。超时时间范围:1m~15d
164 | *
165 | * @param timeExpire timeExpire
166 | * @return WapPayParamChain
167 | */
168 | public WapPayParamChain builderTimeExpire(String timeExpire) {
169 | alipayTradeWapPayModel.setTimeExpire(timeExpire);
170 | return this;
171 | }
172 |
173 | /**
174 | * Business Expansion Parameters
175 | *
176 | * 业务扩展参数
177 | *
178 | * @param extendParams extendParams
179 | * @return AppPayParamChain
180 | */
181 | public WapPayParamChain builderExtendParams(ExtendParams extendParams) {
182 | alipayTradeWapPayModel.setExtendParams(extendParams);
183 | return this;
184 | }
185 |
186 | /**
187 | * The specific value of the business information transferred by the merchant should be agreed with Alipay. It should be used in the scenario of direct transmission of parameters such as security and marketing, and the format should be json
188 | *
189 | * 商户传入业务信息,具体值要和支付宝约定,应用于安全,营销等参数直传场景,格式为json格式
190 | *
191 | * @param businessParams businessParams
192 | * @return WapPayParamChain
193 | */
194 | public WapPayParamChain builderBusinessParams(String businessParams) {
195 | alipayTradeWapPayModel.setBusinessParams(businessParams);
196 | return this;
197 | }
198 |
199 | /**
200 | * Common return parameters, if passed during the request, will be returned to the merchant. Alipay will only return this parameter as is when returning synchronously (including jumping back to the merchant website) and asynchronously notifying. This parameter can be sent to Alipay only after UrlEncoding
201 | *
202 | * 公用回传参数,如果请求时传递了该参数,则返回给商户时会回传该参数。支付宝只会在同步返回(包括跳转回商户网站)和异步通知时将该参数原样返回。本参数必须进行UrlEncode之后才可以发送给支付宝
203 | *
204 | * @param passBackParams passBackParams
205 | * @return AppPayParamChain
206 | */
207 | public WapPayParamChain builderPassBackParams(String passBackParams) {
208 | alipayTradeWapPayModel.setPassbackParams(passBackParams);
209 | return this;
210 | }
211 |
212 | /**
213 | * Merchant's original order number, maximum length limit of 32 digits
214 | *
215 | * 商户原始订单号,最大长度限制32位
216 | *
217 | * @param merchantOrderNo merchantOrderNo
218 | * @return WapPay ParamChain
219 | */
220 | public WapPayParamChain builderMerchantOrderNo(String merchantOrderNo) {
221 | alipayTradeWapPayModel.setMerchantOrderNo(merchantOrderNo);
222 | return this;
223 | }
224 |
225 | /**
226 | * External designated buyer
227 | * 外部指定买家
228 | *
229 | * @param extUserInfo extUserInfo
230 | * @return AppPayParamChain
231 | */
232 | public WapPayParamChain builderExtUserInfo(ExtUserInfo extUserInfo) {
233 | alipayTradeWapPayModel.setExtUserInfo(extUserInfo);
234 | return this;
235 | }
236 | }
237 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/query/PayQueryChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.github.thierrysquirrel.alipay.pay.query;
18 |
19 | import com.alipay.api.AlipayApiException;
20 | import com.alipay.api.AlipayClient;
21 | import com.alipay.api.domain.AlipayTradeQueryModel;
22 | import com.alipay.api.request.AlipayTradeQueryRequest;
23 | import lombok.Data;
24 |
25 | /**
26 | * ClassName: PayQueryChain
27 | * Description:
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class PayQueryChain {
35 | private AlipayClient alipayClient;
36 | private AlipayTradeQueryModel alipayTradeQueryModel;
37 |
38 | public PayQueryChain(AlipayClient alipayClient, AlipayTradeQueryModel alipayTradeQueryModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayTradeQueryModel = alipayTradeQueryModel;
41 | }
42 |
43 | /**
44 | * Building Query
45 | *
46 | * 构建查询
47 | *
48 | * @return String
49 | * @throws AlipayApiException AlipayApiException
50 | */
51 | public String query() throws AlipayApiException {
52 | AlipayTradeQueryRequest queryRequest = new AlipayTradeQueryRequest();
53 | queryRequest.setBizModel(alipayTradeQueryModel);
54 | return alipayClient.execute(queryRequest).getBody();
55 | }
56 |
57 | /**
58 | * Custom Build QueryRequest
59 | *
60 | * 自定义构建QueryRequest
61 | *
62 | * @param queryRequest queryRequest
63 | * @return String
64 | * @throws AlipayApiException AlipayApiException
65 | */
66 | public String query(AlipayTradeQueryRequest queryRequest) throws AlipayApiException {
67 | return alipayClient.execute(queryRequest).getBody();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/query/param/PayQueryParamChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.github.thierrysquirrel.alipay.pay.query.param;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.AlipayTradeQueryModel;
21 | import com.github.thierrysquirrel.alipay.pay.query.PayQueryChain;
22 | import lombok.Data;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * ClassName: PayQueryParamChain
28 | * Description: Document Address Document Address
29 | * 文档地址 文档地址
30 | * Date:2024/8/6
31 | *
32 | * @author ThierrySquirrel
33 | * @since JDK21
34 | */
35 | @Data
36 | public class PayQueryParamChain {
37 | private AlipayClient alipayClient;
38 | private AlipayTradeQueryModel alipayTradeQueryModel;
39 |
40 | public PayQueryParamChain(AlipayClient alipayClient, AlipayTradeQueryModel alipayTradeQueryModel) {
41 | this.alipayClient = alipayClient;
42 | this.alipayTradeQueryModel = alipayTradeQueryModel;
43 | }
44 |
45 | /**
46 | * Builder PayQueryChain
47 | *
48 | * 构建 PayQueryChain
49 | *
50 | * @return PayQueryChain
51 | */
52 | public PayQueryChain builder() {
53 | return new PayQueryChain(alipayClient, alipayTradeQueryModel);
54 | }
55 |
56 | /**
57 | * Mandatory
58 | * The order number of the merchant passed in during order payment and the Alipay transaction number cannot be blank at the same time
59 | *
60 | * 必选
61 | * 订单支付时传入的商户订单号,和支付宝交易号不能同时为空
62 | * TradeNo,OutTradeNo如果同时存在优先取TradeNo
63 | *
64 | * @param outTradeNo outTradeNo
65 | * @return PayQueryParamChain
66 | */
67 | public PayQueryParamChain builderOutTradeNo(String outTradeNo) {
68 | alipayTradeQueryModel.setOutTradeNo(outTradeNo);
69 | return this;
70 | }
71 |
72 | /**
73 | * Mandatory
74 | * Alipay transaction number and merchant order number cannot be empty at the same time
75 | *
76 | * 必选
77 | * 支付宝交易号,和商户订单号不能同时为空
78 | *
79 | * @param tradeNo tradeNo
80 | * @return PayQueryParamChain
81 | */
82 | public PayQueryParamChain builderTradeNo(String tradeNo) {
83 | alipayTradeQueryModel.setTradeNo(tradeNo);
84 | return this;
85 | }
86 |
87 | /**
88 | * Useful in interbank mode, please do not use in other scenarios; Shuanglian specifies the PID of the acquiring institution of the exchange to be queried through this parameter
89 | *
90 | * 银行间联模式下有用,其它场景请不要使用; 双联通过该参数指定需要查询的交易所属收单机构的pid
91 | *
92 | * @param orgPid orgPid
93 | * @return PayQueryParamChain
94 | */
95 | public PayQueryParamChain builderOrgPid(String orgPid) {
96 | alipayTradeQueryModel.setOrgPid(orgPid);
97 | return this;
98 | }
99 |
100 | /**
101 | * Query options, merchants can customize this interface by passing in this parameter to synchronize the response with additional information fields returned in array format
102 | *
103 | * 查询选项,商户传入该参数可定制本接口同步响应额外返回的信息字段,数组格式
104 | *
105 | * @param queryOptions queryOptions
106 | * @return PayQueryParamChain
107 | */
108 | public PayQueryParamChain builderQueryOptions(List
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.refund;
18 |
19 | import com.alipay.api.AlipayApiException;
20 | import com.alipay.api.AlipayClient;
21 | import com.alipay.api.domain.AlipayTradeRefundModel;
22 | import com.alipay.api.request.AlipayTradeRefundRequest;
23 | import lombok.Data;
24 |
25 | /**
26 | * ClassName: PayRefundChain
27 | * Description:
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class PayRefundChain {
35 | private AlipayClient alipayClient;
36 | private AlipayTradeRefundModel alipayTradeRefundModel;
37 |
38 | public PayRefundChain(AlipayClient alipayClient, AlipayTradeRefundModel alipayTradeRefundModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayTradeRefundModel = alipayTradeRefundModel;
41 | }
42 |
43 | /**
44 | * Building Refund
45 | *
46 | * 构建退款
47 | *
48 | * @return String
49 | * @throws AlipayApiException AlipayApiException
50 | */
51 | public String refund() throws AlipayApiException {
52 | AlipayTradeRefundRequest refundRequest = new AlipayTradeRefundRequest();
53 | refundRequest.setBizModel(alipayTradeRefundModel);
54 | return alipayClient.execute(refundRequest).getBody();
55 | }
56 |
57 | /**
58 | * Custom Build RefundRequest
59 | *
60 | * 自定义构建 RefundRequest
61 | *
62 | * @param refundRequest refundRequest
63 | * @return String
64 | * @throws AlipayApiException AlipayApiException
65 | */
66 | public String refund(AlipayTradeRefundRequest refundRequest) throws AlipayApiException {
67 | refundRequest.setBizModel(alipayTradeRefundModel);
68 | return alipayClient.execute(refundRequest).getBody();
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/refund/param/PayRefundParamChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.refund.param;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.AlipayTradeRefundModel;
21 | import com.alipay.api.domain.OpenApiRoyaltyDetailInfoPojo;
22 | import com.alipay.api.domain.RefundGoodsDetail;
23 | import com.github.thierrysquirrel.alipay.pay.refund.PayRefundChain;
24 | import lombok.Data;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | * ClassName: PayRefundParamChain
30 | * Description: Document Address Document Address
31 | * 文档地址: 文档地址
32 | * Date:2024/8/6
33 | *
34 | * @author ThierrySquirrel
35 | * @since JDK21
36 | */
37 | @Data
38 | public class PayRefundParamChain {
39 | private AlipayClient alipayClient;
40 | private AlipayTradeRefundModel alipayTradeRefundModel;
41 |
42 | public PayRefundParamChain(AlipayClient alipayClient, AlipayTradeRefundModel alipayTradeRefundModel) {
43 | this.alipayClient = alipayClient;
44 | this.alipayTradeRefundModel = alipayTradeRefundModel;
45 | }
46 |
47 | /**
48 | * Builder PayRefundChain
49 | *
50 | * 构建 PayRefundChain
51 | *
52 | * @return PayRefundChain
53 | */
54 | public PayRefundChain builder() {
55 | return new PayRefundChain(alipayClient, alipayTradeRefundModel);
56 | }
57 |
58 | /**
59 | * Mandatory
60 | * refund amount
61 | *
62 | * 必选
63 | * 退款金额
64 | *
65 | * @param refundAmount refundAmount
66 | * @return PayRefundParamChain
67 | */
68 | public PayRefundParamChain builderRefundAmount(String refundAmount) {
69 | alipayTradeRefundModel.setRefundAmount(refundAmount);
70 | return this;
71 | }
72 |
73 | /**
74 | * Mandatory
75 | * Merchant order number
76 | *
77 | * 必选
78 | * 商户订单号
79 | *
80 | * @param outTradeNo outTradeNo
81 | * @return PayRefundParamChain
82 | */
83 | public PayRefundParamChain builderOutTradeNo(String outTradeNo) {
84 | alipayTradeRefundModel.setOutTradeNo(outTradeNo);
85 | return this;
86 | }
87 |
88 | /**
89 | * Mandatory
90 | * Alipay transaction number
91 | *
92 | * 必选
93 | * 支付宝交易号
94 | *
95 | * @param tradeNo tradeNo
96 | * @return PayRefundParamChain
97 | */
98 | public PayRefundParamChain builderTradeNo(String tradeNo) {
99 | alipayTradeRefundModel.setTradeNo(tradeNo);
100 | return this;
101 | }
102 |
103 | /**
104 | * Reason for refund explanation
105 | *
106 | * 退款原因说明
107 | *
108 | * @param refundReason refundReason
109 | * @return PayRefundParamChain
110 | */
111 | public PayRefundParamChain builderRefundReason(String refundReason) {
112 | alipayTradeRefundModel.setRefundReason(refundReason);
113 | return this;
114 | }
115 |
116 | /**
117 | * Refund Request Number
118 | *
119 | * 退款请求号
120 | *
121 | * @param outRequestNo outRequestNo
122 | * @return PayRefundParamChain
123 | */
124 | public PayRefundParamChain builderOutRequestNo(String outRequestNo) {
125 | alipayTradeRefundModel.setOutRequestNo(outRequestNo);
126 | return this;
127 | }
128 |
129 | /**
130 | * List of products included in the refund
131 | *
132 | * 退款包含的商品列表信息
133 | *
134 | * @param refundGoodsDetail refundGoodsDetail
135 | * @return PayRefundParamChain
136 | */
137 | public PayRefundParamChain builderRefundGoodsDetail(List
145 | * 退分账明细信息
146 | *
147 | * @param refundRoyaltyParameters refundRoyaltyParameters
148 | * @return PayRefundParamChain
149 | */
150 | public PayRefundParamChain builderRefundRoyaltyParameters(List
158 | * 查询选项
159 | *
160 | * @param queryOptions queryOptions
161 | * @return PayRefundParamChain
162 | */
163 | public PayRefundParamChain builderQueryOptions(List
171 | * 针对账期交易,在确认结算后退款的话,需要指定确认结算时的结算单号
172 | *
173 | * @param relatedSettleConfirmNo relatedSettleConfirmNo
174 | * @return PayRefundParamChain
175 | */
176 | public PayRefundParamChain builder(String relatedSettleConfirmNo) {
177 | alipayTradeRefundModel.setRelatedSettleConfirmNo(relatedSettleConfirmNo);
178 | return this;
179 | }
180 |
181 | }
182 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/refund/query/PayRefundQueryChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.refund.query;
18 |
19 | import com.alipay.api.AlipayApiException;
20 | import com.alipay.api.AlipayClient;
21 | import com.alipay.api.domain.AlipayTradeFastpayRefundQueryModel;
22 | import com.alipay.api.request.AlipayTradeFastpayRefundQueryRequest;
23 | import lombok.Data;
24 |
25 | /**
26 | * ClassName: PayRefundQueryChain
27 | * Description:
28 | * Date:2024/8/6
29 | *
30 | * @author ThierrySquirrel
31 | * @since JDK21
32 | */
33 | @Data
34 | public class PayRefundQueryChain {
35 | private AlipayClient alipayClient;
36 | private AlipayTradeFastpayRefundQueryModel alipayTradeFastpayRefundQueryModel;
37 |
38 | public PayRefundQueryChain(AlipayClient alipayClient, AlipayTradeFastpayRefundQueryModel alipayTradeFastpayRefundQueryModel) {
39 | this.alipayClient = alipayClient;
40 | this.alipayTradeFastpayRefundQueryModel = alipayTradeFastpayRefundQueryModel;
41 | }
42 |
43 | /**
44 | * Build Refund Query
45 | *
46 | * 构建退款查询
47 | *
48 | * @return String
49 | * @throws AlipayApiException AlipayApiException
50 | */
51 | public String refundQuery() throws AlipayApiException {
52 | AlipayTradeFastpayRefundQueryRequest queryRequest = new AlipayTradeFastpayRefundQueryRequest();
53 | queryRequest.setBizModel(alipayTradeFastpayRefundQueryModel);
54 | return alipayClient.execute(queryRequest).getBody();
55 | }
56 |
57 | /**
58 | * Custom Build QueryRequest
59 | *
60 | * 自定义构建 QueryRequest
61 | *
62 | * @param queryRequest queryRequest
63 | * @return String
64 | * @throws AlipayApiException AlipayApiException
65 | */
66 | public String refundQuery(AlipayTradeFastpayRefundQueryRequest queryRequest) throws AlipayApiException {
67 | queryRequest.setBizModel(alipayTradeFastpayRefundQueryModel);
68 | return alipayClient.execute(queryRequest).getBody();
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/github/thierrysquirrel/alipay/pay/refund/query/param/PayRefundQueryParamChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2024/8/6 ThierrySquirrel
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 |
17 | package com.github.thierrysquirrel.alipay.pay.refund.query.param;
18 |
19 | import com.alipay.api.AlipayClient;
20 | import com.alipay.api.domain.AlipayTradeFastpayRefundQueryModel;
21 | import com.github.thierrysquirrel.alipay.pay.refund.query.PayRefundQueryChain;
22 | import lombok.Data;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * ClassName: PayRefundQueryParamChain
28 | * Description: Document Address Document Address
29 | * 文档地址 文档地址
30 | * Date:2024/8/6
31 | *
32 | * @author ThierrySquirrel
33 | * @since JDK21
34 | */
35 | @Data
36 | public class PayRefundQueryParamChain {
37 | private AlipayClient alipayClient;
38 | private AlipayTradeFastpayRefundQueryModel alipayTradeFastpayRefundQueryModel;
39 |
40 | public PayRefundQueryParamChain(AlipayClient alipayClient, AlipayTradeFastpayRefundQueryModel alipayTradeFastpayRefundQueryModel) {
41 | this.alipayClient = alipayClient;
42 | this.alipayTradeFastpayRefundQueryModel = alipayTradeFastpayRefundQueryModel;
43 | }
44 |
45 | /**
46 | * Builder PayRefundChain
47 | *
48 | * 构建 PayRefundChain
49 | *
50 | * @return PayRefundQueryChain
51 | */
52 | public PayRefundQueryChain builder() {
53 | return new PayRefundQueryChain(alipayClient, alipayTradeFastpayRefundQueryModel);
54 | }
55 |
56 | /**
57 | * Mandatory
58 | * Refund Request Number
59 | *
60 | * 必选
61 | * 退款请求号
62 | *
63 | * @param outRequestNo outRequestNo
64 | * @return PayRefundQueryParamChain
65 | */
66 | public PayRefundQueryParamChain builderOutRequestNo(String outRequestNo) {
67 | alipayTradeFastpayRefundQueryModel.setOutRequestNo(outRequestNo);
68 | return this;
69 | }
70 |
71 | /**
72 | * Mandatory
73 | * Alipay transaction number
74 | *
75 | * 必选
76 | * 支付宝交易号
77 | *
78 | * @param tradeNo tradeNo
79 | * @return PayRefundQueryParamChain
80 | */
81 | public PayRefundQueryParamChain builderTradeNo(String tradeNo) {
82 | alipayTradeFastpayRefundQueryModel.setTradeNo(tradeNo);
83 | return this;
84 | }
85 |
86 | /**
87 | * Mandatory
88 | * Merchant order number
89 | *
90 | * !!这是不可缺参数
91 | * 商户订单号
92 | * OutTradeNo,OutRequestNo如果同时存在优先取OutTradeNo
93 | *
94 | * @param outTradeNo outTradeNo
95 | * @return PayRefundQueryParamChain
96 | */
97 | public PayRefundQueryParamChain builderOutTradeNo(String outTradeNo) {
98 | alipayTradeFastpayRefundQueryModel.setOutTradeNo(outTradeNo);
99 | return this;
100 | }
101 |
102 | /**
103 | * Query options, merchants can customize the additional information fields that need to be returned for synchronization by uploading this parameter, in array format
104 | *
105 | * 查询选项,商户通过上送该参数来定制同步需要额外返回的信息字段,数组格式
106 | *
107 | * @param queryOptions queryOptions
108 | * @return PayRefundQueryParamChain
109 | */
110 | public PayRefundQueryParamChain builder(List