Tech Kid
Tech Kid

Reputation: 577

How do i know whether the client paypal transaction is successful or not on my success page

On my order page, I'm using this form:

<input type="hidden" name="item_number" value="<?php echo $refNumber; ?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $paypal_email; ?>" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="<?=$_SESSION["web_site_url"]?>/payment_success.php?OrderID=<?=$refNumber;?>" />
input type="hidden" name="amount" id="amount" value="<?=$product_vals["discount_prize"]?>" />
<input type="hidden" name="item_name" id="item_name" value="<?=$product_vals["name"]?>" />

now I want a sample code for my payment_success page from that i came to know whether paypal authenticate the client payment or the client's payment is success of not.. so that i can proceed to next step of gathering information from client.

I have read the Paypal docs but unable to learn useful from them. help me out to solve this problem.Moreover i also want to get the paypal email of client and transaction id / payment_success variable (that is true/false) so that i will help me to identify the payment is succesful or not..

Thanks in advance.

Upvotes: 0

Views: 168

Answers (2)

Debra
Debra

Reputation: 93

You can use paypal class by Micah Carrick. This is pretty clear class which support notify URL, return URL and success URL. You dont need to use any form or something but just use this class and let this class to do your job. sample code is:

$p = new paypal_class;   
$p->add_field('business', $paypal_email);
$p->add_field('return', $add_fund_url.'/success.php');
$p->add_field('cancel_return', $add_fund_url.'/cancel.php');
$p->add_field('notify_url', $notify_url );
$p->add_field('item_name', $item_name);
$p->add_field('item_number', $item_number);
$p->add_field('custom',$custom_field);
$p->add_field('amount', $amount);
$p->add_field('no_shipping', '1');
$p->submit_paypal_post(); // submit the fields to paypal

Upvotes: 1

Drew Angell
Drew Angell

Reputation: 26056

If you're gather more data after they pay then you should really using Express Checkout APIs instead of PayPal Standard like you're using now. Even with Auto-Return enabled in your PayPal profile the user still may not make it back to your site (for example, they could simply close their browser before the redirect happens.)

With Express Checkout the user will always end up back on your site even before the final call to finalize the payment, so you could actually gather the additional details from the user even before finalizing the payment if you wanted to.

Check out this guide on Implementing the Simplest Express Checkout Integration. That will get you familiar with how Express Checkout should be setup (ie. the API calls you'll be making).

Then, grab this PayPal PHP SDK and use it to make the API calls. It has everything setup for you so that it would be very quick and easy for you to integrate into your checkout.

Upvotes: 1

Related Questions