Use Pbfunc in PowerBuilder to pay the _javascript skills in the payment function in the face

Source: Internet
Author: User

In the PB implementation Alipay pay the function, need to first in Alipay merchant contract, and set the relevant public key information (specific reference Alipay document).

The corresponding private key file is then used to calculate the parameters in front of the RSAWITHSHA1. The specific code is as follows:

String Ls_pubfilename,ls_prifilename n_pbfunc_cryp Lnv_cryp ls_prifilename = "D:\PBFUNCLIB_PRI.PEM"//private key file string Ls_ str string Ls_appid,ls_secret,ls_biz_content ls_appid = "3434343"//Change to your appId ls_biz_content= ' {"Out_trade_no": " 2015020011 "," Scene ":" Bar_code "," Auth_code ":" ' +sle_1.text+ ' "," subject ":" Pay by face bar code "," Total_amount ":" 0.01 "} ' Ls_str = "App_id=" +ls_appid ls_str + = ' &biz_content= ' +ls_biz_content ls_str + = ' &charset=utf-8 ' ls_str + = ' &method= Alipay.trade.pay ' ls_str + = ' &sign_type=rsa ' ls_str + = ' &timestamp=2016-05-08 11:27:15 ' ls_str + = ' &version= 1.0 ' string ls_sigstr blob utf8r utf8r =lnv_cryp.of_str2utf8 (LS_STR) if Lnv_cryp.of_sha1withrsa (ls_prifilename,utf8r, Lnv_cryp. HASH_RESULT_DEFAULT,LS_SIGSTR) then MessageBox ("hint", "Signature succeeded:" +ls_sigstr) Else MessageBox ("hint", "signature failed") End If/* verification signature may not be required To invoke/Ls_pubfilename = "D:\PBFUNCLIB_PUB.PEM"//Generate the public key file in D disk Pbfunclib_pub.pem IF not LNV_CRYP.OF_RSAVERIFYFILESHA1 (ls_ Pubfilename,utf8r,ls_sigstr,lnv_cryp. Hash_result_default) Then MEssagebox ("Prompt", "Verify signature Failed") Else MessageBox ("", "Verify signature succeeded") End IF//ls_str = ' n_pbfunc_http lnv_http lnv_http.of_clear ()/ Empty parameter string Ls_data ls_data = "app_id=" +wf_alipay_urlencode (ls_appid) Ls_data + = "&biz_content=" +wf_alipay_ UrlEncode (ls_biz_content) Ls_data + = "&charset=" +wf_alipay_urlencode ("Utf-8") Ls_data + = "&method=" +wf_ Alipay_urlencode ("Alipay.trade.pay") Ls_data + = "&sign_type=" +wf_alipay_urlencode ("RSA") Ls_data = "&sign=" +wf_alipay_urlencode (ls_sigstr) Ls_data + = "&timestamp=" +wf_alipay_urlencode ("2016-05-08 11:27:15") Ls_data = " &version= "+wf_alipay_urlencode (" 1.0 ") Lnv_http.of_set_url (" Https://openapi.alipay.com/gateway.do? ") +ls_data) Blob lblb_data string ls_error IF lnv_http.of_post (lblb_data,ls_error) Then string Gbkdata gbkdata = Lnv_cry P.OF_UTF8TOGBK (Lblb_data)//Because the return is UTF-8 encoding, the direct display will be garbled MessageBox ("hint", gbkdata+ "" +string (lblb_data)) Else MessageBox (" Prompt ", execution failed") End IF

Where the Wf_alipay_urlencode function code is as follows:

LS_STR is the parameter
n_pbfunc_encode lnv_encode
string ls_content,ls_reserved//indicates the character that does not need to be encoded
ls_reserved = ""/ All need to encode
string ls_sigstr
blob utf8r
utf8r =lnv_encode.of_str2utf8 (ls_str)
Lnv_encode.of_uriencode2 ( utf8r,ls_content) return
ls_content

The above is a small set to introduce the use of Pbfunc in the PowerBuilder pay in the face of payment function, hope to help everyone, if you have any questions welcome to my message, small series will promptly reply.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.