PayPal Adaptive Payments Module | No programming required!
Website Templates by TemplateMonster.com!

Code Samples


Before diving into the code samples below, please be aware of a few key points. First, the button generator produces an HTML snippet for you that includes the URL (link) and image button code. The image button stuff isn't that important and is only for your convenience, so that you have a button to click on your HTML/browser page. The URL is the important part. For you to invoke the EZChain functionality on your web page, you'll need that URL, but you can use any button image you want. Or simply use the link with no button. Or even programmatically redirect your customers to the EZChain URL as part of your custom process. Any of the above will work, as long as your customers' browser ends up going to the EZChain URL. Example EZChain HTML code snippet:

<a href='https://www.chainedpayments.com/EZChain/go.php?ButtonID=390G30644579111245155P97U' target='_blank'>
<img src='https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif' title='Buy Now' border='0'>
</a>

Important: To try a purchase all the way through to completion (by clicking the "Try it" link) you must have a PayPal sandbox account.

Example #1 - Two recipients, no dynamic settings, % split with remainder        View Settings  |  Try it

https://www.chainedpayments.com/EZChain/go.php?ButtonID=390G30644579111245155P97U

Notice there is only one parameter on the URL: ButtonID=390G30644579111245155P97U. That ButtonID is auto-generated by the EZChain button generator and is the key to all your settings, safely stored inside the EZChain database. When ButtonID is the only parameter, it means you have no dynamic settings at all. This is the simplest and most secure way to go, but is only practical for very simple scenarios, such as when you're selling one product whose price seldom changes, the recipients seldom change, and the split amounts seldom change. It is important to know that you can create an unlimited number of these links/buttons, and you can have different settings for each one. For example, say you have 10 different products to sell on your website, and for each product you want to charge a different price and have different recipients and amount splits for each. You could simply create 10 different buttons to avoid having to dynamically construct the URL. Dynamic construction of the URL is a powerful feature, however, and will be demonstrated in some examples below. Also note that you can change any settings of any button as often as you wish. When you change a setting and click "Save & Generate Button", the new settings take effect immediately. When you click the View Settings link for this example you will see that there are two recipients: a Primary and one Secondary. The Primary is configred to receive 20% of the funds from the $10.50 item which would amount to $2.10 minus the PayPal fee and EZChain fee. The Secondary is configured to receive the "Remainder" -- whatever is left over. Alternatively we could have set the Secondary to receive 80% which, in this example, would have produced identical results. Only one recipient can receive the Remainder.

Example #2 - Three recipients, no dynamic settings, % split + dollar split with remainder        View Settings  |  Try it

https://www.chainedpayments.com/EZChain/go.php?ButtonID=3K2129169T44436QY79M1Z1I0

Again we have only one paramter on the URL: ButtonID=3K2129169T44436QY79M1Z1I0. But this time we have 3 recipients instead of 2: the Primary and 2 secondaries. The Primary gets the remainder, the first Secondary gets 25.5% and the second Secondary gets $2.50. Notice that you can mix dollar amounts and percents among your recipients. Only one recipient can get the remainder, though.

Example #3 - Three recipients, one static and two dynamic        View Settings  |  Try it

https://www.chainedpayments.com/EZChain/go.php?ButtonID=2X2675D3374C019MW7920X17U&Email2=sellr3_1317771158_biz%40zerogravityprogramming.com&Email3=sellr4_1317771409_biz%40zerogravityprogramming.com

Notice the dynamic parameters on the URL: &Email2=sellr3_1317771158_biz%40zerogravityprogramming.com&Email3=sellr4_1317771409_biz%40zerogravityprogramming.com. The "%40" in the middle of each email address is merely url-encoding, because the "@" sign is illegal in URLs. The first paramter in a URL (in this case ButtonID=2X2675D3374C019MW7920X17U) must always begin with the "?" sign. All subsequent parameters must always begin with the "&" sign. This behavior is standard across all browsers and goes back to the beginning of the Internet. Those dynamic email addresses can be programmatically changed (or "swapped out") by your website. This is very useful when you want to reuse an EZChain button for a number of different recipients, and you can't know which recipient to use until your customer takes some specific action on your site. Also notice that all three recipients will receive a fixed amount. You could just as easily use percents and a remainder, or some combination of all three. When you click the View Settings link above, notice the checked "Dynamic" check boxes next to both secondary recipients. For security, those boxes must be checked in order for EZChain to allow you to pass in dynamic parameters. You may also notice many other settings that could be dynamic if you want. Because dynamic values in URLs can be tampered with, it's more secure to use static settings (in other words, stored in the EZChain database rather than passed in on the URL), when you are able to do so. But don't worry too much about using dynamic settings; that is a powerful feature and sometimes you simply can't avoid it. There are ways to reduce and nearly eliminate the risk of url tampering, but that is outside the scope of this article. Nearly all your button settings could by dynamic if you want. This provides maximum flexibility, but almost certainly will require a bit of custom programming on your part to generate the URL at run time.

Example #4 - Dynamic item name and price, custom logo and URLs        View Settings  |  Try it

https://www.chainedpayments.com/EZChain/go.php?ButtonID=97S4BK8C4314M85V17578O811&ItemName=Premium+Cupcakes&ItemPrice=9.99

Notice the dynamic parameters on the URL: &ItemName=Premium+Cupcakes&ItemPrice=9.99. The "+" in the middle of "Premium+Cupcakes" is because spaces in URLs are illegal, so this is URL-encoded. Item Name and Item Price are dynamic and can be changed programmatically or manually at any time. To prove the point, grab the URL shown above, paste it into your browser's address bar, change the item name and/or item price, and hit enter. You'll see those changes reflected. You'll need to log in at the payment window with a sandbox account before you see the new item name. Also notice in the Settings the custom Logo Image URL, Return URL, and Cancel URL. All these can be either specified in your PayPal account settings, or here in EZChain. The Return URL is where the customer is brought after completing the purchase, and the Cancel URL is where the customer is brought if he/she cancels before completing the purchase.

Example #5 - Chained subscription        View Settings  |  Try it

https://www.chainedpayments.com/EZChain/go.php?ButtonID=03HD26I917HRB6CMW18518LC9

Notice the Subscribe Options when you click View Settings. At present time, subscribe options cannot be dynamic, but we could make that option available for a fee, or for free if you have enough volume in your business. Notice the URL is simplistic, with only the ButtonID as a parameter. All the standard settings can be made dynamic, just not the Subscribe Options at this time.