droidcon de 2013

Post on 28-Nov-2014

621 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

Developer

Painless Payments for Droids Tim Messerschmidt

Painless Payments for Droids Tim Messerschmidt

Log In with PayPal

The Artist formerly known

as access

Log In with PayPal

Authentication

Log In with PayPal

Authorization

Log In with PayPal

OAuth 2.0 & OpenID Connect

Log In with PayPal

Client

1.  Open Authorization Endpoint URL

4.  Check callbacks for Authorization Token

5.  Request a valid Access Token

7.  Retrieve user’s resources

Server

2.  Provide a login page 3.  Return the Authorization

Token after a successful login

6.  Check Authorization Token & return the Access Token if it’s valid

Log In with PayPal

NAME EMAIL

Date of Birth

Locale

Time Zone

Address

Gender

Language

Phone Number

Verified

Creation Date

Painless Payments for Droids Tim Messerschmidt

Painless Payments for Droids Tim Messerschmidt

Painless Payments for Droids Tim Messerschmidt

Simple Payment

Sender Receiver

10 €

Parallel Payment

Sender 10 €

20 €

Chained Payment

10 €

20 €

30 € 100 €

1 transaction

Mobile Payments Library

Download the SDK

Mobile Payments Library

API Credentials At x.com

Mobile Payments Library

Sandbox APP ID: APP-80W284485P519543T

Mobile Payments Library

Add The .JAR To Your Project

Mobile Payments Library

Modify the Manifest

Mobile Payments Library

<activity android:name="com.paypal.android.MEP.PayPalActivity"android:configChanges="keyboardHidden|orientation" />

Adding the PayPal Activity:

Best to be used with a translucent Theme android:theme="@android:style/Theme.Translucent.NoTitleBar"  

Mobile Payments Library

<uses-permission android:name="android.permission.INTERNET" />

DECLARING THE NEEDED PERMISSIONS:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

READ Phone state

Internet

Access Wifi State <uses-permission

android:name="android.permission.ACCESS_WIFI_STATE" />

Mobile Payments Library

Initialize The Library

Mobile Payments Library

new Thread() {public void run() { instance = PayPal.getInstance(); if (instance == null) { instance = PayPal.initWithAppID( context, ID, // YOUR APP'S ID PayPal.ENV_SANDBOX ); }}

}.start();  

Mobile Payments Library

Create the PAYMENT

Mobile Payments Library

Simple 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);  

Mobile Payments Library

Parallel 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);  

Mobile Payments Library

Execute The Payment

Mobile Payments Library

Intent payIntent =instance.checkout(invoice, context);

startActivityForResult(payIntent, REQUEST);  

GET THE INTENT:

Can be used with a Delegate instead Intent payIntent =instance.checkout( invoice, context, delegate);

startActivity(payIntent);  

Mobile Payments Library

Receive 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; } }}  

Mobile Payments Library

Advantage: Intent-based

Mobile Payments Library

Use IPN to update your stock

Mobile Payments Library

Verify Payments: payment.setIpnUrl("http://example.com/callback.php");  

PayPal POST

Server

Server PayPal

Mobile Payments Library

CODE

top related