: This article mainly introduces the PayPal website payment standard edition forPHP. if you are interested in the PHP Tutorial, please refer to it. Simply sort out the PHP project and integrate the PayPal payment function.
1. form construction:
II. IPN verification
Paypal_url); // generate the post string from the _ POST vars aswell as load the // _ POST vars into an arry so we can play with them from the calling // script. $ post_str = ''; foreach ($ _ POSTas $ field => $ value) {$ this-> ipn_data [" $ field "] = $ value; $ post_str. = $ field. '= '. urlencode (stripslashes ($ value )). '&';} $ post_str. = "cmd = _ policy-validate"; // append ipn command // open the connection to paypal $ fp = Fsockopen ($ url_par [host], "80", $ errnum, $ errstr, 30); if (! $ Fp) {// cocould not open the connection. returnfalse;} else {// Post the data back to paypalfputs ($ fp, "POST ". $ url_par [path]. "HTTP/1.1 \ r \ n"); fputs ($ fp, "Host :". $ url_par [host]. "\ r \ n"); fputs ($ fp, "Content-type: application/x-www-form-urlencoded \ r \ n"); fputs ($ fp, "Content-length :". strlen ($ post_str ). "\ r \ n"); fputs ($ fp, "Connection: close \ r \ n"); fputs ($ fp, $ post_str. "\ r \ n"); // loop thr Ough the response from the server and append to variablewhile (! Feof ($ fp) {$ this-> validate_ipn_response. = fgets ($ fp, 1024);} fclose ($ fp); // close connection} if (eregi ("VERIFIED", $ this-> validate_ipn_response) {returntrue ;} else {returnfalse ;}}
}?>
Materials:
Developer: https://developer.paypal.com/
Instant Payment Notification: https://www.paypal-biz.com/development/documentation/PayPal_IPN&PDT_Guide_V1.0.pdf
Paypal Standard Edition: https://www.paypal-biz.com/development/documentation/PayPal_WPS_Guide_CN_V2.0.pdf
The above introduces the PayPal website payment standard edition for PHP, including the content, hope to be helpful to friends interested in PHP tutorials.