Skip to main content
adventurous_image6C1B
New Participant
January 29, 2019
Question

Passing info to PayPal via form button

  • January 29, 2019
  • 2 replies
  • 799 views

I have a pdf form for registration for art classes.  This form has several checkboxes (to select the classes they wish to take).  I have created a paypal button for each of the classes (I need to track the number of people who pay because the classes are limited).  I would like to have a button on my pdf form that is labeled "add to cart" and when that button is pressed the PayPal cart is displayed and there is an items for each checkbox selected on my form.  Is this possible?  If so, any help would be greatly appreciated.

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
January 29, 2019

PayPal provides all the info on how to form urls for product payment.  It's how it's done on a web page. You can do the same thing with a button in PDF. Here's some sample code for a fictional product.  This code goes in the mouseup

// First the Hard-Coded Parameters

// PayPal URI with Pay Now command

var cURI = "https://w;ww.paypal.com/cgi-bin/webscr?cmd=_xclick"

// Vendor reference

cURI += "&business=herschelgomez@xyzzyu.com"

// Currency Code

cURI += "&currency_code=USD"

// Now the Dynamic parameters from PDF form fields

// Product Name

var cProduct = this.getField("item_name").value;

cURI += "&item_name=" + cProduct;

// Amount

var cAmount = this.getField("amount").value;

cURI += "&amount=" + cAmount;

// Launch the PayPal URI

app.launchURL(encodeURI(cURI));

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
adventurous_image6C1B
New Participant
October 20, 2019

This information is very helpful in passing information for one item at a time.  I would like to press one button to pass information for multiple items.  Is that possible?  Any help would be appreciated.  I have tried this code but all that is submitted to paypal is the last item.

var url ="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YF8HL8F4BSVP8";
url += "&hosted_button_id=P5S6PT3X7KAEA";
app.launchURL(url);

try67
Community Expert
October 20, 2019

You need to read the documentation of the PayPal API carefully. Passing the same URL parameter twice is not going to work, you need to find out how to include multiple items in the same parameter. Also, I would rename the "url" variable to something else, as there's already a built-in property with that name and it could conflict with your code.

try67
Community Expert
January 29, 2019

Yes, in theory that's possible, if you know the exact URL for each item. You can simply attach that URL to an "Open a web-page" command that's associated with your button and it will open in the browser when the button is clicked.