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
https://forums.phpfreaks.com/topic/244175-php-script-with-paypal/
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'];

 

 

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.