Jump to content

php script with paypal


aquanuke

Recommended Posts

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

Link to comment
Share on other sites

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'];

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.