How do I pass an Invoice number to PayPal and receive some form of confirmation back

mrLeo
New Community Member

Help please. I created a Buy Now button for my website. However, (1) I need to know how to send an Invoice number in the "invoice" variable to PayPal. (2) I also need to know how to receive some form of confirmation back from PayPal when the transaction is processed. For example, when my customer clicks my "Buy Now" button on my webpage, they get redirected to PayPal. I need to include "an invoice number (ie..13-10050) " so that I can track the purchase. After PayPal processes the transaction, the customer is re-directed to a "confirmation.aspx" page located on my website. I need to grab something back from PayPal so that I know the transaction was processed.

 

Questions:

1. How do I pass an invoice number in the invoice variable on the Buy Now button?

2. How do I collect a response from PayPal when the customer is redirected to my "confirmation.aspx" webpage?

Login to Me Too
1 REPLY 1

snowshoe
Frequent Advisor
Frequent Advisor

Couple of things to consider when using the "invoice" variable.

 

If you plan to dynamically change the invoice number, (which is recommended), your item button code needs to be manually generated as the online button creator has it's limitations.  In addition using the "hosted" version of the code, you won't be able to change the invoice number dynamically.

 

Normally the value of this variable will not appear in the email notification or the PayPal Screens however, it will appear your Account Profile Transaction History details.   This behavior is fine for most but, some folks would like to be able to see this value in their email email notifications and in the Option Column of the PayPal Screens.   So we created a small script that does just that.

 

If you don't dynamically change the invoice number after each puchase you can run into a small issue.  Because the system recognizes that the invoice has already been paid, should a second customer try to purchase the same item, he or she will get the following message: "This invoice has already been paid.  For more information, please contact the merchant".   You can also turn this feature off in your PayPal account, select Profile, under My Selling Tools, Block Payments, select Update, look for Payment Receiving Preferences.

 

Below is an example of how to manually code your item button to pass this variable.  As for dyanamically changing the value, that's up to you.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title>Button Example Code</title>

<!-- START META TAG SECTION -->
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="Content-Language" content="en">
<!-- END META TAG SECTION -->


<!-- Start of Script -->  
<script type="text/javascript">
<!--
function UpdateForm (obj1) { 
 obj1.os1.value = obj1.myopt1.value;
 obj1.invoice.value = obj1.myopt1.value;
}
//-->
</script>
<!-- End of Script --> 


</head>

<body>

<!-- START SAMPLE CODE SECTION -->


<!-- PARAGRAPH 1 -->
Pay Your Bill Online Examples

<br><br>

Demonstrates the Use of the &quot;invoice&quot; Variable.

<br><br>

Notes:

<br><br>

Normally the value of this variable will not appear in the email notification or the PayPal Screens however, it will appear your Account Profile Transaction History details.&nbsp;&nbsp; This behavior is fine for most but, some folks would like to be able to see this value in their email email notifications and in the Option Column of the PayPal Screens.&nbsp;&nbsp; So we created a small script that does just that.
<br><br>
Because the system recognizes that the invoice has already been paid, should a second customer try to purchase the same item, he or she will get the following message: &quot;This invoice has already been paid.&nbsp; For more information, please contact the merchant&quot;.&nbsp;&nbsp;  You can also turn this feature off in your PayPal account, select Profile, under My Selling Tools, Block Payments, select Update, look for Payment Receiving Preferences.

<br><br>
<hr align="left" width="50%" noshade>
<br><br>

<!-- START CONTENTS -->

<!-- START BUTTON EXAMPLES -->


<!-- Start of Form -->  
<form method="post" name="buynowform" id="buynowform" action="https://www.paypal.com/cgi-bin/webscr" onsubmit="this.target='paypal'; return UpdateForm(this);">
<!-- If using a Business or Company Logo Graphic, include the "cpp_header_image" variable. -->
<input type="hidden" name="cpp_header_image" value="https://www.yourwebsite.com/logo.jpg">
<input type="hidden" name="on0" value="Customer Number">Please Enter Your Customer Number:&nbsp;&nbsp;
(Example:&nbsp;&nbsp; 99999999)
<br><br>
<input type="text" name="os0">
<br><br>
Please Enter Your Invoice Number:&nbsp;&nbsp;(Example:&nbsp;&nbsp; 99999999)
<br><br>
<input type="text" name="myopt1">
<br><br>
Enter Amount Due :&nbsp;&nbsp;
(Example:&nbsp;&nbsp; 999.99)
<br>
<input type="text" name="amount">
<br><br>
<input type="reset" name="reset" value="Clear Selections">
<br><br>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="cmd" value="_xclick">
<!-- Replace "business" value with your PayPal Email Address or your Merchant Account ID -->
<input type="hidden" name="business" value="your email address">
<input type="hidden" name="item_name" value="Online Payment">
<input type="hidden" name="item_number" value="OLP-00001">
<input type="hidden" name="on1" value="Invoice Number">
<input type="hidden" name="os1">
<input type="hidden" name="invoice">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="tax" value="0.00">
<!-- Replace value with the web page you want the customer to return to after a successful transaction -->
<input type="hidden" name="return" value="http://www.yourwebsite.com/ThankYou.html">
<!-- Replace value with the web page you want the customer to return to after item cancellation -->
<input type="hidden" name="cancel_return" value="http://www.yourwebsite.com/Cancel.html">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="country" value="US">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynowCC_LG.gif:NonHosted">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
</form>
<!-- End of Form -->  


<!-- END BUTTON EXAMPLES -->



<!-- END SAMPLE CODE SECTION -->

<br><br><br><br>
<hr align="left" width="50%" noshade>
<br><br>
NOTES:
<br>
In order to test the code, you must replace the &quot;business&quot; value variable with your PayPal Email Address or your Merchant Account ID.

</body>
</html>

 

 

As for question 2.  Suggest looking into PayPal's IPN or Instant Payment Notification feature.

 

The following links should help get you started:

 

https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/

 

https://developer.paypal.com/webapps/developer/docs/classic/products/instant-payment-notification/

 

http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html

 

https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/ipnguide.pdf


 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.