VFP handles the payment. You need to know some knowledge to do it

“   People who boast about the power of programming language are usually the power of the language itself, not the power of this person. Whenever, language is just a tool. -- Garfield "

Recently, a friend asked whether VFP can be paid. It must be paid for VFP. Kitty has done all the components well. After opening an account, it can be directly connected.

Let's demonstrate it.

, duration 00:55

01

Official payment and aggregate payment

Official payment

The company that runs to WeChat company is WeChat official, Alipay is Alipay official.  

Disadvantages: the rate is high, and it is necessary to pay attention to the public account

Aggregate payment

It is aggregated WeChat payment, Alipay payment, Baidu wallet payment, UnionPay and other payment methods as a whole, a variety of payment methods, to provide business receipts. Can receive personal information.

There are many companies in the market that can provide this method, such as UnionPay aggregate payment

02

Type of payment product

Payment code

Payment code payment means that the user displays the "payment code" in the wechat wallet to the merchant system for scanning and then directly completes the payment. It is applicable to the scene of face-to-face cashier in offline venues, such as supermarkets, convenience stores, restaurants, hospitals, schools, cinemas, scenic spots and other physical places with clear business addresses.

JSAPI payment

JSAPI payment refers to the payment of JSAPI in the payment scenario by the JSAPI interface provided by the WeChat payment, and the payment is completed with the WeChat payment module. JSAPI payment is required to be initiated within the official account.

Application scenarios include:

Offline place: call the interface to generate QR code. After scanning the QR code, the user opens the page in wechat browser and completes the payment

Public scene: users enter the official account number in WeChat official account, open a main page and complete payment.

PC website scenario: the QR code is displayed in the website. After scanning the QR code, the user opens the page in the wechat browser and completes the payment

H5 payment

H5 payment means that the merchant displays goods or services on the mobile terminal web page outside the wechat client. When the user confirms to use wechat payment on the above page, the merchant initiates this service and calls the wechat client for payment. It is mainly used in the scenario where the touch-screen mobile browser requests wechat payment. It can easily evoke wechat payment from an external browser.

Native payment

Native payment refers to the mode in which the merchant system generates a payment QR code according to the wechat payment agreement, and the user uses wechat to "scan" to complete the payment.

This mode is applicable to PC website, physical store single product or order, media advertising payment and other scenarios.  

Applet payment

Applet payment means that the merchant realizes the payment function in the wechat applet platform by calling the wechat payment applet payment interface; The user opens the merchant assistant applet to place an order, enters the payment password and completes the payment, and then returns to the merchant applet


 

03

Applet payment process

04

critical code

1. Wechat applet initiates payment

To send openid, commodity name and amount to the background API

wx.request({url: app.globalData.serverurl + 'ctl_pay.fsp?proc=unifiedorder2&token='+token,..})

2. Receive VFP program webapi and prepare various payment parameters

The three parameters received above will be,Add the order number to call the payment function oweixinPay=Newobject("Qiyupay_unionpay","Qiyupay_unionpay.prg")*--Three payment related parameters should not be wrong oweixinPay.appid=""oweixinPay.unionpayid=""oweixinPay.unionPayKey=""&&Callback to set oweixinPay.notify_url=""&&order number,explain,amount of money,openidcJson=oweixinPay.unionpay_Wxpay(cout_trade_no,cattach,ntotal_fee,copenid)If Isnull(cJson)  &&Error throwing  Error oweixinPay.msgEndifReturn cJson

three   The returned JSON structure is

{timeStamp:"",nonceStr:"",package:"",signType:"",paySign:""}

4. According to the JSON structure above, payment can be pulled up.

wx.requestPayment({  timeStamp: obj.timeStamp,  nonceStr: obj.nonceStr,  package: obj.package,  signType: obj.signType,  paySign: obj.paySign,  success: function (res) {  console.log(res);  wx.hideLoading();//Jump to page},   fail:   function   (res)   {  wx.hideLoading();  console.log(res);}})

5 get payment results

There are two main methods. One is active query. You don't know whether the actual accounts have arrived after payment. Generally, you need to call the active query interface to see whether the accounts have arrived after one to three seconds? Proceed to the next step upon receipt.

Background notification: if the payment reaches your account, the payment server will call the callback URL you gave earlier to send data.

These two processes should be handled according to the business processes of receipt and non receipt. We should pay attention to both normal processes and abnormal processes.

6 data recalled by the payment server

Important order number, amount and other records will enter the business process after receiving the data.

I provide a template here, which can be implemented for reference.

Define Class ctl_notice_ht As Session    *-- For payment callback  Procedure onDefault          cData=HttpGetPostData()      lcresult_code=this.getXmlContent("result_code",cData)      lctotal_fee=this.getXmlContent("total_fee",cData)      lcout_trade_no=this.getXmlContent("out_trade_no",cData)        *First, remove the weight,Order flag updating succeeded,Processing business logic                      RETURN ""  Endproc    Function getXmlContent(cName ,cXmldata)    If Empty(cXmldata)      Return ""    Endif    Local lc value    lc value = ""    lc value  = Strextract(m.cXmldata, "<"+cName +"><![CDATA[", "]]></"+cName + ">")    Return lc value  EndfuncEnddefine

Q & A:

1 is aggregate payment secure?

What the co payment is doing is to open up various payment channels, which can get through the payment channels of Alipay, WeChat payment, cloud flash payment, flower chant, credit card and so on.

The aggregate payment is only involved in the liquidation of funds in the whole process. The money is directly butted by third party platforms (banks, Alipay, WeChat) and merchants. For example, businesses choose to cooperate with the third party payment platform (Alipay, WeChat payment, cloud flash payment, etc.). If the merchant receives the money from Alipay, then Alipay will enter the designated Alipay balance account after the settlement. If the money received comes from wechat, wechat will put the money into the wechat merchant platform, and the merchant can withdraw cash the next day. That is to say, the money of merchants is guaranteed by banks, Alipay and WeChat.

Now there is no such thing as "Er Qing", which is illegal. And paying for licenses is expensive.

2. Can I open an individual account for aggregate payment?

No, only with a business license, such as self-employed. It can be collected to individual or public accounts.

3 will it be difficult to pay for VFP calls?

Garfield has integrated the class library, called directly, and the code is simple. Code scanning payment is very simple and can be used out of the box. Applet calls need guidance.

Posted by e4c5 on Wed, 20 Oct 2021 21:51:53 -0700