aktualnie mam już prawie wszystkie płatności, zostało mi jedynie dodanie pay safe card, oraz pay pal'a
Jak widzicie temat dotyczy PP, mam problem z tym że po prostu nie działa, choć powinno.
Czy ktoś mógł poratować przykładami jak tego używać, chodzi mi o to że osoba logouje sie na strone, wchodzi w panel, wpisuje wartość i klika guzik, jest przekierowywana na strone ppala płaci (tyle mam), ale nie umiem sprawdzić czy płatność dotarła, ustawiłem return URL'a, lecz POST jest pusty, a ja pieniążki dostaje na paypala (sprawdzałem), zamieszczam kodzik niżej:
test.php (czyli główny)
<FORM ACTION="https://www.paypal.com/cgi-bin/webscr" METHOD="POST"> <INPUT TYPE="hidden" NAME="cmd" VALUE="_xclick"> <INPUT TYPE="hidden" NAME="NOSHIPPING" VALUE="2"> <INPUT TYPE="hidden" NAME="business" VALUE="xierip@gmail.com"> <INPUT TYPE="hidden" NAME="user_id" VALUE="fffff user id"> <INPUT TYPE="hidden" NAME="item_name" VALUE="Monety w sklepie serwerowym"> <INPUT TYPE="number" NAME="amount"/> <INPUT TYPE="hidden" NAME="currency_code" VALUE="PLN"> <input type="hidden" value="http://darkelite.pl/return2.php" name="return"> <INPUT TYPE="image" NAME="submit" BORDER="0" SRC="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" ALT="PayPal - The safer, easier way to pay online"> <img alt="" border="" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif"> </FORM>
return.php czyli plik podany do odbioru na stronie ppala:
<?php // CONFIG: Enable debug mode. This means we'll log requests into 'ipn.log' in the same directory. // Especially useful if you encounter network errors or other intermittent problems with IPN (validation). // Set this to 0 once you go live or don't require logging. // Set to 0 once you're ready to go live // Read POST data // reading posted data directly from $_POST causes serialization // issues with array data in POST. Reading raw POST data from input stream instead. foreach ($raw_post_array as $keyval) { } // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { } else { } $req .= "&$key=$value"; } // Post IPN data back to PayPal to validate the IPN data is genuine // Without this step anyone can fake IPN data if(USE_SANDBOX == true) { $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; } else { $paypal_url = "https://www.paypal.com/cgi-bin/webscr"; } $ch = curl_init($paypal_url); if ($ch == FALSE) { return FALSE; } curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); if(DEBUG == true) { curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLINFO_HEADER_OUT, 1); } // CONFIG: Optional proxy configuration //curl_setopt($ch, CURLOPT_PROXY, $proxy); //curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); // Set TCP timeout to 30 seconds curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // CONFIG: Please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path // of the certificate as shown below. Ensure the file is readable by the webserver. // This is mandatory for some environments. //$cert = __DIR__ . "./cacert.pem"; //curl_setopt($ch, CURLOPT_CAINFO, $cert); $res = curl_exec($ch); if (curl_errno($ch) != 0) // cURL error { if(DEBUG == true) { } curl_close($ch); exit; } else { // Log the entire HTTP response if debug is switched on. if(DEBUG == true) { } curl_close($ch); } // Inspect IPN validation result and act accordingly // Split response headers and payload, a better way for strcmp // check whether the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your PayPal email // check that payment_amount/payment_currency are correct // process payment and mark item as paid. // assign posted variables to local variables //$item_name = $_POST['item_name']; //$item_number = $_POST['item_number']; //$payment_status = $_POST['payment_status']; //$payment_amount = $_POST['mc_gross']; //$payment_currency = $_POST['mc_currency']; //$txn_id = $_POST['txn_id']; //$receiver_email = $_POST['receiver_email']; //$payer_email = $_POST['payer_email']; if(DEBUG == true) { } echo"dziala".$_POST['item_name']."x".$_POST['payment_status']."x".$_POST['payer_email']."x".$_POST['receiver_email']."x".$_POST['mc_gross'].$_POST['user_id']; // log for manual investigation // Add business logic here which deals with invalid IPN messages if(DEBUG == true) { } } ?>
zawsze zwraca "nie dziala", prosze o pomoc, ew przykłady kodu, nie musi być to IPN.
Po zakończeniu płatności chce dodać rekord do bazy danych.
Pozdrawiam i dziękuje za wszelkie odpowiedzi.