aquanuke Posted August 8, 2011 Share Posted August 8, 2011 Would someone be able to explain how you interact with paypal payments with php. I need to set up a simple payment where a user buys credits ie 1 credit costs £10. Ive used paypals simple form before but then just actioned the event myself after Ive received the email from paypal. How would I automate a process so when a user purchases X amount of credits it then sends a response back to my script so that my script then adds the correct amount of credits purchased into mysql. Thanks Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted August 8, 2011 Share Posted August 8, 2011 Paypal IPN (Instant Payment Notification) Quote Link to comment Share on other sites More sharing options...
phpSensei Posted August 8, 2011 Share Posted August 8, 2011 Upon the checkout your form should send predefined field names given to you by Paypal itself. You have to follow their criteria.. Such as an item number.. Once these fields are sent to paypal and the payment goes through processing, it sends back a set of variables to let you know how the process went, and paypal sends this to your IPN script.... <input type="hidden" name="item_number1" value="{$row['someID']}" /> Here's the variables returned to you after paypal handles the request and send it back $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']; Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted August 8, 2011 Share Posted August 8, 2011 to add to what phpSensei has mentioned, You also have the option of adding a 'custom' input field, with which you can send anything else you need, such as the user's id. <input type="hidden" name="custom" value="user id or something here" /> <?php $custom = $_POST['custom']; ?> Note: the input field name must be 'custom' you can't name it anything else. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted August 8, 2011 Share Posted August 8, 2011 to add to what phpSensei has mentioned, You also have the option of adding a 'custom' input field, with which you can send anything else you need, such as the user's id. <input type="hidden" name="custom" value="user id or something here" /> <?php $custom = $_POST['custom']; ?> Note: the input field name must be 'custom' you can't name it anything else. Yeah exactly, If I were you OP, I would encrypt my data for security reasons and try not to expose obvious data structure. Quote Link to comment Share on other sites More sharing options...
aquanuke Posted August 8, 2011 Author Share Posted August 8, 2011 Thanks Quote Link to comment Share on other sites More sharing options...
phpSensei Posted August 8, 2011 Share Posted August 8, 2011 We are glad to help, to help the community save time, please mark thread as solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.