user3723069
user3723069

Reputation: 65

PayPal not returning variables

I'm adding PayPal to my checkout form. Rather than using the API, I just use a form script. However, I'm not getting the response variables from PayPal after the payment has been made. I would like to confirm the amount of money I received to see if the user has paid the amount he should've paid.

Since I dont receive the response variables from paypal, I cannot see whether the user has indeed paid the good amount of money. Am I doing something wrong? I see alot of people have problems with it and none of them had the answer.

My form:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" >
                        <input type="hidden" name="business" value="[email protected]">
                        <input type="hidden" name="cmd" value="_xclick">
                        <input type="hidden" name="upload" value="1" />
                        <input type="hidden" name="item_name" value="<?php echo $_amount_credits ?> credits">
                        <input type="hidden" name="item_number" value="<?php echo $_invoice_id ?>">
                        <input type="hidden" name="amount" value="<?php echo $_total_amount ?>">
                        <input type="hidden" name="lc" value="NL">
                        <input type="hidden" name="rm" value="2">
                        <input type="hidden" name="cbt" value="Go back to http://domain.com">
                        <input type="hidden" name="no_note" value="1" />
                        <input type="hidden" name="currency_code" value="EUR">
                        <input type="hidden" name="return" value="http://domain.com/index.php?payment=success&transaction_id=<?php echo $_GET['tx'] ?>"/>

                        <input type="hidden" name="cancel_return" value="http://domain.com/index.php?payment=canceled&transaction_id=<?php echo $_GET['tx'] ?>"/>
                        <input type="submit" class="button blue _quick_order_overview _payment_paypal" name="submit" value="Pay via PayPal">
                    </form>

Upvotes: 0

Views: 773

Answers (1)

Drew Angell
Drew Angell

Reputation: 26036

You should use Instant Payment Notification (IPN) for this sort of thing. There are lots of good templates for this available on GitHub/Packagist, etc.

IPN will POST transaction data to a listener script you have setup on your server any time a transaction happens on your PayPal account. This would be for payments, refunds, disputes, cleared e-checks, etc. You can automate all sorts of tasks based on the different txn_type's that IPN sends you.

Upvotes: 1

Related Questions