Reputation: 19
In general, i'am looking for a way to determine "who paid for what" when I get a Paypal payment.
I'm developing a e-commerce website and am trying paypal as the payment method. However, i'm confused about how to associate the response (IPN message from paypal, which i currently intend to rely on solely) with a specific transaction happening on my site.
What i expected was that maybe when customer click on my paypal button to pay, i could tell paypal "hi, this is a transaction with id 1234"; then paypal could tell me "transaction 1234 is completed\canceled". However, i didn't find some "stamp" that i can put on a transaction so that i can know who paid for what. The txn_id variable seem to be close to what i expected, but as i understand now, it's generated by paypal instead of assigned by me.
I also thought about doing some tricks on the redirect_url I send to paypal. May be I could generate a url for each transaction, send that url as a code to paypal; so that when someone requests that url I know the transaction is paid for as only paypal and i know the existence of that url. However, i'm not sure about the security about this method, and think there may be other ways.
Thanks in advance for any idea or direction!
Upvotes: 2
Views: 267
Reputation: 2996
You can use paypal button like this- Just replace appropriate values and update
<input type="hidden" name="custom" value="90">
value dynamically using js. Then you can access custom field in you notify_url
<div class="paypal-button-loader-script-tag">
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" class="paypal-button" target="_top">
<div class="hide" id="errorBox"></div>
<input type="hidden" name="button" value="buynow data-quantity=">
<input type="hidden" name="amount" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Moneyfan">
<input type="hidden" name="notify_url" value="yourwebsite.com">
<input type="hidden" name="custom" value="90">
<input type="hidden" name="return" value="http://yourwebsite.com">
<input type="hidden" name="cancel_return" value="http://yourwebsite.com">
<input type="hidden" name="env" value="www.sandbox">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="example.com">
<input type="hidden" name="bn" value="JavaScriptButton_buynow data-quantity=">
<button type="submit" class="paypal-button large">undefined</button>
</form>
</div>
Upvotes: 1
Reputation: 18671
In my case, that work well with custom
and invoice
they send them back to the notify_url
link.
Upvotes: 1