example 2 is now working. This example has all the setup. That example makes a few changes.
I have worked a little bit with PayPal before, but I figured it was time to create a "hello world," from-scratch example.
Below is the really, really simple PayPal example. Here are the steps / instructions and clarification of points that were not obvious:
I started from this example. I modified the HTML code just a bit; those mods are part of this page. Use Control-U in most browsers to see the HTML source code / view source.
To get the client ID, you need to log in with your PayPal developer account which may be your "real" account. It is very likely not a sandbox / "fake" user account. You can log into your "Dashboard" / account from the above example link, or developer home.
It seems the following page is the default once you log in, but, if not it's the "applications" page, or "My apps & credentials." Then you "Create app." It doesn't matter what you call it.
At some point during that process, you get "SANDBOX API CREDENTIALS" / "Sandbox account: [by default] realAddress-'facilitator'@gmail.com." That's not literally what you see. Below that is the "Client ID" which is 80 characters of uppercase letters, lowercase letters, numbers, and hyphens. It is not a secret, so you can see mine in the source code.
If you don't have a valid client ID, your test page will return an HTTP 400 error.
To test the example, you can use Amex sandbox card 378282246310005 as documented here. I have found the Amex card more reliable than the others. Once you have that card number ready, you'll hit the first button that simply says "PayPal." The others may work, but I haven't tried them. Once you hit the button and get the payment screen, don't log in unless you have a sandbox account. Use the "Pay with Debit or Credit Card" option at the bottom.
Now that I've played with sandbox purchases more, I'm not sure the card number is at issue. It seems that the sandbox does some degree of validation just like the real system does. Put next month as the expiration date, not this month; that seems to help. "1234" (without quotes) will work as the CSC number. "Bob Smith" works as a name. "123 somewhere st" works. I *think* the system needs a real city-state-zip, though. "(555) 555-0100" works as phone. bob@example.com works as email. Then you can "Pay Now" at the bottom. Processing time takes a weirdly long time--something like 10 seconds. A correct result is that this test page re-focuses and a popup appears that says, "Transaction completed by Bob."
For testing purposes, it's a lot easier to use a sandbox user to fake pay. Note that you cannot use the same sandbox user as the seller, because that would be the seller selling to himself. Without a sandbox account, you're probably better off using real addresses and such. The sandbox payment system is cranky when used without an account, and I suspect it's because it is weeding out some results as fake. It works well enough for an example, though.
When you created the app, you set it to a particular "Sandbox account" email / login id, such as a "...-facilitor" address. You can change / set the password of that account on the left side under "SANDBOX / Accounts." Then you go to sandbox.paypal.com, log in as that user, and you can see the transaction. I think I saw a 7 minute delay between transaction and seeing it in the account. Note that PayPal charges $0.01 for a $0.01 purchase, so your account will show $0.