STEP 4 – PAYMENTS.PHP (THE RESPONSE)
The next part of the payments.php page handles the response from PayPal. The response is re-assigned to variables and then posted back to PayPal for verification using fsockopen.
If the response is VERIFIED then a validation check can be performed. The check_txnid and check_price functions are called to check that the correct Transaction ID and Price have been returned. The updatePayments function can finally be called to store the details of the payment in the payments table (Step 6).
STEP 5 – FUNCTIONS.PHP
The payments.php page calls upon a number of functions used to validate the returned data and store the response in the database.
2 | function check_txnid( $tnxid ){ |
7 | $sql = mysql_query( "SELECT * FROM `payments` WHERE txnid = '$tnxid'" , $link ); |
8 | if ( $row = mysql_fetch_array( $sql )) { |
14 | function check_price( $price , $id ){ |
33 | function updatePayments( $data ){ |
36 | if ( is_array ( $data )) { |
37 | $sql = mysql_query("INSERT INTO `payments` (txnid, payment_amount, payment_status, itemid, createdtime) VALUES ( |
38 | '".$data[' txn_id ']."' , |
39 | '".$data[' payment_amount ']."' , |
40 | '".$data[' payment_status ']."' , |
41 | '".$data[' item_number ']."' , |
42 | '".date("Y-m-d H:i:s")."' |
44 | return mysql_insert_id( $link ); |
No comments:
Post a Comment