I have a form with a PayPal button on my website in which the buyer inputs the data I need to process her/his wishes. I would like to save this data into my database, but only after the user has made a transaction.
In essence, I need to forward this custom data to PayPal, and the PayPal should send it back to me, once the user completes the transaction or discard it if the user didn't complete the transaction.
Is it possible to send custom data to PayPal and get that same data to the listenerPage.php
on my server? The listenerPage.php would store the data into the database. I am new to PayPal and this is just how I imagine the process should look. I am open to other solutions as well.
<input class="import-input-i-need-to-get-from-paypal" type="text" placeholder="Data">
<a id="a-submit" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=someID">Pay with PayPal</a>
Additonal question in the case of using a
elements as buttons.
Should href attribute be: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&custom=customdata&hosted_button_id=someID" ? Is this acceptable?
Yes, you can and it's pretty straightforward. In the form of your paypal button add an hidden field with 'name' attribute "custom" and the custom data as the value. It will return back as "custom"
<input type="hidden" name="custom" value="custom data here" />