PHP integrates PayPal payment and php integrates paypal. PHP integrated PayPal payment, php integrated paypal simple arrangement PHP project integrated PayPal payment function. 1. Form Construction: formmethodpostnameformactionwww. paypal. co PHP integrated PayPal payment, php integrated paypal
Simply sort out the PHP project and integrate the PayPal payment function.
1. form construction:
II. IPN verification
<? Phpclass paypal {var $ ipn_data = array (); // array contains the POST values for IPN var $ fields = array (); // form parameters submitted to Paypal, for example: item_name = iPhone 6, quantity = 1, amount = 499, currency_code = USD, and other form information. // you must initialize var $ paypal_url = 'before calling IPN verification' https://www.paypal.com/cgi-bin/webscr '; // Sandbox: https://www.sandbox.paypal.com/cgi-bin/webscr Function validate_ipn () {// verify IPN // parse the paypal URL $ url_par = parse_url ($ this-> 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 ($ _ POST as $ 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. return false;} else {// Post the data back to paypal fputs ($ 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 Through the response from the server and append to variable while (! Feof ($ fp) {$ this-> validate_ipn_response. = fgets ($ fp, 1024);} fclose ($ fp); // close connection} if (eregi ("VERIFIED", $ this-> validate_ipn_response )) {return true;} else {return false ;}}}?>
The above is all the content of this article. I hope you will like it.
Alipay simply sorted out the PHP project and integrated the PayPal payment function. 1. form Construction: form method = "post" name = "form" action = "https://www.paypal.co...