Tuesday, November 2, 2010

Putting a PayPal Donation Button In Flash

This was a real mysterious one but I think I figured it out.

Here is the code for donating a fixed amount. This option adds an item at the dollar amount you set to the PayPal cart:

var variables:URLVariables = new URLVariables();
variables.cmd = "_cart";
variables.add = "1";
variables.amount = String(  TOTAL DOLLAR AMOUNT HERE  );
variables.business = "  YOUR PAYPAL EMAIL HERE  ";
variables.item_name = "Item 1";
variables.item_number = "123456789";
variables.tax = "0";
variables.currency_code = "USD";
variables.page_style = "PayPal";
variables.no_shipping = "0";
variables.undefined_quantity = "1";
variables.rn = "1";
variables.shipping = "0";
variables.shopping_url = "http://www.salvationarmyusa.org";
var request:URLRequest = new URLRequest("https://www.paypal.com/cgi-bin/webscr");
request.method = URLRequestMethod.POST;
request.data = variables;
navigateToURL(request, "_self");

Here is the code for donating an amount decided by user:

var variables:URLVariables = new URLVariables();
variables.cmd = "_donations";
variables.add = "1";
variables.business = "YOUR PAYPAL EMAIL GOES HERE";
variables.item_name = "Donation to Salvation Army";
variables.item_number = "123456789";
variables.tax = "0";
variables.currency_code = "USD";
variables.page_style = "PayPal";
variables.no_shipping = "0";
variables.undefined_quantity = "1";
variables.rn = "1";
variables.shipping = "0";
variables.shopping_url = "http://www.salvationarmyusa.org";
var request:URLRequest = new URLRequest("https://www.paypal.com/cgi-bin/webscr");
request.method = URLRequestMethod.POST;
request.data = variables;
navigateToURL(request, "_self");

And here is PayPal's description of the variables.

No comments: