In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you the content of a sample analysis of the development of Wechat's enterprise payment encapsulation by C#. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Introduction of enterprise payment
The so-called enterprise payment means that after the opening of the function, such as customer claim settlement, surrender, commodity refund, bonus distribution of solicitation activities, lottery interaction and other operations in the insurance industry can be completed through enterprise payment. Prior to this, WeChat Pay could only provide customers with one-way payment to the enterprise.
If merchants need to pay users, they can directly put the money into the user's "Wechat change". WeChat Pay will notify the news of the change, and the details of the income and expenditure of the change will show the corresponding records. For the historical client version of the no change account, the funds will be entered into the user's red packet account, WeChat Pay has no news to notify the user, and the enterprise can choose to reach the user on its own.
The certified enterprise account can activate WeChat Pay function. The certified enterprise account can manage the "WeChat Pay" entrance of the "service center" of the platform to apply for WeChat Pay function. After the WeChat Pay function is activated, the enterprise will have two functions: collection and payment. If the payment is made by the user number to the enterprise account, the payment will go into the merchant number associated with the enterprise account. At the same time, the enterprise account can pay to the user account in the form of WeChat red packet or Wechat.
Enterprise payment, provides the function that the enterprise pays to the user, supports the enterprise to pay through the API interface, or through the WeChat Pay merchant platform web page function to pay.
The function involving capital operation requires high security, which requires the operator to install the certificate (merchant platform-account setting-password security-operation certificate); pay to the target user through API or web page operation (the enterprise can lock the target user according to APPID+OpenID). For users who have been authenticated by their real names, WeChat Pay can provide an optional function to verify the consistency of real names.
Enterprise payment reminder:
◆ pays the same real-name user with a single daily limit of 2W/2W
◆ pays the same non-real-name user with a single daily limit of 2000, 2000
◆ A merchant's total payment limit on the same day is 100W.
◆ only supports APPID whose merchant number is bound.
◆ aims at the target users of payment. Users who have been authenticated by WeChat Pay's real name can provide the function of verifying their real names. Users without real name authentication cannot. Enterprises can choose the verification type according to the security level of their own business.
The amount of ◆ payment must be less than or equal to the amount of the merchant's current available balance
◆ payment records, enterprises can check the corresponding data through the enterprise payment query.
2. Enterprise payment API
Enterprise payment business is based on the fund management ability of WeChat Pay merchant platform. In order to help merchants easily realize enterprise payment to individuals, for some merchants with development ability, it provides the function of enterprise payment through API.
For example, the current insurance industry to the customer surrender, payment, claim settlement.
The enterprise payment will use the merchant's available balance and need to ensure that the available balance is sufficient. To check the available balance, recharge and withdrawal, please log in to the merchant platform "Capital Management" to operate.
Interface address Interface Link: https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers
Is a certificate required?
The request requires a two-way certificate. For details, see the use of certificates
Request parameter
Example of submitting data:
Wxe062425f740c30d8100000983PG2J4ILTKCH16CQ2502SI8ZNMTM67VS100000982014120919616ohO4Gt7wVPxIT1A9GjFaMYMiZY1sOPTION_ check Zhang San 100Happy holidays! 10.2.3.10C97BDBACF37622775366F38B629F45E3
Example of data returned successfully:
According to the above interface description, as well as the input and return parameters, we can build the interface of the corresponding C# code
According to the above interface definition, we can define the interface information as follows
/ WeChat Pay interface / public interface ITenPayApi {/ Enterprise payment (request requires a two-way certificate) / Enterprise payment business is based on the fund management capability of WeChat Pay merchant platform, in order to help merchants easily realize the payment from the enterprise to the individual. / / provide the ability to complete enterprise payment through API for some merchants who have the ability to develop. For example, the current insurance industry to the customer surrender, payment, claim settlement. / / the enterprise payment will use the merchant's available balance and need to ensure that the available balance is sufficient. To check the available balance, recharge and withdrawal, please log in to the merchant platform "Capital Management" to operate. Https://pay.weixin.qq.com/ Note: the funds collected by WeChat Pay are not the same account and need to be recharged separately. / Enterprise payment data / CorpPayResult CorpPay (CorpPayJson json);
The above CorpPayJson and CorpPayResult are the input parameters and the obtained results, respectively. The object information of both can be defined according to the parameters.
/ Enterprise payment data information / public class CorpPayJson {public CorpPayJson () {this.check_name = "FORCE_CHECK";} / the terminal device number assigned by WeChat Pay / public string device_info {get; set } / user openid / public string openid {get; set } / check the user name option, you can use the PayCheckName enumeration object to obtain the name / NO_CHECK: do not verify the real name / FORCE_CHECK: strongly verify the real name (users without real name authentication will fail the verification Unable to transfer money) / OPTION_CHECK: real name verification only for users whose real names have been verified (users without real name verification can transfer money successfully) / public string check_name {get Set;} / the real name of the recipient. / if check_name is set to FORCE_CHECK or OPTION_CHECK, the user's real name / / public string re_user_name {get; set;} / Enterprise payment amount is required in / public int amount {get; set;} / Enterprise payment operation instructions. Required. / public string desc {get; set;} / the Ip address of the machine calling the interface / public string spbill_create_ip {get; set }} / the returned result of the enterprise payment operation / public class CorpPayResult: PayResult {/ the public account ID assigned by Wechat (enterprise corpid is this appId) / public string mch_appid {get; set } / the terminal device number assigned by WeChat Pay / public string device_info {get; set;} / merchants use the original route of the order number filled in by query API to return. / public string partner_trade_no {get; set;} / Enterprise payment is successful. The returned Wechat order number / / public string payment_no {get; set;} / Enterprise payment success time / public string payment_time {get; set;}}
The API implementation of enterprise payment is similar to the previous two red packets, one is to pass in regular account information, the other is to pass in business parameters, and then submit the result, as shown below.
/ / Enterprise payment (request requires a two-way certificate) / / Enterprise payment business is based on the fund management capability of WeChat Pay merchant platform, in order to help merchants easily realize enterprise payment to individuals, / / provide the function of enterprise payment through API for some merchants with development ability. For example, the current insurance industry to the customer surrender, payment, claim settlement. / / the enterprise payment will use the merchant's available balance and need to ensure that the available balance is sufficient. To check the available balance, recharge and withdrawal, please log in to the merchant platform "Capital Management" to operate. Https://pay.weixin.qq.com/ Note: the funds collected by WeChat Pay are not the same account and need to be recharged separately. / Enterprise payment data / public CorpPayResult CorpPay (CorpPayJson json) {CheckAccount (); / / check the object attribute value of AccountInfo WxPayData data = new WxPayData (); data.SetValue ("mch_appid", AccountInfo.UniteAppId) / / Public account appid, note that it is mch_appid, not wxappid data.SetValue ("mchid", AccountInfo.MchID); / / merchant number, note that it is mchid rather than mch_id data.SetValue ("nonce_str", data.GenerateNonceStr ()); / / random string data.SetValue ("spbill_create_ip", NetworkUtil.GetIPAddress ()) / / Terminal ip data.SetValue ("partner_trade_no", data.GenerateOutTradeNo (AccountInfo.MchID)); / / Random string data.SetValue ("device_info", json.device_info); / / Terminal ip data.SetValue ("openid", json.openid); data.SetValue ("check_name", json.check_name) Data.SetValue ("re_user_name", json.re_user_name); data.SetValue ("amount", json.amount); data.SetValue ("desc", json.desc); data.SetValue ("sign", data.MakeSign (AccountInfo.PayAPIKey)) / / finally generate signature var url = string.Format ("https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"); return Helper.GetPayResultWithCert (data, url, AccountInfo.CertPath, AccountInfo.CertPassword);}
After the interface is defined and implemented, we can call and test API in the project. The specific code is as follows
CorpPayJson json = new CorpPayJson () {amount = 100, check_name = PayCheckName.FORCE_CHECK.ToString (), desc = "Test refund", openid = this.openId, device_info = "", re_user_name = "Wu Hua Cong" Spbill_create_ip = NetworkUtil.GetIPAddress ()} Var result = api.CorpPay (json); var message = string.Format ("Enterprise Direct payment: {0} {1}", result.Success? Success: failure, result.Message); Console.WriteLine (message); Console.WriteLine (result.ToJson ())
After the payment operation is successful, we can see that the money goes directly to the user's wallet, and we can also view the records at the merchant background and see the corresponding records.
Thank you for reading! On the "C# development of Wechat enterprise payment encapsulation example analysis" this article shares here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.