PHP integrated PayPal payment, PHP integrated PayPal
Simply organize your PHP project to integrate PayPal payment functionality.
One, the construction of the form:
Second, the IPN verification part
<?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 all form information,//prior to invoking validation IPN Need to initialize good var $paypal _url = ' 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 to 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=_notify-validate"; Append IPN command//Open the connection to PayPal $fp = Fsockopen ($url _par[host], "Z", $errnum, $errstr, 30);if (! $fp) {//Could 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\r\n"); Fputs ($fp, $post _str. "\r\n\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 mentioned is the whole content of this article, I hope you can like.
http://www.bkjia.com/PHPjc/1015435.html www.bkjia.com true http://www.bkjia.com/PHPjc/1015435.html techarticle PHP integrated PayPal Payment, PHP integrated PayPal simple collation PHP project integrated paypal payment function. Form construction: Form method= "POST" name= "form" action= "https://www.paypal.co ...