In fact, PayPal can be divided into two parts:
International Payment is only for US dollars! China supports RMB collection and payment!
This is clear first!
Process logic:
In fact, you can get a payment interface directly on the PayPal account:
As follows:
<Form target = "PayPal" Action = "" method = "Post">
<Input type = "image" src = "" border = "0" alt = "PayPal-the safest and most convenient online payment method! ">
<Input type = "hidden" value = "1">
<Input type = "hidden" value = "_ cart">
<Input type = "hidden" value = "">
<Input type = "hidden" value = "asss">
<Input type = "hidden" value = "DF">
<Input type = "hidden" value = "10.00">
<Input type = "hidden" value = "0">
<Input type = "hidden" value = "1">
<Input type = "hidden" value = "CNY">
<Input type = "hidden" value = "1">
<Input type = "hidden" value = "kgs">
<Input type = "hidden" value = "PP-shopcartbf">
</Form>
It is inconvenient to directly use this code! It can only be added one by one, but think about it. This code can also be dynamically generated. It can be used in PHP or ASP, as long as some values inside are changed, the Payment Code of your product can be generated by reading the database, and you do not need to write them one by one !!
I wrote it like this:
Read Database: Rs should be known to everyone.
<Form action = "" method = "Post">
<Input type = "hidden" value = "_ xclick">
<Input type = "hidden" value = "<% = RS (" email ") %>"> 'your PayPal account
<Input type = "hidden" value = "<% = RS (" ordernum ") %>"> 'order number on the shopping cart on your website
<Input type = "hidden" value = "USD"> $! Cny RMB!
<Input type = "hidden" value = "<% = RS (" price ") %>"> 'product price
<Input type = "hidden" value = "'Here is the address of the message returned when the customer successfully paid the payment!
Theurl = lcase (request. servervariables ("http_host") & request. servervariables ("url ")
Theurl = left (theurl, faster Rev (theurl ,"/"))
Response. Write theurl & "INC/paypalreturn. asp"
%> ">
<Input type = "Submit" value = "use Paypal payment">
</Form>
Is this payment acceptable? If the payment is successful, make an authentication and change the order status!
This authentication is implemented on the page of paypalreturn. asp:
The Code is as follows:
Paypalreturn. asp:
<%
Mainpath = "PayPal. mdb"
Set conn = server. Createobject ("ADODB. Connection ")
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath (mainpath)
Conn. Open connstr
Function viate (itemnumber, paymentid, payamount, payeremail)
Set rs = server. Createobject ("ADODB. recordset ")
SQL = "select * from orders where ordernum = '" & itemnumber & "' Here is the order table. If the payment is successful, change the order status to paid!
Rs. Open SQL, Conn, 1, 3
If not (Rs. BOF or Rs. EOF) then
RS ("orderline") = "3"
RS ("paymentid") = paymentid
RS ("payamount") = payamount
RS ("payeremail") = payeremail
RS ("paydate") = now ()
Rs. Update
Else
Response. Write "<SCRIPT> alert ('no this order number! Please contact website administrator !! '); </SCRIPT>"
End if
Rs. Close
Set rs = nothing
End Function
Function urldecode (encodestr) 'This function decodes the urldecode returned by PayPal.
Newstr = ""
Havechar = false
Lastchar = ""
For I = 1 to Len (encodestr)
Char_c = mid (encodestr, I, 1)
If char_c = "+" then
Newstr = newstr &""
Elseif char_c = "%" then
Next_shortc = mid (encodestr, I + 1, 2)
Next_1_num = CINT ("& H" & next_1_c)
If havechar then
Havechar = false
Newstr = newstr & CHR (CINT ("& H" & lastchar & next_0000c ))
Else
If ABS (next_1_num) <= 127 then
Newstr = newstr & CHR (next_1_num)
Else
Havechar = true
Lastchar = next_0000c
End if
End if
I = I + 2
Else
Newstr = newstr & char_c
End if
Next
Urldecode = newstr
End Function
Str1 = trim (request. querystring ("TX "))
Str2 = "& AT = rdqubrmdd5awgxjh5q2hmhkmcetp4q8ulj9aapix0b1l3f9aqiv9epn1084" 'How to obtain the PayPal identity tag
"
Paypalurl = paypalurl & Str
'Response. Write "<br>" & paypalurl & "<br>"
Set objhttp = server. Createobject ("msxml2.serverxmlhttp. 3.0 ")
Objhttp. setoption 2, 13056
Objhttp. Open "Post", paypalurl, false ,"",""
Objhttp. Send ()
Responsetxt = objhttp. responsetext'
Set objhttp = nothing
'------------------------------------------------- Check the obtained value
Responsetxt = urldecode (responsetxt) 'decodes the returned value and assigns it to responsetxt
If mid (responsetxt,) = "success" then' gets the returned value status, sucess indicates that the payment is successful! Fail indicates payment failed! There are only two returned values!
Responsetxt = mid (responsetxt, 9) 'gets the return value except the first nine characters and returns it to responsetxt
Sparts = Split (responsetxt, vblf) 'separates the returned values with vblf (in VB, this is the meaning of carriage return <line feed>) and assigns it to an array sparts
Iparts = ubound (sparts)-1 'to separate the value of this array, you can understand it later!
Redim sresults (iparts, 1)
For I = 0 to iparts
Aparts = Split (sparts (I), "= ")
Skey = aparts (0)
Svalue = aparts (1)
Sresults (I, 0) = skey
Sresults (I, 1) = svalue
Select case skey
Case "first_name"
Firstname = svalue
Case "last_name"
Lastname = svalue
Case "item_name"
Itemname = svalue
Case "mc_gross"
Mcgross = svalue
Case "mc_currency"
Mccurrency = svalue
Case "txn_id"
Liushuihao = trim (svalue)
Case "payer_email"
Payeremail = trim (svalue)
End select
Next
Call viate (itemname, liushuihao, mcgross, payeremail) 'calls the function viate () for authentication and updates the status of this order!
MSG = "pay for success! Please wait for delivery! "&" \ N your order number: "& itemname &"! "
Else
MSG = "Sorry! Your operating error! Please contact website administrator !! "
End if
Response. Write "<SCRIPT> alert ('" & MSG & "'); location. href = 'user. asp '</SCRIPT>"' after payment is complete, return to the user information page!
%>
Responsetxt example:
Success mc_gross = 44.00 export = eligible address_status = confirmed payer_id = export tax = 0.00 address_street = 1 + main + st payment_date = 07% 3a32% 3a55 + dec + 22% 2C + 2008 + Pst payment_status = completed charset = Windows-1252 address_zip = 95131 first_name = test mc_fee = 1.58 rows = US address_name = test + User custom = payer_status = verified business = quota % 40163.com address_country = United + states address_city = san + Jose quantity = 1 payer_email = %%%%contact_phone = txn_id = transferpayment_type = instant last_name = user address_state = Ca region = %% %payment_region = 1.58 receiver_id = export txn_type = export item_name = 20081222225300 mc_currency = USD item_number = residence_country = US handling_amount = 0.00 transaction_subject = 20081222225300 payment_gross = 44.00 shipping = 0.00
Note: your PayPal account may have no money to perform the test. The Paypal account thinks very well. It is a website with a second-level domain name that features the same functionality as PayPal:
Https://www.sandbox.paypal.com/cgi-bin/webscr Interface
After registering an account here, you can set up two test accounts in it. The money in the two test accounts is not enough. You can use them for testing! Related information: View
Note:
Meaning of fields and returned fields when submitting PayPal
'================================================ ========================
'Mc _ gross transaction revenue
'Address _ Status address status
'Paypal _ address_id PayPal address information ID
'Payer _ id the payer's PayPal ID
'Tax
'Address _ street communication address
'Payment _ date transaction time
'Payment _ Status Transaction Status
'Charset language Encoding
'Address _ zip code
'First _ name payer's last name
'Address _ country_code country
'Address _ name: Recipient Name
'Custom' custom value
'Payer _ Status payer account status
'Business payee PayPal account
'Address _ country mailing address country
'Address _ City: communication address City
'Quantity of goods
'Payer _ email payer email
'Txn _ id transaction ID
'Payment _ type transaction type
'Last _ name payer name
'Address _ state communication address Province
'Author Er _ email recipient email
'Address _ owner has not been published/officially Enabled
'Er _ id payee ID
'Ebay _ ssss_id eBay user address ID
'Txn _ type transaction announcement Method
'Item _ name goods name
'Mc _ currency type
'Item _ number Product NO.
'Payment _ gross transaction amount [Only applicable to USD]
'Shipping shipping fee
'================================================ ========================
'Main parameters:
'Add: only one product can be purchased at a time
'Upload: multiple items can be purchased
'Shopping cart'
'<Input type = "hidden" value = "_ cart">
'Seller's account
'<Input type = "hidden">
'Product name
'<Input type = "hidden" value = "Java">
'Item No.
'<Input type = "hidden" value = "1001">
'Item prices
'<Input type = "hidden" value = "1.00">
'Item quantity-for each item
'<Input type = "hidden" value = "2">
'Currency type CNY: RMB, USD: USD
'<Input type = "hidden" value = "CNY">
'Cancel the transaction and the location to return
'<Input type = "hidden" value = "">
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/zxl0715/archive/2009/12/02/4914418.aspx