Quickly complete the development of payment modules, easily embedded in any system

Quickly complete the development of payment modules, easily embedded in any system

2022-09-05 0 1,356
Resource Number 38072 Last Updated 2025-02-24
¥ 0HKD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

This issue recommends an open source aggregate payment framework, supporting wechat Pay, Alipay Pay, etc. – IJPay.

Quickly complete the development of payment modules, easily embedded in any system插图

IJPay encapsulates wechat Pay, QQ Pay, Alipay Pay, Jingdong Pay, UnionPay, PayPal Pay and other commonly used payment methods as well as various commonly used interfaces. Does not rely on any third-party mvc framework, just as a tool to use simple and fast to complete the development of payment modules, can be easily embedded in any system.

Features

    • Simplicity first : The Module-centered project structure is simple, convenient and easy to expand, and the total inclusion does not exceed 2M after release.

Out of the box : does not rely on any third-party MVC framework, only as a tool, simple and fast to complete the development of the payment module, can be easily embedded in any system.

  • Rich channels : Support wechat Pay, QQ wallet payment, Alipay Pay, UnionPay, Jingdong Pay, etc.

 

wechat Pay: supports multi-application and multi-merchant, ordinary merchant mode and service provider mode, of course, also supports overseas, and supports the interface of Api-v3 and Api-v2 versions.

Alipay payment: supports multiple applications, and supports both common public key and public key certificate signature.

UnionPay payment: all-channel scanning code payment, wechat App payment, public number & Mini program payment, UnionPay JS payment, Alipay service window payment.

Personal wechat Pay: wechat personal merchants, the lowest rate of 0.38%, the official direct connection asynchronous callback notice.

PayPal payment: automatically manage AccessToken, quickly access a variety of commonly used payment methods.

  • Minimalist introduction : IJPay has always been simple, out-of-the-box as the core, providing a complete example of simple configuration modification can be used.

Example of accessing wechat Pay

1 Add dependencies

  • Add dependencies for all payment methods at once
<dependency>
    <groupId>com.github.javen205</groupId>
    <artifactId>IJPay-All</artifactId>
    <version>latest-version</version>
</dependency>
  • or just add a dependency on the desired payment method

Wechat Pay:

<dependency>
    <groupId>com.github.javen205</groupId>
    <artifactId>IJPay-WxPay</artifactId>
    <version>latest-version</version>
</dependency>

更多依赖:

Installation dependency | IJPay

2 Build request parameter Model

  • wechat Pay Model

The Model involved in the commonly used payment methods in IJPay is built using the builder mode, in which each field of the Model is consistent with the official interface document, and supports the merchant mode and service provider mode.

Code address:
https://gitee.com/javen205/IJPay/tree/master/IJPay-WxPay/src/main/java/com/ijpay/wxpay/model

Why use Lombok to build interface request parameters?

1. Lombok is used to build request parameters for convenience without writing too many redundant get sets.

2. Avoid low-level errors caused by manual setting of incorrect write parameters.

The outside world’s evaluation of Lombok is not quite consistent, like very much like not like hard to mock, then IJPay there are other alternatives?

Sure, the simplest way is to use Map to build the request parameters and WxPayKit.buildSign to build the signature. IJPay 1.x version does just that

  • Extension Model

Due to different payment methods, there are a lot of interfaces involved. If the Model of some interfaces does not provide encapsulation in IJPay, you can inherit all attribute field names of BaseModel and keep the interface parameters consistent and must be of String type. Finally add the following comments to implement the builder pattern.

Code address:
https://gitee.com/javen205/IJPay/blob/master/IJPay-Core/src/main/java/com/ijpay/core/model/BaseModel.java

@Builder
@AllArgsConstructor
@Getter
@Setter
public class CloseOrderModel extends BaseModel {
    // Property field names consistent with interface parameters 
    private String appid;
    // Omit other parameters in the interface... 
}

Note:

1. The extension Model must inherit BaseModel

2. All attribute field names must be consistent with interface parameters and must be of String type

3, must add Lombok annotation @Builder

@AllArgsConstructor(access = AccessLevel.PRIVATE) @Getter

4, IDEA must install Lombok plugin

3 Build the parameters and execute the request

1. According to the parameters required by the interface, use Model to build parameters other than sign

2. Create a signature after build based on the signature mode of the interface creatSign

3. Execute https request using the interface provided by WxPayApi

Code address:
https://gitee.com/javen205/IJPay/blob/master/IJPay-WxPay/src/main/java/com/ijpay/wxpay/WxPayApi.java

4. Construct payment parameters to evoke payment

  • For example, public number payment (JSAPI payment) unified order:
// Unified build request parameters 
Map< String,String> params = UnifiedOrderModel
    .builder()
    .appid(wxPayBean.getAppId())
    .mch_id(wxPayBean.getMchId())
    .nonce_str(WxPayKit.generateStr())
    .body("IJPay Make payments at your fingertips ")
    .attach("Node.js version:https://gitee.com/javen205/TNWX")
    .out_trade_no(WxPayKit.generateStr())
    .total_fee("1000")
    .spbill_create_ip(ip)
    .notify_url(wxPayBean.getDomain().concat("/wxpay/pay_notify"))
    .trade_type(TradeType.JSAPI.getTradeType())
    .openid(openId)
    .build()
    // Simultaneous supportSignType.MD5、SignType.HMACSHA256
    .creatSign(wxPayBean.getPartnerKey(), SignType.HMACSHA256);  
//Send request 
String xmlResult = WxPayApi.pushOrder(false,params); 
// The xml data returned by the request is converted into a Map, which is convenient for later logical data acquisition 
Map<String, String> resultMap = WxPayKit.xmlToMap(xmlResult);
// Judge the returned result 
String returnCode = resultMap.get("return_code");
String returnMsg = resultMap.get("return_msg");
if (!WxPayKit.codeIsOk(returnCode)) {
    return new AjaxResult().addError(returnMsg);
}
String resultCode = resultMap.get("result_code");
if (!WxPayKit.codeIsOk(resultCode)) {
    return new AjaxResult().addError(returnMsg);
}

// The following fields return  when return_code and result_code are both SUCCESS
String prepayId = resultMap.get("prepay_id");
// Secondary signature to build the parameters of public account arousing payment. The signature method here should be consistent with the above unified order request signature method 
Map< String, String>  packageParams = WxPayKit.prepayIdCreateSign(prepayId,
   wxPayBean.getAppId(),wxPayBean.getPartnerKey(),SignType.HMACSHA256);
// Returns the data built by the secondary signature to the front-end and invokes the public account payment 
String jsonStr = JSON.toJSONString(packageParams);
return new AjaxResult().success(jsonStr); 

Full sample code:
https://gitee.com/javen205/IJPay/blob/master/IJPay-Demo-SpringBoot/src/main/java/com/ijpay/demo/controller/wxpay/WxPayCo ntroller.java

Read more.

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free Source Code Quickly complete the development of payment modules, easily embedded in any system https://ictcoder.com/quickly-complete-the-development-of-payment-modules-easily-embedded-in-any-system/

Share free open-source source code

Q&A
  • 1. Automatic: After making an online payment, click the (Download) link to download the source code; 2. Manual: Contact the seller or the official to check if the template is consistent. Then, place an order and make payment online. The seller ships the goods, and both parties inspect and confirm that there are no issues. ICTcoder will then settle the payment for the seller. Note: Please ensure to place your order and make payment through ICTcoder. If you do not place your order and make payment through ICTcoder, and the seller sends fake source code or encounters any issues, ICTcoder will not assist in resolving them, nor can we guarantee your funds!
View details
  • 1. Default transaction cycle for source code: The seller manually ships the goods within 1-3 days. The amount paid by the user will be held in escrow by ICTcoder until 7 days after the transaction is completed and both parties confirm that there are no issues. ICTcoder will then settle with the seller. In case of any disputes, ICTcoder will have staff to assist in handling until the dispute is resolved or a refund is made! If the buyer places an order and makes payment not through ICTcoder, any issues and disputes have nothing to do with ICTcoder, and ICTcoder will not be responsible for any liabilities!
View details
  • 1. ICTcoder will permanently archive the transaction process between both parties and snapshots of the traded goods to ensure the authenticity, validity, and security of the transaction! 2. ICTcoder cannot guarantee services such as "permanent package updates" and "permanent technical support" after the merchant's commitment. Buyers are advised to identify these services on their own. If necessary, they can contact ICTcoder for assistance; 3. When both website demonstration and image demonstration exist in the source code, and the text descriptions of the website and images are inconsistent, the text description of the image shall prevail as the basis for dispute resolution (excluding special statements or agreements); 4. If there is no statement such as "no legal basis for refund" or similar content, any indication on the product that "once sold, no refunds will be supported" or other similar declarations shall be deemed invalid; 5. Before the buyer places an order and makes payment, the transaction details agreed upon by both parties via WhatsApp or email can also serve as the basis for dispute resolution (in case of any inconsistency between the agreement and the description of the conflict, the agreement shall prevail); 6. Since chat records and email records can serve as the basis for dispute resolution, both parties should only communicate with each other through the contact information left on the system when contacting each other, in order to prevent the other party from denying their own commitments. 7. Although the probability of disputes is low, it is essential to retain important information such as chat records, text messages, and email records, in case a dispute arises, so that ICTcoder can intervene quickly.
View details
  • 1. As a third-party intermediary platform, ICTcoder solely protects transaction security and the rights and interests of both buyers and sellers based on the transaction contract (product description, agreed content before the transaction); 2. For online trading projects not on the ICTcoder platform, any consequences are unrelated to this platform; regardless of the reason why the seller requests an offline transaction, please contact the administrator to report.
View details

Related Source code

ICTcoder Customer Service

24-hour online professional services