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

PayPal works but ...

pddesigner
Registered: Jul 9 2006
Posts: 858
Answered

I've created the following JavaScript which works but needs to be corrected to solve a browser time out problem. Note: A PayPal merchant account was established before I used this code.
 
This is the Mouse Up JavaScript for the Submit button
this.mailDoc(true, "myemailaddress [at] msn [dot] com", "", "", "Banner Ad Form");
 
This is the Mouse Down JavaScript for the same Submit button
// Get the item name and cost from a field on the page
var name = this.getField('serialNumber').value;
var cost = this.getField('Cost').value;
 
// Construct the paypal url. Change the email address and currency code as appropriate
var url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=myPayPalEmailAddress [at] msn [dot] com&currency_code=USD"
  
url = url + "&item_name=" + name;
url = url + "&amount=" + cost;
  
app.launchURL(url, true);
 
The serial number is a text number field that is Read Only and set to auto increment each time the form is opened.
This is the auto increment code:
// Get and increment Form ID
this.getField("serialNumber").value++;
 
The Cost field is a drop down field that populates the Cost field with default values.
 
I'd like suggestions for solving the time out problem and a method of including the words Invoice Number on the same line as the serialNumber.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

My Product Information:
Acrobat Pro 8.1.7, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
I would not use the Mouse Down event for anything and instead combine both scripts into a single script, but issue the app.launchURL before the mailDoc. If that doesn't work, can you explain the timeout problem in more detail?

I don't understand your last question. Can you explain the problem in more detail as well?
pddesigner
Registered: Jul 9 2006
Posts: 858
When the serial number is placed on the PayPay payment page I want to see the words "Invoice Number" in front of the this.getField("serialNumber").value++;
Sincerely appreciate your prompt reply and suggestion.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
You can't do both. You need to decide whether this is a text field or a number field.
If it's a text field, then you can't use the "++" operator. If it's a number field, then you can't add text to it.

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

QwertyKid
Registered: Nov 28 2010
Posts: 14
pdd, I appreciate you have accepted an answer on this but is everything being submitted to PayPal correctly?

I have used your code and am getting a PayPal reply stating “The link you have used to enter the PayPal system contains an incorrectly formatted item amount.”


Did you get that at any point in your attempts to set things up?

...just when you think you have it idiot proof ...along comes a bigger idiot

#:O)

pddesigner
Registered: Jul 9 2006
Posts: 858
The original code still works fine. My guest is your form fields are not properly formatted as number fields. I did not use the mouse up and down together as was advised.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

QwertyKid
Registered: Nov 28 2010
Posts: 14
On using the Console I note that the amount inserted and sent to PayPal is the actual calculated amount, running into several decimal places. PayPal is expecting to see a figure with just 2 decimal places.

There is no mention of it anywhere in your script, did you set ‘rounding’ at document level using...

function Round(fValue, fRound){// round fValue to fRound decimal placesreturn  Math.round(fValue * Math.pow(10, fRound) ) / Math.pow(10, fRound);}// end round function
or another means?

...does the above code round to 2 decimal places?


Did you do anything with the authorisation code that is returned by PayPal acknowledging payment has been received?

It would have been nice to have that code entered directly onto the form before its submitted therefore it would contain the receipt of payment number.

...just when you think you have it idiot proof ...along comes a bigger idiot

#:O)

pddesigner
Registered: Jul 9 2006
Posts: 858
I'll post the entire code in sequence tomorrow for your review.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

pddesigner
Registered: Jul 9 2006
Posts: 858
This forum will not allow me to provide a link to a working copy that you can review amd modify. Contact me via my members profile and I'll send you the link.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

QwertyKid
Registered: Nov 28 2010
Posts: 14
Gene,
bizarrely there is no means of contact showing on your profile, ...........



...just when you think you have it idiot proof ...along comes a bigger idiot

#:O)

pddesigner
Registered: Jul 9 2006
Posts: 858
Your email adddress is missing a dot and will not work.

Link to the example:
http://www.mylaughlinwebsite.com/external/INVOICE-test.pdf

The linked pdf file was found at http://forum.planetpdf.com/
Registration is required.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

QwertyKid
Registered: Nov 28 2010
Posts: 14
Thanks Gene,

Unfortunately the form is all but useless and doesn't disclose anything I don’t already know. Even with a bit of tweaking to get it to do anything meaningful it still inserts several decimal places in to the PayPal sent info.

I'll check out the forum mentioned for an answer to this.

...just when you think you have it idiot proof ...along comes a bigger idiot

#:O)

QwertyKid
Registered: Nov 28 2010
Posts: 14
Found this useful script for testing things out..

// Get the item name and cost from a field on the pagevar name = this.getField('InvoiceNumber').value;var cost = this.getField('Cost').value; // display the constructed string as it is builtconsole.show(); // open JavaScirpt consoleconsole.clear(); // clear the console // Construct the paypal url. Change the email address and currency code as appropriatevar url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=<span class="spamspan"><span class="u">me</span> [at] <span class="d">mybusiness [dot] com</span></span>&c urrency_code=USD" // show the urlconsole.println('url = ' + url);console.println('name = ' + name);console.println('cost = ' + cost);// Append the item and amount parts of the urlurl = url + "&item_name=" + name;// show updated urlconsole.println('url + name: ' + url);url = url + "&amount=" + cost;// show updated urlconsole.println('url + cost: ' + url); // comment out until string is tested/*// Launch the web page. true means "open in a new browser window"app.launchURL(url, true);

*/

...just when you think you have it idiot proof ...along comes a bigger idiot

#:O)

QwertyKid
Registered: Nov 28 2010
Posts: 14
.... and the solution to rounding the calculated total to 2 decimal places, posted by GKaiseril on the forums.adobe.com is:


"...let's keep this to the "Format" tab set to "Number" and the "Decimal places" to 2. But the data entered or computed for that field can have more data than the 2 decimal places. You can either use the "Validate" or "Calculation" tabs to add a script to perform the conversion, but do not use both. You can use the following script for either the Run custom validation script or the Custom calculation script"

event.value = 1 * util.printf("%,1 .2f", event.value);



...just when you think you have it idiot proof ...along comes a bigger idiot

#:O)