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 961
Resource Number 38072 Last Updated 2025-02-24
¥ 0USD 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/kyym/quickly-complete-the-development-of-payment-modules-easily-embedded-in-any-system.html

Share free open-source source code

Q&A
  • 1, automatic: after taking the photo, click the (download) link to download; 2. Manual: After taking the photo, contact the seller to issue it or contact the official to find the developer to ship.
View details
  • 1, the default transaction cycle of the source code: manual delivery of goods for 1-3 days, and the user payment amount will enter the platform guarantee until the completion of the transaction or 3-7 days can be issued, in case of disputes indefinitely extend the collection amount until the dispute is resolved or refunded!
View details
  • 1. Heptalon will permanently archive the process of trading between the two parties and the snapshots of the traded goods to ensure that the transaction is true, effective and safe! 2, Seven PAWS can not guarantee such as "permanent package update", "permanent technical support" and other similar transactions after the merchant commitment, please identify the buyer; 3, in the source code at the same time there is a website demonstration and picture demonstration, and the site is inconsistent with the diagram, the default according to the diagram as the dispute evaluation basis (except for special statements or agreement); 4, in the absence of "no legitimate basis for refund", the commodity written "once sold, no support for refund" and other similar statements, shall be deemed invalid; 5, before the shooting, the transaction content agreed by the two parties on QQ can also be the basis for dispute judgment (agreement and description of the conflict, the agreement shall prevail); 6, because the chat record can be used as the basis for dispute judgment, so when the two sides contact, only communicate with the other party on the QQ and mobile phone number left on the systemhere, in case the other party does not recognize self-commitment. 7, although the probability of disputes is very small, but be sure to retain such important information as chat records, mobile phone messages, etc., in case of disputes, it is convenient for seven PAWS to intervene in rapid processing.
View details
  • 1. As a third-party intermediary platform, Qichou protects the security of the transaction and the rights and interests of both buyers and sellers according to the transaction contract (commodity description, content agreed before the transaction); 2, non-platform online trading projects, any consequences have nothing to do with mutual site; No matter the seller for any reason to require offline transactions, please contact the management report.
View details

Related Article

make a comment
No comments available at the moment
Official customer service team

To solve your worries - 24 hours online professional service