Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var win = Titanium.UI.createWindow({backgroundColor:'white'});
- Titanium.Paypal = require('ti.paypal');
- /**
- * Environment Constants
- * Titanium.Paypal.PAYPAL_ENV_LIVE
- * Titanium.Paypal.PAYPAL_ENV_SANDBOX
- * Titanium.Paypal.PAYPAL_ENV_NONE
- *
- * Transaction Type Constants
- * Titanium.Paypal.PAYMENT_TYPE_HARD_GOODS
- * Titanium.Paypal.PAYMENT_TYPE_DONATION
- * Titanium.Paypal.PAYMENT_TYPE_PERSONAL
- * Titanium.Paypal.PAYMENT_TYPE_SERVICE
- *
- * Button Style Constants
- * Titanium.Paypal.BUTTON_68x24
- * Titanium.Paypal.BUTTON_68x33
- * Titanium.Paypal.BUTTON_118x24
- * Titanium.Paypal.BUTTON_152x33
- * Titanium.Paypal.BUTTON_194x37
- * Titanium.Paypal.BUTTON_278x43
- * Titanium.Paypal.BUTTON_294x43
- */
- /**
- * Create the PayPal button is simple enough and as you pass all the data into the button
- */
- var ppButton = Titanium.Paypal.createPaypalButton({
- // Button Details
- // Note - height/width only determine the size of the view that
- // the button is embedded in - the actual button size is determined by
- // the style.
- height:30,
- width:100,
- bottom:50,
- appId: "<<<YOUR APP ID HERE>>>", // The appID issued by Paypal for your application - APP-80W284485P519543T is the default Paypal test ID
- buttonStyle: Titanium.Paypal.BUTTON_68x24, // The style & size of the button
- paypalEnvironment: Titanium.Paypal.PAYPAL_ENV_SANDBOX, // Sandbox, None or Live
- feePaidByReceiver: false, // This will only be applied when the transaction type is Personal
- transactionType: Titanium.Paypal.PAYMENT_TYPE_DONATION, // The type of payment
- enableShipping: false, // Whether or not to select/send shipping information
- // The payment itself
- payment:
- {
- amount: 12.99,
- tax: 0.00,
- shipping: 0.00,
- currency: "USD",
- recipient: "<<RECIPIENT>>",
- itemDescription: "Donation",
- merchantName: "Dev Tools",
- senderEmailOrPhone: "<<SENDER>>"
- }
- });
- // Events available
- ppButton.addEventListener("paymentCanceled", function(e){
- Titanium.API.info("Payment Canceled");
- });
- ppButton.addEventListener("paymentSuccess", function(e){
- Titanium.API.info("Payment Success. TransactionID: "+e.transactionID);
- });
- ppButton.addEventListener("paymentError", function(e){
- Titanium.API.info("Payment Error");
- Titanium.API.info("errorCode: "+e.errorCode);
- Titanium.API.info("errorMessage: "+e.errorMessage);
- });
- // Add it to the window
- win.add(ppButton);
- // Open the window
- win.open();
Add Comment
Please, Sign In to add comment