Mobile Payments Library Developer Guide and Reference – Blackberry OS Edition Last updated: August 2011 Mobile Payments Library Developer Guide & Reference – Blackberry OS Edition 1
© 2011 PayPal, Inc. All rights reserved. PayPal is a registered trademark of PayPal, Inc. The PayPal logo is a trademark of PayPal, Inc. Other trademarks and brands are the property of their respective owners. The information in this document belongs to PayPal, Inc. It may not be used, reproduced or disclosed without the written approval of PayPal, Inc. Copyright © PayPal. All rights reserved. PayPal S.à r.l. et Cie, S.C.A., Société en Commandite par Actions.
Table of Contents Preface .............................................................................................................................................................. 5 Purpose ......................................................................................................................................................... 5 Scope............................................................................................................................................................
About Preapproval Keys .......................................................................................................................... 18 About Preapproval Pins........................................................................................................................... 19 Sample Call .............................................................................................................................................. 19 Custom Objects in the Mobile Payments Library ..........
Preface The PayPal Mobile Payments Library provides secure, extensible, and scalable PayPal payment functionality to the Blackberry platform. Purpose The PayPal Mobile Payments Library provides an easy way for you to integrate payments into your Blackberry applications. You can download the library from X.com and include it in your application. With the library, you need only a few lines of code to integrate the payments library into your application.
Where to Go for More Information Adaptive Payments Developer Guide Sandbox User Guide Merchant Setup and Administration Guide PayPal X Developer Network (x.
1. PayPal Mobile Payments Library This section provides details about the Mobile Payments Library API, and it provides instructions and examples for integrating the library with your Blackberry application. Mobile Payments Library API Reference The flow of the library is: 1. Your application initializes the PayPal instance with your unique PayPal application ID. 2. You retrieve the PayPal instance. 3. You retrieve the PayPal button from the instance using the getCheckoutButton method.
Also, import the appropriate classes into your application classes. The following classes must be imported: import com.paypal.blackberry.ui.CheckoutButton; import com.paypal.blackberry.PayPal; import com.paypal.blackberry. components.PayPalReceiverDetails; import com.paypal.blackberry.PayPalPayment; or import com.paypal.blackberry.AdvancedPayPalPayment; import com.paypal.blackberry.util.
NOTE: The Mobile Payments Library binds specific devices to specific application IDs, for enhanced security. For each of your application IDs, you must use a different sandbox account for each of your devices. If you log in with a different account on a device after binding, you receive the following error: “This app is attached to another PayPal account. To remove it, the account holder must visit PayPal.com and select Mobile Applications from the profile.
button to your application, you add a FieldChangeListener to your buttons which executes when the user selects the corresponding item. You can implement PayPalPaymentDelegate to be informed immediately upon the successful completion, failure, or cancellation of a payment. Should you choose not to implement a custom delegate, you can use the default implementation, which doesn’t do anything, provided by PayPal library. To respond to the button press, implement a FieldListener on the PayPal Button.
PayPalBlackberryLibraryPayPalPaymentDelegateException { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Dialog.alert("payment cancelled"); UiApplication.getUiApplication(). pushScreen(new DemoAppScreen()); }} ); }} The following are the callback events triggered in the PayPalPaymentDelegate interface: Method Description paymentCancelled The payment was cancelled by the user.
Parameter Description address The buyer's address that should be used when calculating adjusted tax and shipping amounts. currency The currency of the payment. amount The current subtotal amount. tax The current tax amount. shipping The current shipping amount. Your method must return a new Amounts object (see the “Custom Objects in the Mobile Payments Library” section). This object contains the new currency and amounts.
Method Sequence The following diagram illustrates the sequence of methods required to implement the checkout experience.
Optional Methods in the Mobile Payments Library getInstance Method This method returns the singleton PayPal object. PayPal payPal = PayPal.getInstance(); setLang Method payPal.setLang (String localeCode); Enable / Disable Shipping Method This method lets buyers include display of shipping addresses in the library. With shipping enabled, buyers can choose an address from the list available in their PayPal accounts. The chosen shipping address is then used for the payment. Shipping is enabled by default.
After the Payment After the payment is completed, the Mobile Payments Library returns the payKey. A number of other features are also available to you to enable you to further deal with the payment: Instant Payment Notification, Transaction Details, and Refunds. Instant Payment Notification Instant Payment Notification (IPN) is PayPal’s message service that sends a notification when a transaction is affected. You can integrate IPN with your systems to automate and manage your back office.
Simple, Parallel, and Chained Payments Simple payments have a single recipient. Parallel and chained payments have multiple recipients and differ in the how the payments are split. Simple Payments Simple payments use the PayPalPayment object, which supports a payment to only a single recipient. Parallel Payments Parallel Payments allow you to make payments for any amount to any number of recipients. A parallel payment is created by making a payment to multiple recipients with no primary recipient.
Chained Payments A chained payment is a payment from a sender that is indirectly parallel among multiple receivers. It is an extension of a typical payment from a sender to a receiver; however, a receiver, known as the primary receiver, passes part of the payment to other receivers, who are called secondary receivers. NOTE: Chained payments require a specific permission level on the part of the API caller and merchant.
Preapprovals The PayPal Mobile Payments Library lets you set up and obtain authorization in advance from buyers for future payments to you without requiring buyers to authorize each payment individually. For example, you might use the library to establish preapproval agreements for subscriptions to mobile content, such as mobile streaming audio or video. Or, you might use the library to establish preapproval agreements for payments to gain access to higher levels of difficulty in mobile games.
About Preapproval Pins Confirmed preapproval keys let you take payments from buyers without requiring them to log in to PayPal to authorize payments individually. Depending on your business model, you may want to obtain consent quickly from buyers before you take individual payments. Preapproval PINs are special codes that buyers enter to authorize preapproved payments individually without logging in to PayPal.
Custom Objects in the Mobile Payments Library The Mobile Payments Library includes custom objects for passing information between the library and your application during checkout. Use these objects if you enable dynamic amount calculation by calling the DynamicAmountUpdate method. MEPAddress This object is passed to your PaymentAdjuster class in the adjustAmount method. Use this address to update the payment amount, tax, currency, and shipping values of the payment.
PayPalPayment This object is passed to the library when the specific checkout method (checkoutSimplePayment, checkoutPreapprovalPayment, etc.) is called. This object contains all the values for a payment. Method Description setCurrencyType(String currencyType) (Optional) – Currency code for the payment. Defaults to USD if not set. setSubtotal(BigDecimal subtotal) (Required) – Subtotal for the payment.
PayPalAdvancedPayment This object is passed to the library when the associated non-simple Checkout method is called. This object contains all the values for a payment Method Description setCurrencyType(String currencyType) (Optional) – Currency code for the payment. Defaults to USD if not set. setReceivers(Vector PayPalReceiverDetails) (Required) – Your payment must have at minimum one receiver. The receiver itself should be set up before adding it to the payment.
PayPalInvoiceItem These items can be added to any PayPalInvoiceData. NOTE: The Price and Quantity must multiply together correctly to equal the Price. The TotalPrices of all invoiceItems of a PayPalPayment or a PayPalAdvancedPayment must equal the subtotal of the payment. Method Description setName(String name) (Optional) – The name of the item. setID(String ID) (Optional) – A unique ID for the item. setTotalPrice(BigDecimal price) (Required) – The total cost of this item (unit cost * quantity).
Enumerated Values in the Mobile Payments Library The enumerated values supported by various methods in the library are: PayPalServerType ENV_LIVE – Use the PayPal production servers. ENV_SANDBOX – Use the PayPal testing servers. ENV_NONE – Do not use any PayPal servers. Operate in demonstration mode, instead. Demonstration mode lets you view various payment flows without requiring production or test accounts on PayPal servers.
NOTE: For Personal payment types, the PayPal Checkout experience differs slightly from other payment types. Additionally for Personal payment types, senders in some cases can choose who pays any fees – the sender or the recipient. In India and Germany, recipients always pay any fees. For more information, see “setFeePaidByReceiver Method” on page 15.
Localization Support in the Mobile Payments Library To change the language in the library, call setLang (String localeCode) on the PayPal object. Pass through the desired locale code (for example, for US English, use en_US). If you do not use this method, the library defaults to the locale to which the device is set.
Language (Country or Region) Locale Code English (Spain) en_ES English (Switzerland) en_CH English (Taiwan) en_TW English (United States) en_US French (Belgium) fr_BE French (Canada) fr_CA French (France) fr_FR French (Switzerland) fr_CH German (Austria) de_AT German (Germany) de_DE German (Switzerland) de_CH Italian (Italy) it_IT Japanese (Japan) ja_JP Spanish (Argentina) es_AR Spanish (Mexico) es_MX Spanish (Spain) es_ES Polish (Poland) pl_PL Portuguese (Brazil) pt_BR
2. The Checkout Experience with the Mobile Payments Library The following screen shots illustrate several different PayPal Checkout experiences that occur after buyers click the PayPal button that your application obtains from the library by means of the getCheckoutButton()method. Checkout Experience #1 – Goods or Services with Shipping PaymentType = GOOD or SERVICE / Shipping = enabled In the preceding experience, buyers enter their PayPal login credentials in the Log In To PayPal screen.
Checkout Experience #2 – Goods or Services without Shipping PaymentType = GOODS or SERVICE / Shipping = disabled In the case, shipping is not required (that is, manual pick up of goods or services). Shipping is disabled by a call to the setShippingEnabled() library method. Buyers enter their PayPal login credentials and directly pay by clicking the Pay button on the first screen. Buyers can review funding choices by clicking the Review button on the same page.
Checkout Experience #3 – Donations PaymentSubType = Donations / Shipping = enabled In the preceding experience, buyers make a donation to a charity or other cause. In this context, the charity or cause wants to leverage PayPal members’ addresses as mailing addresses for donation receipts. By enabling shipping in the library, buyers are presented with their primary mailing address but can choose another mailing address from the ones in their PayPal accounts.
Checkout Experience #4 – Personal Send Money Payments Payment Type = PERSONAL / Shipping = disabled In the preceding experience, PayPal members make personal payments to other PayPal members. There are no transaction fees when it is funded by PayPal balance or by a bank account on file. The transaction carries a fee when it is funded by payment card – debit or credit or PayPal Credit cards. In some cases, senders choose who pays any fees – sender or recipient.
Checkout Experience #5 – Create Pin In the preceding experience, a PayPal member has just completed a payment and does not currently have a PIN associated with his or her account. By following the on-screen instructions, the user can associate the account with a phone number and PIN for easier login in the future. Upon successful creation of the PIN, the user is returned to your application, triggering the paymentSucceeded() delegate callback.
Checkout Experience #6 – Preapproval In this experience, you started the PayPal preapproval flow by calling the checkoutPreapproval method, as discussed under “Preapprovals” on page 17. Basic Preapproval Checkout Login Screen Agree and Pay Screen During a preapproval checkout, the buyer agrees to the terms of a preapproval agreement. The agreement authorizes you to take payments without requiring the buyer to log in to PayPal to authorize the payments individually.
Creating Preapproval PINs During Preapproval Checkout Depending on your business model, you may require buyers to create preapproval PINs during preapproval checkout. Preapproval PINs are special codes that buyers specify during checkout to let them consent quickly later to individual payments. If your preapproval agreements require PINs, PayPal displays the optional “Create a Code” screen during preapproval checkout.
3. Submitting Your Application to PayPal Before you distribute your mobile application publicly, you need an authorized application ID from PayPal. PayPal tests all mobile applications before issuing application IDs. Test your mobile application thoroughly in the PayPal Sandbox by using APP-80W284485P519543T as your test application ID. Then, submit your test application to PayPal. 1. Log in or sign up on PayPal’s developer website, X.com. 2. After logging in successfully, click the “My Apps” tab. 3.
A. Currencies Supported by PayPal PayPal uses 3-character ISO-4217 codes for specifying currencies in fields and variables. Currency Currency Code Australian Dollar AUD BRL Brazilian Real NOTE: This currency is supported as a payment currency and a currency balance for in-country PayPal accounts only.
B. Countries and Regions Supported by PayPal PayPal uses 2-character IS0-3166-1 codes for specifying countries and regions that are supported in fields and variables.
Country or Region Country or Region Code BRITISH INDIAN OCEAN TERRITORY BRUNEI DARUSSALAM BULGARIA BURKINA FASO BURUNDI CAMBODIA CAMEROON CANADA CAPE VERDE CAYMAN ISLANDS CENTRAL AFRICAN REPUBLIC CHAD CHILE CHINA CHRISTMAS ISLAND COCOS (KEELING) ISLANDS COLOMBIA COMOROS CONGO CONGO, THE DEMOCRATIC REPUBLIC OF COOK ISLANDS COSTA RICA COTE D'IVOIRE CROATIA CUBA CYPRUS CZECH REPUBLIC DENMARK DJIBOUTI DOMINICA DOMINICAN REPUBLIC ECUADOR EGYPT EL SALVADOR EQUATORIAL GUINEA ERITREA ESTONIA ETHIOPIA IO BN BG BF
Country or Region Country or Region Code FAROE ISLANDS FIJI FINLAND FRANCE FRENCH GUIANA FRENCH POLYNESIA FRENCH SOUTHERN TERRITORIES GABON GAMBIA GEORGIA GERMANY GHANA GIBRALTAR GREECE GREENLAND GRENADA GUADELOUPE GUAM GUATEMALA GUERNSEY GUINEA GUINEA-BISSAU GUYANA HAITI HEARD ISLAND AND MCDONALD ISLANDS HOLY SEE (VATICAN CITY STATE) HONDURAS HONG KONG HUNGARY ICELAND INDIA INDONESIA IRAN, ISLAMIC REPUBLIC OF IRAQ IRELAND ISLE OF MAN ISRAEL ITALY JAMAICA FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD G
JERSEY JORDAN KAZAKHSTAN KENYA KIRIBATI KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF KOREA, REPUBLIC OF KUWAIT KYRGYZSTAN LAO PEOPLE'S DEMOCRATIC REPUBLIC LATVIA LEBANON LESOTHO LIBERIA LIBYAN ARAB JAMAHIRIYA LIECHTENSTEIN LITHUANIA LUXEMBOURG MACAO MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF MADAGASCAR MALAWI MALAYSIA MALDIVES MALI MALTA MARSHALL ISLANDS MARTINIQUE MAURITANIA MAURITIUS MAYOTTE MEXICO MICRONESIA, FEDERATED STATES OF MOLDOVA, REPUBLIC OF MONACO MONGOLIA MONTSERRAT MOROCCO JE JO KZ KE KI KP KR KW K
Country or Region Country or Region Code MOZAMBIQUE MYANMAR NAMIBIA NAURU NEPAL NETHERLANDS NETHERLANDS ANTILLES NEW CALEDONIA NEW ZEALAND NICARAGUA NIGER NIGERIA NIUE NORFOLK ISLAND NORTHERN MARIANA ISLANDS NORWAY OMAN PAKISTAN PALAU PALESTINIAN TERRITORY, OCCUPIED PANAMA PAPUA NEW GUINEA PARAGUAY PERU PHILIPPINES PITCAIRN POLAND PORTUGAL PUERTO RICO QATAR REUNION ROMANIA RUSSIAN FEDERATION RWANDA SAINT HELENA SAINT KITTS AND NEVIS SAINT LUCIA SAINT PIERRE AND MIQUELON SAINT VINCENT AND THE GRENADINES M
SM ST SA SN CS SC SL SG SK SI SB SO SOUTH AFRICA ZA SOUTH GEORGIA AND THE SOUTH SANDWICH GS SAN MARINO SAO TOME AND PRINCIPE SAUDI ARABIA SENEGAL SERBIA AND MONTENEGRO SEYCHELLES SIERRA LEONE SINGAPORE SLOVAKIA SLOVENIA SOLOMON ISLANDS SOMALIA ISLANDS SPAIN SRI LANKA SUDAN SURINAME SVALBARD AND JAN MAYEN SWAZILAND SWEDEN SWITZERLAND SYRIAN ARAB REPUBLIC TAIWAN, PROVINCE OF CHINA TAJIKISTAN TANZANIA, UNITED REPUBLIC OF THAILAND TIMOR-LESTE TOGO TOKELAU TONGA TRINIDAD AND TOBAGO TUNISIA TURKEY TURKMENISTAN T
Country or Region Country or Region Code UKRAINE UNITED ARAB EMIRATES UNITED KINGDOM UNITED STATES UNITED STATES MINOR OUTLYING ISLANDS URUGUAY UZBEKISTAN VANUATU VENEZUELA VIET NAM VIRGIN ISLANDS, BRITISH VIRGIN ISLANDS, U.S.