These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

I need help creating a dynamic PayPal button

PDFchild
Registered: Oct 31 2010
Posts: 44
Answered

I have created a form for my website. I have a read only text field "total2" that calculates (in $) depending upon options entered earlier in the form. I want to make a PayPal button that allows people to submit a payment for the calculated amount in "total2". I am familiar with JavaScript but couldn't work that out. Please help.
 

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

My Product Information:
Acrobat Pro 9.0, Windows
PDFchild
Registered: Oct 31 2010
Posts: 44
P.S. The form is in Acrobat (not LiveCycle)

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Can you specify the price in a URL parameter?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

PDFchild
Registered: Oct 31 2010
Posts: 44
You mean the part of the URL which contains the price right?

e.g.

(www.paypal.................amount=100.................)

lets say this is a PayNow link to 100USD

I know that I have to create a Script so that the button I place imports the value from "total2" and replace the price part (here 100) with the imported value. That much know, but I have no Idea how to create the script as i am not from a programming background.


Please help

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
I don't think that's how PayPal works, but anyway here's how to do it.
Let's say the price you want to use is in a field called "price".
On the button's MouseUp event create an Execute JavaScript action and enter this code:

price = this.getField("price").value;
urlToOpen = "http://www.paypal.com?amount=" + price;
app.launchURL(urlToOpen);

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

PDFchild
Registered: Oct 31 2010
Posts: 44
try67 wrote:
I don't think that's how PayPal works, but anyway here's how to do it.
Let's say the price you want to use is in a field called "price".
On the button's MouseUp event create an Execute JavaScript action and enter this code:

price = this.getField("price").value;
urlToOpen = "http://www.paypal.com?amount=" + price;
app.launchURL(urlToOpen);
Thanks for the reply!!

That almost worked for me

actually the PayPal code I use is from a Pay Now button, its a long one. Anyway i managed to make it work.

urlToOpen = "http://www.paypal.com.......amount=" + price + "..........";

But there is a problem, whenever there is a number in decimals e.g. $150.50, 150.25...the link doesn't seem to work, instead takes me to a PayPal page which says the url is in wrong format or something

:'(


PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Can't help you there. You need to check the help section of PayPal to see how to handle cents in the URL string.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Elainede
Registered: Jun 3 2011
Posts: 1
I've read this thread several times and I'm still confused. I want to do the same thing, but I am less than new to javascript......I haven't a clue. The acrobat form is done. All I want to do now is add a Paypal Express Checkout button (or other button that will get me to the same place)with a total amount due pulled from a field in the form. Looking at code offered here:

price = this.getField("price").value;
urlToOpen = "http://www.paypal.com?amount=" + price;
app.launchURL(urlToOpen);

I'm not sure if this is what needs to be written literally or if there are some variables in there. (i.e. I think "price" represents the name of the field that the amount to send is coming from.

But, is there supposed to be a ? after www.paypal.com or does that repesnt some other variable? (From the reply above I think it may be the code PayPal gives you for the buttonm, but I'm not sure.

In the last line, what is (urlToOpen) supposed to represent?

Sorry for being so dense but I just think I need it spelled out a little more for me.

Elainede

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Thom Parker has an article about this at the paid membership site pdfscripting.com.

George Kaiser

PDFchild
Registered: Oct 31 2010
Posts: 44
Elainede wrote:
I've read this thread several times and I'm still confused. I want to do the same thing, but I am less than new to javascript......I haven't a clue. The acrobat form is done. All I want to do now is add a Paypal Express Checkout button (or other button that will get me to the same place)with a total amount due pulled from a field in the form. Looking at code offered here:price = this.getField("price").value;
urlToOpen = "http://www.paypal.com?amount=" + price;
app.launchURL(urlToOpen);

I'm not sure if this is what needs to be written literally or if there are some variables in there. (i.e. I think "price" represents the name of the field that the amount to send is coming from.

But, is there supposed to be a ? after www.paypal.com or does that repesnt some other variable? (From the reply above I think it may be the code PayPal gives you for the buttonm, but I'm not sure.

In the last line, what is (urlToOpen) supposed to represent?

Sorry for being so dense but I just think I need it spelled out a little more for me.
urlToOpen = "http://www.paypal.com?amount=" + price;

thats not complete, you have not used rest of the paypal code. You have to generate it from the payee's paypal account by setting up a pay now button. At least that has worked for me.

PDFchild [at] gmail [dot] com - Go Green Save Paper Adopt a PDF