E-mail Support for PayPal

home page
std.css

PayPal sends out e-mails when something is purchased, but only as a result of the data it receives. There are limits on the amount of data PayPal can absorb. These limits are reflected in the following...

    item_name   = 127 characters
    item_number = 200
    on0         = 64
    os0         = 200
    on1         = 64
    os1         = 200

One way out of this is to send an auxillary email along with the PayPal payment. We want to do this with a single button - click on a single thing and the e-mail is sent out, and the customer is vectored into PayPal for payment. But there are big problems with certain methods of sending E-mail, and most of the problems are a result of your ISP. Bottom line, if you want to support the most users (AOL users, for example), then you must use "formatted email" packages - the standard action="mailto:... just doesn't work in the general case.

There are certain ISPs that intercept this feature, and redirect you into their E-mail program (like AOL, for example). This means you simply cannot send E-mail from an AOL user to your site unless it is through a "formatted email" program such as MIT E-mail example. I'm sorry., but there are few exceptions.

Following is an example of using E-mail from a FORM, as documented in manuals, but that is not supported by all ISP's (AOL is just one). Try it, and see what happens. If you either get an error, or your mail system pops up wanting subject, etc., then you cannot do this sort of thing from your ISP. Right click on this page (and to see the HTML for this E-mail submission).

The bottom line is that you simply must have an ISP formatting E-mail support program to be able to send an auxillary E-mail along with your customer's PayPal purchase - IFF you want to support most customers on the web! And here is how you do that...

Let's assume that you have a CGI mail program on your server, and that you access it with a FORM statement like this...

    <form name="Email" action="http://your.url/mail-cgi/MailForm"
      method="post" />
      ...
      <input type="text" name="item" size="10" />
      ...
    </form>

Within that FORM you enter all the information you need for the purchase. The problem now becomes how to send you the E-mail of that data, and link the PayPal payment to that E-mail so you can credit the customer with the purchase. This is a rather standard problem, and here is how you do it.

You must also have a PayPal form on your page...

    <form target="paypal" name="PPForm" action=...
      ...
      <input type="text" name="item_name" size="10" />
      ...
    </form>

The problem is now, how to get email information from the Email form into the the PPForm, and then submit them both at the same time. This is trivial in JavaScript (JS).

Each FORM is addressable through its name, and each FORM has a submit method (a subroutine, or procedure). When the user hits the "submit" button we must move data from the Email FORM down into the PPForm, and then submit both FORMs. And here is how you do that...

Somewhere on the page (inside either FORM, or outside both of them - it makes no difference) we have this HTML statement...

    <img src="submit.gif" alt="submit button" 
      onclick="MoveDat(); return false;" />

What this does is to call a JS function named MoveDat whenever the customer clicks on that image. Within that function we can move data around, and "submit" FORMs as we wish. Here is an example of what MoveDat might look like... (located inside the head area.)

  function MoveDat () {  // move data and submit both forms
  var e = document.forms.Email;  // address of email form
  var p = document.forms.PPForm; //  and the PayPal form
    p.item_name.value = e.item.value;  // move data
    e.submit();  // and submit both FORMs
    p.submit();
  }

What this demonstrates is how to submit an E-mail form and a PayPal form at the same time. What you might want to do is to tie them together with a special code (such as the customer's E-mail address) so you can put together the E-mail you get with the PayPal E-mail you get confirming payment.

But, watch out! Every email you get may not have a corresponding PayPal payment confirmation because the user may back out of the PayPal payment process and there is no way for us to know that. This is something you must deal with on your own.

That is the "idea", now we talk about the reality...


Special Considerations

Sometimes you need to go to two different servers with a single click of a button (an email FORM, and a PayPal FORM). While you may "submit" multiple FORMS with JavaScript, if both FORMs can send data to the user (even an error message) you MUST route the server responses to two different windows. Certain browser settings (or ISPs [AOL for one]) do not do this, so you must intervene and force the situation.

To do this properly you must pre-open a window for each server that might provide output to the user's machine, and link the FORMs within your HTML to those pre-opened windows (the "target" value in the FORM statement). Following is a demonstraton of one way to do this...

Example

Open two windows, and monitor them. The first window is the PayPal view-cart window, and the second (top) window is designed to receive your email confirmation message. In normal operation you would delete the top window (for email) after getting the confirmation, and then process the PayPal window.

What I'm going to demonstrate here is opening two windows, routing data to both windows at the same time (the error message for AOL email is just to transmit data), and automatically closing the email window after 20 seconds, and then the PayPal window after 30 saeconds. This shows how the original window can control them, and still be in execution underneath both of them. Notice that the edges of both windows are visible on your screen as they load.

Now check the status of the windows. We opened them, and then closed them. They should both be closed now. (if you let the time-outs work). Or, you can manually close the two wndows and then check their status before the timeouts. By monitoring window status like this, you could tell what the user was doing, and perhaps throw up an alert if he did something wrong.

The other important control is the focus control that can change which window is on top. "win1.focus();" executed before timeout would bring the PayPal window to the top.

Installation

How sites might use this is so varied that I am going to let the source of this example speak toward installation. You need to pre-open windows with JavaScript window.open(), and link FORMs to those windows with the quot;targetquot; paramater. What you do with the windows after they are filled with data is up to you.

In the most simple case you might just open the windows and then submit the FORMs waiting for the user to decide what to do with them. In this case it becomes really simple.


Image: XHTML 1.1 certified! Image: CSS2 certified! Image: Multi-user accessibility!

Contact me concerning this article at paypalhelper@aol.com. Mention "email" in your note.

Individual help starting at $25.00 for simple JS solutions.