Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Droidcon DE 2013

650 views

Published on

Talk given at the Droidcon DE 2013 in Berlin about integrating payments into Android applications without making the user entering too much data.

  • Be the first to comment

Droidcon DE 2013

  1. 1. Developer
  2. 2. Painless Payments for DroidsTim Messerschmidt
  3. 3. Painless Payments for DroidsTim Messerschmidt
  4. 4. Log In with PayPal The Artistformerly known as access
  5. 5. Log In with PayPal Authentication
  6. 6. Log In with PayPal Authorization
  7. 7. Log In with PayPal OAuth 2.0 & OpenID Connect
  8. 8. Log In with PayPal Client Server1.  Open Authorization 2.  Provide a login page Endpoint URL 3.  Return the Authorization4.  Check callbacks for Token after a successful Authorization Token login5.  Request a valid Access 6.  Check Authorization Token Token & return the Access Token7.  Retrieve user’s resources if it’s valid
  9. 9. Log In with PayPal NAME Date of Birth Creation Date EMAIL Language Gender Locale Time Zone Phone Number Address Verified
  10. 10. Painless Payments for DroidsTim Messerschmidt
  11. 11. Painless Payments for DroidsTim Messerschmidt
  12. 12. Painless Payments for DroidsTim Messerschmidt
  13. 13. Simple Payment 10 € Sender Receiver
  14. 14. Parallel Payment 20 € 10 € Sender
  15. 15. Chained Payment 20 € 100 € 30 € 10 €1 transaction
  16. 16. Mobile Payments Library Download the SDK
  17. 17. Mobile Payments Library API Credentials At x.com
  18. 18. Mobile Payments Library Sandbox APP ID: APP-80W284485P519543T
  19. 19. Mobile Payments Library Add The .JAR To Your Project
  20. 20. Mobile Payments Library Modify the Manifest
  21. 21. Mobile Payments LibraryAdding the PayPal Activity:<activity android:name="com.paypal.android.MEP.PayPalActivity" android:configChanges="keyboardHidden|orientation" />Best to be used with a translucent Themeandroid:theme="@android:style/Theme.Translucent.NoTitleBar"  
  22. 22. Mobile Payments LibraryDECLARING THE NEEDED PERMISSIONS:Internet<uses-permission android:name="android.permission.INTERNET" /> READ Phone state<uses-permission android:name="android.permission.READ_PHONE_STATE" />Access Wifi State<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  23. 23. Mobile Payments Library Initialize The Library
  24. 24. Mobile Payments Librarynew Thread() { public void run() { instance = PayPal.getInstance(); if (instance == null) { instance = PayPal.initWithAppID( context, ID, // YOUR APPS ID PayPal.ENV_SANDBOX ); } } }.start();  
  25. 25. Mobile Payments Library Create the PAYMENT
  26. 26. Mobile Payments LibrarySimple Payment:PayPalPayment payment = new PayPalPayment(); payment.setRecipient("foo@bar.com"); payment.setCurrencyType("USD"); payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS); payment.setSubtotal(new BigDecimal(”29.99")); PayPalInvoiceItem item = new PayPalInvoiceItem(); item.setName("Hipster T-Shirt"); item.setQuantity(1); item.setTotalPrice(new BigDecimal(”29.99")); PayPalInvoiceData data = new PayPalInvoiceData(); data.add(item); payment.setInvoiceData(data);  
  27. 27. Mobile Payments LibraryParallel Payment:PayPalAdvancedPayment payment = new PayPalAdvancedPayment(); payment.setCurrencyType("USD"); PayPalReceiverDetails firstReceiver = new PayPalReceiverDetails(); firstReceiver.setRecipient("first@bar.com"); firstReceiver.setSubtotal(new BigDecimal("10.00")); PayPalReceiverDetails secondReceiver = new PayPalReceiverDetails(); secondReceiver.setRecipient("second@bar.com"); secondReceiver.setSubtotal(new BigDecimal("20.00")); payment.getReceivers().add(firstReceiver); payment.getReceivers().add(secondReceiver);  
  28. 28. Mobile Payments Library Execute The Payment
  29. 29. Mobile Payments LibraryGET THE INTENT:Intent payIntent = instance.checkout(invoice, context); startActivityForResult(payIntent, REQUEST);  Can be used with a Delegate insteadIntent payIntent = instance.checkout( invoice, context, delegate ); startActivity(payIntent);  
  30. 30. Mobile Payments LibraryReceive the result:protected void onActivityResult( int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST) { switch (resultCode) { case Activity.RESULT_OK: showText("Success"); break; case Activity.RESULT_CANCELED: showText("Canceled"); break; case PayPalActivity.RESULT_FAILURE: showText("Failure"); break; } } }  
  31. 31. Mobile Payments Library Advantage: Intent-based
  32. 32. Mobile Payments LibraryUse IPN to update your stock
  33. 33. Mobile Payments LibraryVerify Payments:payment.setIpnUrl("http://example.com/callback.php");   POST PayPal Server Server PayPal
  34. 34. Mobile Payments Library CODE

×