Guest User

Untitled

a guest
Jun 19th, 2018
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. var win = Titanium.UI.createWindow({backgroundColor:'white'});
  2.  
  3. Titanium.Paypal = require('ti.paypal');
  4.  
  5. /**
  6. * Environment Constants
  7. * Titanium.Paypal.PAYPAL_ENV_LIVE
  8. * Titanium.Paypal.PAYPAL_ENV_SANDBOX
  9. * Titanium.Paypal.PAYPAL_ENV_NONE
  10. *
  11. * Transaction Type Constants
  12. * Titanium.Paypal.PAYMENT_TYPE_HARD_GOODS
  13. * Titanium.Paypal.PAYMENT_TYPE_DONATION
  14. * Titanium.Paypal.PAYMENT_TYPE_PERSONAL
  15. * Titanium.Paypal.PAYMENT_TYPE_SERVICE
  16. *
  17. * Button Style Constants
  18. * Titanium.Paypal.BUTTON_68x24
  19. * Titanium.Paypal.BUTTON_68x33
  20. * Titanium.Paypal.BUTTON_118x24
  21. * Titanium.Paypal.BUTTON_152x33
  22. * Titanium.Paypal.BUTTON_194x37
  23. * Titanium.Paypal.BUTTON_278x43
  24. * Titanium.Paypal.BUTTON_294x43
  25. */
  26.  
  27. /**
  28. * Create the PayPal button is simple enough and as you pass all the data into the button
  29. */
  30. var ppButton = Titanium.Paypal.createPaypalButton({
  31. // Button Details
  32. // Note - height/width only determine the size of the view that
  33. // the button is embedded in - the actual button size is determined by
  34. // the style.
  35. height:30,
  36. width:100,
  37. bottom:50,
  38. appId: "<<<YOUR APP ID HERE>>>", // The appID issued by Paypal for your application - APP-80W284485P519543T is the default Paypal test ID
  39. buttonStyle: Titanium.Paypal.BUTTON_68x24, // The style & size of the button
  40. paypalEnvironment: Titanium.Paypal.PAYPAL_ENV_SANDBOX, // Sandbox, None or Live
  41. feePaidByReceiver: false, // This will only be applied when the transaction type is Personal
  42. transactionType: Titanium.Paypal.PAYMENT_TYPE_DONATION, // The type of payment
  43. enableShipping: false, // Whether or not to select/send shipping information
  44. // The payment itself
  45. payment:
  46. {
  47. amount: 12.99,
  48. tax: 0.00,
  49. shipping: 0.00,
  50. currency: "USD",
  51. recipient: "<<RECIPIENT>>",
  52. itemDescription: "Donation",
  53. merchantName: "Dev Tools",
  54. senderEmailOrPhone: "<<SENDER>>"
  55. }
  56. });
  57.  
  58. // Events available
  59. ppButton.addEventListener("paymentCanceled", function(e){
  60. Titanium.API.info("Payment Canceled");
  61. });
  62.  
  63. ppButton.addEventListener("paymentSuccess", function(e){
  64. Titanium.API.info("Payment Success. TransactionID: "+e.transactionID);
  65. });
  66.  
  67. ppButton.addEventListener("paymentError", function(e){
  68. Titanium.API.info("Payment Error");
  69. Titanium.API.info("errorCode: "+e.errorCode);
  70. Titanium.API.info("errorMessage: "+e.errorMessage);
  71. });
  72.  
  73. // Add it to the window
  74. win.add(ppButton);
  75. // Open the window
  76. win.open();
Add Comment
Please, Sign In to add comment