├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── README_zh_CN.md ├── pom.xml └── src └── main └── java └── com └── github └── thierrysquirrel └── alipay ├── container ├── PayCheckFactoryContainer.java ├── PayClientConstant.java └── PayParamConstant.java ├── factory ├── PayCheckFactory.java └── PayRootChainFactory.java └── pay ├── AppPayChain.java ├── DefaultPayChain.java ├── PagePayChain.java ├── WapPayChain.java ├── close ├── PayCloseChain.java └── param │ └── PayCloseParamChain.java ├── download ├── PayDownloadQueryChain.java └── param │ └── PayDownloadQueryParamChain.java ├── param ├── AppPayParamChain.java ├── PagePayParamChain.java └── WapPayParamChain.java ├── query ├── PayQueryChain.java └── param │ └── PayQueryParamChain.java └── refund ├── PayRefundChain.java ├── param └── PayRefundParamChain.java └── query ├── PayRefundQueryChain.java └── param └── PayRefundQueryParamChain.java /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: ThierrySquirrel 2 | custom: https://www.paypal.com/paypalme/thierrysquirrel 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | /**/target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | 20 | ### NetBeans ### 21 | /nbproject/private/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | /build/ 27 | 28 | ### VS Code ### 29 | .vscode/ 30 | 31 | ### Windows ### 32 | *.bat -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Citizen Code of Conduct 2 | 3 | ## 1. Purpose 4 | 5 | A primary goal of Alipay is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof). 6 | 7 | This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior. 8 | 9 | We invite all those who participate in Alipay to help us create safe and positive experiences for everyone. 10 | 11 | ## 2. Open [Source/Culture/Tech] Citizenship 12 | 13 | A supplemental goal of this Code of Conduct is to increase open [source/culture/tech] citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community. 14 | 15 | Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society. 16 | 17 | If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know. 18 | 19 | ## 3. Expected Behavior 20 | 21 | The following behaviors are expected and requested of all community members: 22 | 23 | * Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community. 24 | * Exercise consideration and respect in your speech and actions. 25 | * Attempt collaboration before conflict. 26 | * Refrain from demeaning, discriminatory, or harassing behavior and speech. 27 | * Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential. 28 | * Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations. 29 | 30 | ## 4. Unacceptable Behavior 31 | 32 | The following behaviors are considered harassment and are unacceptable within our community: 33 | 34 | * Violence, threats of violence or violent language directed against another person. 35 | * Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. 36 | * Posting or displaying sexually explicit or violent material. 37 | * Posting or threatening to post other people's personally identifying information ("doxing"). 38 | * Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. 39 | * Inappropriate photography or recording. 40 | * Inappropriate physical contact. You should have someone's consent before touching them. 41 | * Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances. 42 | * Deliberate intimidation, stalking or following (online or in person). 43 | * Advocating for, or encouraging, any of the above behavior. 44 | * Sustained disruption of community events, including talks and presentations. 45 | 46 | ## 5. Weapons Policy 47 | 48 | No weapons will be allowed at Alipay events, community spaces, or in other spaces covered by the scope of this Code of Conduct. Weapons include but are not limited to guns, explosives (including fireworks), and large knives such as those used for hunting or display, as well as any other item used for the purpose of causing injury or harm to others. Anyone seen in possession of one of these items will be asked to leave immediately, and will only be allowed to return without the weapon. Community members are further expected to comply with all state and local laws on this matter. 49 | 50 | ## 6. Consequences of Unacceptable Behavior 51 | 52 | Unacceptable behavior from any community member, including sponsors and those with decision-making authority, will not be tolerated. 53 | 54 | Anyone asked to stop unacceptable behavior is expected to comply immediately. 55 | 56 | If a community member engages in unacceptable behavior, the community organizers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event). 57 | 58 | ## 7. Reporting Guidelines 59 | 60 | If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. . 61 | 62 | 63 | 64 | Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress. 65 | 66 | ## 8. Addressing Grievances 67 | 68 | If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. 69 | 70 | 71 | 72 | ## 9. Scope 73 | 74 | We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues--online and in-person--as well as in all one-on-one communications pertaining to community business. 75 | 76 | This code of conduct and its related procedures also applies to unacceptable behavior occurring outside the scope of community activities when such behavior has the potential to adversely affect the safety and well-being of community members. 77 | 78 | ## 10. Contact info 79 | 80 | 81 | 82 | ## 11. License and attribution 83 | 84 | The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). 85 | 86 | Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). 87 | 88 | _Revision 2.3. Posted 6 March 2017._ 89 | 90 | _Revision 2.2. Posted 4 February 2016._ 91 | 92 | _Revision 2.1. Posted 23 June 2014._ 93 | 94 | _Revision 2.0, adopted by the [Stumptown Syndicate](http://stumptownsyndicate.org) board on 10 January 2013. Posted 17 March 2013._ 95 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (properties) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # alipay 2 | 3 | [AliPay Open Platform](https://open.alipay.com/platform/home.htm) 4 | 5 | AliPay Java SDK 6 | 7 | [中文](./README_zh_CN.md) 8 | 9 | Support Function: 10 | - [x] App Payment 11 | - [x] Mobile Website Payment 12 | - [x] Payment By Computer Website 13 | - [x] Transaction Query 14 | - [x] Transaction Closed 15 | - [x] Transaction Refund 16 | - [x] Transaction Refund Query 17 | - [x] Query Bill Download Address 18 | - [x] Transaction Verification 19 | 20 | # App Payment: 21 | * [App payment product introduction](https://docs.open.alipay.com/204/105051/) 22 | APP Payment Is Suitable For Businesses To Integrate AliPay Payment Function In App Applications. 23 | Merchant APP Calls AliPay's SDK, SDK, And Then Calls The Payment Module in AliPay APP. 24 | If The User Has Installed AliPay APP, 25 | The Merchant APP Will Jump To AliPay To Complete The Payment, 26 | After Payment, Jump Back To The Merchant App, And Finally Display The Payment Result. 27 | If The User Does Not Install AliPay APP, 28 | The Merchant APP Will Adjust The AliPay Web Payment Cashier, 29 | Users Log On To AliPay Account And Show The Payment Results After Payment. 30 | Currently supported mobile systems are IOS (Apple) and Android (Android). 31 | 32 | # Mobile Website Payment: 33 | * [Mobile Website Payment Product Introduction](https://docs.open.alipay.com/203) 34 | It Is Suitable For Businesses To Integrate AliPay Payment Function In Mobile Web Page Application. 35 | In The Web Application, 36 | Merchants Call The Web Page Payment Interface Provided By AliPay, And The Interface Will Adjust The Payment Module In AliPay Client, 37 | At This Point, It Will Jump From The Merchant Web Application To The AliPay Client And Start Payment: After Payment Is Completed, 38 | It Will Jump Back To The Application Of The Merchant Web Page, 39 | Finally, The Merchant Shows The Payment Result. 40 | 41 | # Payment By Computer Website: 42 | * [Introduction To Payment Products Of Computer Website](https://docs.open.alipay.com/270) 43 | Through The Payment Function Of The Computer Website, 44 | Users Will Automatically Jump To The AliPay PC Website Cashier To Complete Payment After Consuming The PC Website. 45 | Trading Funds Directly Into The Merchant AliPay Account, Real-Time Arrival. 46 | The User's Transaction Payment Is Received Immediately, 47 | And The Transaction Order Can Be Refunded Within Three Months, 48 | Provide Refund, Settlement, Reconciliation And Other Supporting Services. 49 | 50 | # Transaction Query: 51 | * [Unified Single Line Transaction Inquiry](https://opendocs.alipay.com/open/82ea786a_alipay.trade.query?scene=23&pathHash=0745ecea) 52 | The Interface Provides All AliPay Payment Orders Inquiries, Merchants Can Actively Query The Order Status Through This Interface, 53 | And Complete The Next Business Logic. 54 | Need To Call Query Interface: When The Merchant Background, Network, 55 | Server And So On Are Abnormal, 56 | The Merchant System Does Not Receive The Payment Notice Finally: 57 | System Error Or Unknown Transaction Status Returned After Calling The Payment Interface: 58 | Call alipay.trade.pay To Return The Status Of INPROCESS: 59 | Before Calling alipay.trade.cancel, You Need To Confirm The Payment Status: 60 | 61 | # Transaction Closed: 62 | * [Unified Receipt Transaction Closing Interface](https://opendocs.alipay.com/open/ce0b4954_alipay.trade.close?scene=common&pathHash=7b0fdae1) 63 | After The Transaction Is Created, 64 | The User Fails To Pay Within A Certain Period Of Time, 65 | This Interface Can Be Called To Close The Unpaid Transactions Directly. 66 | 67 | # Transaction Refund: 68 | * [Unified Receipt Transaction Refund Interface](https://opendocs.alipay.com/open/4b7cc5db_alipay.trade.refund?scene=common&pathHash=d98b006d) 69 | When A Refund Is Required Due To The Buyer Or The Seller For A Period Of Time After The Transaction, 70 | The Seller Can Return The Payment To The Buyer Through The Refund Interface, 71 | AliPay Will Receive A Refund Request And Verify The Success, 72 | Refund The Payment To The Buyer's Account According To The Refund Rules. 73 | No Refund Can Be Made For The Order Whose Transaction Exceeds The Agreed Time (The Refundable Time Set At The Time Of Signing) 74 | AliPay Refund Support For Single Transaction With Multiple Refunds, 75 | For Multiple Refunds, You Need To Submit The Merchant Order Number Of The Original Payment Order And Set A Different Refund Number. 76 | If A Refund Fails To Be Submitted Again, 77 | The original Refund Number Shall Be Used. 78 | The Total Refund Amount Cannot Exceed The User's Actual Payment Amount 79 | 80 | # Transaction Refund Query: 81 | * [Unified Receipt Transaction Refund Query](https://opendocs.alipay.com/open/7be83133_alipay.trade.fastpay.refund.query?scene=common&pathHash=7cf4fed5) 82 | The Merchant Can Use This Interface To Query Whether The Refund Request Submitted By Itself Through alipay.trade.refund 83 | or alipay.trade.refund.apply Is Executed Successfully. 84 | The Return Code 10000 Of This Interface Only Represents The Success Of This Query Operation, Not The Success Of Refund. 85 | If The Interface Returns Query Data, 86 | If The refund_status Is Empty Or REFUND_SUCCESS, The Refund Is successful, 87 | If It Is Not Found, It Means That The Refund Is Successful. 88 | You Can Call The Refund Interface To Try Again. 89 | Please Make Sure That The Refund Request Number Is The Same When You Try Again. 90 | 91 | # Query Bill Download Address: 92 | * [Query The Download Address Of Statement](https://opendocs.alipay.com/open/3c9f1bcf_alipay.data.dataservice.bill.downloadurl.query?scene=common&pathHash=97357e8b) 93 | In Order To Facilitate The Merchant's Quick Account Checking, 94 | The Merchant Is Supported To Obtain The Offline Bill Download Address Of The Merchant Through This Interface 95 | 96 | # Transaction Verification: 97 | * [Difference Between RSA and RSA2 Signature Algorithms](https://docs.open.alipay.com/291/106115/) 98 | The New Application Only Supports The RSA2 Signature Method. Currently, 99 | The Application That Has Used The RSA Signature Method Can Still Call The Interface Normally, 100 | See For Details.[Open Platform Interface Signature Upgrade Announcement.](https://docs.open.alipay.com/10505) 101 | 102 | ## Quick Start 103 | 104 | ```xml 105 | 106 | 107 | com.github.thierrysquirrel 108 | alipay 109 | 1.4.0.0-RELEASE 110 | 111 | ``` 112 | 113 | # App Payment: 114 | 115 | ```java 116 | public class AppPay { 117 | public String appPay() throws AlipayApiException { 118 | return PayRootChainFactory 119 | .createdPayChain("appId", "privateKey", "publicKey") 120 | .appPay("outTradeNo", "totalAmount", "subject") 121 | .builder() 122 | .pay("notifyUrl"); 123 | } 124 | } 125 | ``` 126 | 127 | # Mobile Website Payment: 128 | 129 | ```java 130 | public class WapPay { 131 | public String wapPay() throws AlipayApiException { 132 | return PayRootChainFactory 133 | .createdPayChain("appId", "privateKey", "publicKey") 134 | .wapPay("outTradeNo", "totalAmount", "subject") 135 | .builder() 136 | .pay("returnUrl", "notifyUrl"); 137 | } 138 | } 139 | ``` 140 | 141 | # Payment By Computer Website: 142 | 143 | ```java 144 | public class PagePay { 145 | public String pagePay() throws AlipayApiException { 146 | return PayRootChainFactory 147 | .createdPayChain("appId","privateKey","publicKey") 148 | .pagePay("outTradeNo","totalAmount","subject") 149 | .builder() 150 | .pay("returnUrl","notifyUrl"); 151 | } 152 | } 153 | ``` 154 | 155 | # Transaction Query: 156 | 157 | ```java 158 | public class PayQuery { 159 | public String payQuery() throws AlipayApiException { 160 | return PayRootChainFactory 161 | .createdPayChain("appId", "privateKey", "publicKey") 162 | .queryPay("outTradeNo", "tradeNo") 163 | .builder() 164 | .query(); 165 | } 166 | } 167 | ``` 168 | 169 | # Transaction Closed: 170 | 171 | ```java 172 | public class PayClose { 173 | public String payClose() throws AlipayApiException { 174 | return PayRootChainFactory 175 | .createdPayChain("appId", "privateKey", "publicKey") 176 | .closePay("tradeNo", "outTradeNo") 177 | .builder() 178 | .close(); 179 | } 180 | } 181 | ``` 182 | 183 | # Transaction Refund: 184 | 185 | ```java 186 | public class PayRefund { 187 | public String payRefund() throws AlipayApiException { 188 | return PayRootChainFactory 189 | .createdPayChain("appId", "privateKey", "publicKey") 190 | .refundPay("refundAmount", "outTradeNo", "tradeNo") 191 | .builder() 192 | .refund(); 193 | } 194 | } 195 | ``` 196 | 197 | # Transaction Refund Query: 198 | 199 | ```java 200 | public class PayRefundQuery { 201 | public String payRefundQuery() throws AlipayApiException { 202 | return PayRootChainFactory 203 | .createdPayChain("appId", "privateKey", "publicKey") 204 | .refundQueryPay("outRequestNo", "tradeNo", "outTradeNo") 205 | .builder() 206 | .refundQuery(); 207 | } 208 | } 209 | ``` 210 | 211 | # Query Bill Download Address: 212 | 213 | ```java 214 | public class PayDownloadQuery { 215 | public String payDownloadQuery() throws AlipayApiException { 216 | return PayRootChainFactory 217 | .createdPayChain("appId","privateKey","publicKey") 218 | .downloadQueryPay("billType","billDate") 219 | .builder() 220 | .downloadQuery(); 221 | } 222 | } 223 | ``` 224 | 225 | # Transaction Verification: 226 | 227 | ```java 228 | public class PayCheck { 229 | public boolean payCheck(HttpServletRequest request){ 230 | Map parameterMap=request.getParameterMap(); 231 | Map reload = PayCheckFactory.reload(parameterMap); 232 | return PayCheckFactory.check(reload); 233 | } 234 | } 235 | ``` 236 | 237 | 238 | 239 | -------------------------------------------------------------------------------- /README_zh_CN.md: -------------------------------------------------------------------------------- 1 | # alipay 2 | 3 | [支付宝开放平台](https://open.alipay.com/platform/home.htm) 4 | 5 | 支付宝 Java SDK 6 | 7 | [English](./README.md) 8 | 9 | 支持功能: 10 | - [x] App支付 11 | - [x] 手机网站支付 12 | - [x] 电脑网站支付 13 | - [x] 交易查询 14 | - [x] 交易关闭 15 | - [x] 交易退款 16 | - [x] 交易退款查询 17 | - [x] 查询账单下载地址 18 | - [x] 交易验签 19 | 20 | # App支付: 21 | * [App支付产品介绍](https://docs.open.alipay.com/204/105051/) 22 | APP支付适用于商家在 App 应用中集成支付宝支付功能. 23 | 商家APP调用支付宝提供的 SDK,SDK 再调用支付宝APP内的支付模块. 24 | 如果用户已安装支付宝 APP,商家 APP 会跳转到支付宝中完成支付, 25 | 支付完后跳回到商家APP内,最后展示支付结果. 26 | 如果用户没有安装支付宝 APP,商家 APP 内会调起支付宝网页支付收银台, 27 | 用户登录支付宝账户,支付完后展示支付结果. 28 | 目前支持手机系统有:iOS(苹果)、Android(安卓). 29 | 30 | # 手机网站支付: 31 | * [手机网站支付产品介绍](https://docs.open.alipay.com/203) 32 | 适用于商家在移动端网页应用中集成支付宝支付功能. 33 | 商家在网页应用中调用支付宝提供的网页支付接口,接口会调起支付宝客户端内的支付模块, 34 | 此时会从商家网页应用跳转到支付宝客户端中并开始支付:支付完成后会跳转回商家网页应用内, 35 | 最后商家展示支付结果. 36 | 37 | # 电脑网站支付: 38 | * [电脑网站支付产品介绍](https://docs.open.alipay.com/270) 39 | 通过电脑网站支付功能,用户在商家 PC 网站消费后界面会自动跳转到支付宝 PC 网站收银台完成付款. 40 | 交易资金直接打入商家支付宝账户,实时到账. 41 | 用户交易款项即时到账,交易订单三个月内可退款, 42 | 提供退款、清结算、对账等配套服务. 43 | 44 | # 交易查询: 45 | * [统一收单线下交易查询](https://opendocs.alipay.com/open/82ea786a_alipay.trade.query?scene=23&pathHash=0745ecea) 46 | 该接口提供所有支付宝支付订单的查询,商户可以通过该接口主动查询订单状态,完成下一步的业务逻辑. 47 | 需要调用查询接口的情况: 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知: 48 | 调用支付接口后,返回系统错误或未知交易状态情况: 49 | 调用alipay.trade.pay,返回INPROCESS的状态: 50 | 调用alipay.trade.cancel之前,需确认支付状态: 51 | 52 | # 交易关闭: 53 | * [统一收单交易关闭接口](https://opendocs.alipay.com/open/ce0b4954_alipay.trade.close?scene=common&pathHash=7b0fdae1) 54 | 用于交易创建后,用户在一定时间内未进行支付, 55 | 可调用该接口直接将未付款的交易进行关闭. 56 | 57 | # 交易退款: 58 | * [统一收单交易退款接口](https://opendocs.alipay.com/open/4b7cc5db_alipay.trade.refund?scene=common&pathHash=d98b006d) 59 | 当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时, 60 | 卖家可以通过退款接口将支付款退还给买家, 61 | 支付宝将在收到退款请求并且验证成功之后, 62 | 按照退款规则将支付款按原路退到买家帐号上. 63 | 交易超过约定时间(签约时设置的可退款时间)的订单无法进行退款 64 | 支付宝退款支持单笔交易分多次退款, 65 | 多次退款需要提交原支付订单的商户订单号和设置不同的退款单号. 66 | 一笔退款失败后重新提交,要采用原来的退款单号. 67 | 总退款金额不能超过用户实际支付金额 68 | 69 | # 交易退款查询: 70 | * [统一收单交易退款查询](https://opendocs.alipay.com/open/7be83133_alipay.trade.fastpay.refund.query?scene=common&pathHash=7cf4fed5) 71 | 商户可使用该接口查询自已通过alipay.trade.refund或alipay.trade.refund.apply提交的退款请求是否执行成功. 72 | 该接口的返回码10000,仅代表本次查询操作成功,不代表退款成功. 73 | 如果该接口返回了查询数据, 74 | 且refund_status为空或为REFUND_SUCCESS,则代表退款成功, 75 | 如果没有查询到则代表未退款成功,可以调用退款接口进行重试. 76 | 重试时请务必保证退款请求号一致. 77 | 78 | # 查询账单下载地址: 79 | * [查询对账单下载地址](https://opendocs.alipay.com/open/3c9f1bcf_alipay.data.dataservice.bill.downloadurl.query?scene=common&pathHash=97357e8b) 80 | 为方便商户快速查账,支持商户通过本接口获取商户离线账单下载地址 81 | 82 | # 交易验签: 83 | * [RSA 和 RSA2 签名算法区别](https://docs.open.alipay.com/291/106115/) 84 | 新建应用只支持 RSA2 签名方式,目前已使用RSA签名方式的应用仍然可以正常调用接口, 85 | 详情请见[开放平台接口签名方式升级公告.](https://docs.open.alipay.com/10505) 86 | 87 | ## Quick Start 88 | 89 | ```xml 90 | 91 | 92 | com.github.thierrysquirrel 93 | alipay 94 | 1.4.0.0-RELEASE 95 | 96 | ``` 97 | 98 | # App支付: 99 | 100 | ```java 101 | public class AppPay { 102 | public String appPay() throws AlipayApiException { 103 | return PayRootChainFactory 104 | .createdPayChain("appId", "privateKey", "publicKey") 105 | .appPay("outTradeNo", "totalAmount", "subject") 106 | .builder() 107 | .pay("notifyUrl"); 108 | } 109 | } 110 | ``` 111 | 112 | # 手机网站支付: 113 | 114 | ```java 115 | public class WapPay { 116 | public String wapPay() throws AlipayApiException { 117 | return PayRootChainFactory 118 | .createdPayChain("appId", "privateKey", "publicKey") 119 | .wapPay("outTradeNo", "totalAmount", "subject") 120 | .builder() 121 | .pay("returnUrl", "notifyUrl"); 122 | } 123 | } 124 | ``` 125 | 126 | # 电脑网站支付: 127 | 128 | ```java 129 | public class PagePay { 130 | public String pagePay() throws AlipayApiException { 131 | return PayRootChainFactory 132 | .createdPayChain("appId","privateKey","publicKey") 133 | .pagePay("outTradeNo","totalAmount","subject") 134 | .builder() 135 | .pay("returnUrl","notifyUrl"); 136 | } 137 | } 138 | ``` 139 | 140 | # 交易查询: 141 | 142 | ```java 143 | public class PayQuery { 144 | public String payQuery() throws AlipayApiException { 145 | return PayRootChainFactory 146 | .createdPayChain("appId", "privateKey", "publicKey") 147 | .queryPay("outTradeNo", "tradeNo") 148 | .builder() 149 | .query(); 150 | } 151 | } 152 | ``` 153 | 154 | # 交易关闭: 155 | 156 | ```java 157 | public class PayClose { 158 | public String payClose() throws AlipayApiException { 159 | return PayRootChainFactory 160 | .createdPayChain("appId", "privateKey", "publicKey") 161 | .closePay("tradeNo", "outTradeNo") 162 | .builder() 163 | .close(); 164 | } 165 | } 166 | ``` 167 | 168 | # 交易退款: 169 | 170 | ```java 171 | public class PayRefund { 172 | public String payRefund() throws AlipayApiException { 173 | return PayRootChainFactory 174 | .createdPayChain("appId", "privateKey", "publicKey") 175 | .refundPay("refundAmount", "outTradeNo", "tradeNo") 176 | .builder() 177 | .refund(); 178 | } 179 | } 180 | ``` 181 | 182 | # 交易退款查询: 183 | 184 | ```java 185 | public class PayRefundQuery { 186 | public String payRefundQuery() throws AlipayApiException { 187 | return PayRootChainFactory 188 | .createdPayChain("appId", "privateKey", "publicKey") 189 | .refundQueryPay("outRequestNo", "tradeNo", "outTradeNo") 190 | .builder() 191 | .refundQuery(); 192 | } 193 | } 194 | ``` 195 | 196 | # 查询账单下载地址: 197 | 198 | ```java 199 | public class PayDownloadQuery { 200 | public String payDownloadQuery() throws AlipayApiException { 201 | return PayRootChainFactory 202 | .createdPayChain("appId","privateKey","publicKey") 203 | .downloadQueryPay("billType","billDate") 204 | .builder() 205 | .downloadQuery(); 206 | } 207 | } 208 | ``` 209 | 210 | # 交易验签: 211 | 212 | ```java 213 | public class PayCheck { 214 | public boolean payCheck(HttpServletRequest request){ 215 | Map parameterMap=request.getParameterMap(); 216 | Map reload = PayCheckFactory.reload(parameterMap); 217 | return PayCheckFactory.check(reload); 218 | } 219 | } 220 | ``` 221 | 222 | 223 | 224 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.github.thierrysquirrel 8 | alipay 9 | 1.4.0.0-RELEASE 10 | 11 | alipay 12 | alipay 13 | https://github.com/ThierrySquirrel/alipay 14 | 15 | 16 | 21 17 | 1.18.34 18 | 4.39.165.ALL 19 | 3.13.0 20 | 3.8.0 21 | 3.2.4 22 | 23 | 24 | 25 | 26 | org.projectlombok 27 | lombok 28 | ${lombok.version} 29 | provided 30 | 31 | 32 | com.alipay.sdk 33 | alipay-sdk-java 34 | ${alipay-sdk-java.version} 35 | 36 | 37 | 38 | 39 | 40 | The Apache License, Version 2.0 41 | http://www.apache.org/licenses/LICENSE-2.0.txt 42 | 43 | 44 | 45 | 46 | 47 | ThierrySquirrel 48 | 2161271173@qq.com 49 | 50 | developer 51 | 52 | +8 53 | 54 | 55 | 56 | 57 | scm:git:https://github.com/ThierrySquirrel/alipay.git 58 | scm:git:https://github.com/ThierrySquirrel/alipay.git 59 | 60 | https://github.com/ThierrySquirrel/alipay 61 | v${project.version} 62 | 63 | 64 | 65 | 66 | ossrh 67 | https://oss.sonatype.org/content/repositories/snapshots 68 | 69 | 70 | ossrh 71 | Maven Central Staging Repository 72 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 73 | 74 | 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-compiler-plugin 81 | ${maven-compiler-plugin.version} 82 | 83 | ${java.version} 84 | ${java.version} 85 | UTF-8 86 | 87 | 88 | 89 | org.apache.maven.plugins 90 | maven-javadoc-plugin 91 | ${maven-javadoc-plugin.version} 92 | 93 | 94 | attach-javadocs 95 | 96 | jar 97 | 98 | 99 | 100 | 101 | 102 | org.apache.maven.plugins 103 | maven-gpg-plugin 104 | ${maven-gpg-plugin.version} 105 | 106 | 107 | sign-artifacts 108 | verify 109 | 110 | sign 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /src/main/java/com/github/thierrysquirrel/alipay/container/PayCheckFactoryContainer.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 | /** 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 reload(Map parameterMap) { 53 | Map map = new ConcurrentHashMap<>(PayCheckFactoryContainer.MAP_DEFAULT_SIZE); 54 | parameterMap.forEach((name, values) -> map.put(name, String.join(PayCheckFactoryContainer.RELOAD_JOIN, values))); 55 | return map; 56 | } 57 | 58 | /** 59 | * The Signature Verification Is A One-Time Signature Verification. 60 | * Please Conduct The Second Signature Verification In Combination With The Business 61 | * 1. The Merchant Needs To Verify Whether The Out Trade No In The Notification Data Is The Order Number Created In The Merchant System, 62 | * 2. Determine Whether The Total Amount Is The Actual Amount Of The Order (That Is, The Amount When The Merchant Order Is Created), 63 | * 3. Verify That The seller_id (or seller_email) 64 | * In The Notice Is The Corresponding Operator Of The out_trade_no Document 65 | * (Sometimes, A Merchant May Have Multiple seller_id/seller_email), 66 | * 4. Verify Whether The app_id Is The Merchant Itself. 67 | * If Any Of The Above 1, 2, 3 And 4 Fails To Pass The Verification, It Indicates That This Notification Is An Exception Notification And Must Be Ignored. 68 | * After The Above Verification Is Passed, Merchants Must Correctly Conduct Different Business Processes According To Different Types Of Business Notifications of AliPay, 69 | * And Filter Repeated Notification Of The Result Data. 70 | * In AliPay's Business Notification, 71 | * AliPay Will Only Be Deemed Successful As A Buyer When The Transaction Notification State Is TRADE_SUCCESS Or TRADE_FINISHED. 72 | *

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 reloadMap, String publicKey) throws AlipayApiException { 93 | return AlipaySignature.rsaCheckV1(reloadMap, publicKey, 94 | PayClientConstant.PAY_CHARSET.getValue(), 95 | PayClientConstant.PAY_SIGN_TYPE.getValue()); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/github/thierrysquirrel/alipay/factory/PayRootChainFactory.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.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 goodsDetail) { 127 | alipayTradeAppPayModel.setGoodsDetail(goodsDetail); 128 | return this; 129 | } 130 | 131 | /** 132 | * Absolute timeout, format yyyy MM dd HH: mm: ss 133 | *

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 queryOptions) { 205 | alipayTradeAppPayModel.setQueryOptions(queryOptions); 206 | return this; 207 | } 208 | 209 | 210 | } 211 | -------------------------------------------------------------------------------- /src/main/java/com/github/thierrysquirrel/alipay/pay/param/PagePayParamChain.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.*; 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 goodsDetail) { 151 | alipayTradePagePayModel.setGoodsDetail(goodsDetail); 152 | return this; 153 | } 154 | 155 | /** 156 | * The absolute timeout period for the order. 157 | * The format is yyyy MM dd HH: mm: ss 158 | *

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 goodsDetail) { 156 | alipayTradeWapPayModel.setGoodsDetail(goodsDetail); 157 | return this; 158 | } 159 | 160 | /** 161 | * Absolute timeout, in the format yyyy MM dd HH: mm: ss. Time limit range: 1m~15d 162 | *

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 queryOptions) { 109 | alipayTradeQueryModel.setQueryOptions(queryOptions); 110 | return this; 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/github/thierrysquirrel/alipay/pay/refund/PayRefundChain.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; 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 refundGoodsDetail) { 138 | alipayTradeRefundModel.setRefundGoodsDetail(refundGoodsDetail); 139 | return this; 140 | } 141 | 142 | /** 143 | * Details of Refund Accounts 144 | *

145 | * 退分账明细信息 146 | * 147 | * @param refundRoyaltyParameters refundRoyaltyParameters 148 | * @return PayRefundParamChain 149 | */ 150 | public PayRefundParamChain builderRefundRoyaltyParameters(List refundRoyaltyParameters) { 151 | alipayTradeRefundModel.setRefundRoyaltyParameters(refundRoyaltyParameters); 152 | return this; 153 | } 154 | 155 | /** 156 | * query option 157 | *

158 | * 查询选项 159 | * 160 | * @param queryOptions queryOptions 161 | * @return PayRefundParamChain 162 | */ 163 | public PayRefundParamChain builderQueryOptions(List queryOptions) { 164 | alipayTradeRefundModel.setQueryOptions(queryOptions); 165 | return this; 166 | } 167 | 168 | /** 169 | * For payment term transactions, if a refund is to be made after confirming settlement, it is necessary to specify the settlement number at the time of confirmation settlement 170 | *

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 queryOptions) { 111 | alipayTradeFastpayRefundQueryModel.setQueryOptions(queryOptions); 112 | return this; 113 | } 114 | } 115 | --------------------------------------------------------------------------------