Download - Day1_2 nokia in-app payment
/ DEVELOPER DAYNokia Internal Use Only
CONTENTS
• Introduction
• What’s new
• Benefits
• Architecture and usage
• Coding the API into your project
/ DEVELOPER DAYNokia Internal Use Only
INTRODUCTION
Durables *(e.g. new level in a game)
Consumables(e.g. virtual currency)
Nokia In-App Payment enables developers to sell digital content to consumers from within their application. This is targeted to Nokia Asha Software Platform and Series 40 Developer Platform
/ DEVELOPER DAYNokia Internal Use Only
WHAT’S NEWThe new Nokia In-App Payment marks Nokia’s renewed approach to IAP. The solution has been designed afresh with several new features.
Most important, the new Nokia In-App Payment solution is easier to test and deploy!
Feature Nokia In-App Payment (New)
In-App Purchasing (To be deprecated)
Single click buy flow
S40 backward compatibility (6th Edition and above*)
Payment without registration
/ DEVELOPER DAYNokia Internal Use Only
BENEFITS
Profitable solution
Broadest reach Safe payment experience
• 70% payout from gross selling price
• Easy to integrate and maintain
• Single click payment• Nokia’s brand adds
credibility
• Billing in 59markets with 158 operators
• Unparalleled coverage of devices
/ DEVELOPER DAYNokia Internal Use Only
PROFITABLE SOLUTION
Easy to integrate and maintain
70% payout from gross selling price
/ DEVELOPER DAYNokia Internal Use Only
SEAMLESS AND SAFE EXPERIENCE
Single click payment
Brand credibility
/ DEVELOPER DAYNokia Internal Use Only
BROADEST REACH
Live Operators
■ Full Country coverage
■ Partial Country coverage
Operator billing live with - 158 operators - in 59 countries
(status in April 2013)
/ DEVELOPER DAYNokia Internal Use Only
ARCHITECTURE – COMPONENTS(1/3)• Nokia In-App Payment (NIAP) Library
• Shipped as jar-file, which inlcudes all public classes and APIs for application to interface with the payment system.
• Application needs to include this jar• Nokia In-App Payment Enabler
• Contains all the functionalities implemented for the payment process
• Communicates to backend server, shows UI screens for payment process
• Installed to device through store client update, or when first usage of the Nokia In-App Paymant library occurs.
/ DEVELOPER DAYNokia Internal Use Only
ARCHITECTURE - COMPONENTS(2/3)
• App makes call to IAP function implemented in the NIAP library.• NIAP library communicates with device resident NIAP enabler (enabler installed if missing)• NIAP enabler then communicate with store backend to perform the purchase.• All outside device calls are encrypted and secure.
/ DEVELOPER DAYNokia Internal Use Only
USER JOURNEY
User plays the game and reaches level 2 (premium)
Actual purchase flow User return to the game to play level 2
/ DEVELOPER DAYNokia Internal Use Only
ERROR SITUATIONS• Errors are handled in NIAP enabler, thus the Client code
generally does not need to worry about it.• Error can be temporal in nature, thus user will be offered
to try again with certain error situations.• usual related to connecting payment service,
network issues or getting payment confirmation• Also there can be Fatal Errors which can not be
recovered, then only option user can do, is to close payment process and go to the app for retry. Possible reasons includes:
• Backend couldn’t be initiated• Operator billing not possible• Payment session time out
/ DEVELOPER DAYNokia Internal Use Only
ADDING NIAP INTO YOUR APPSteps:1. Add the library into the 2. Add Code required for the API usage into the project3. Configure emulator4. Use pre-defined Testing time product Ids for testing, and change them to
real ones once your application logic is tested to work.
/ DEVELOPER DAYNokia Internal Use Only
ADDING THE NIAP LIBRARY
1. Right click project name and select “properties” from the pop up menu
When adding NIAP usage into a application, you also need to add the NIAP library into the project.This can be done with following steps:
2. select “Java build path” and “libraries” tab, and then click “Add external Jar”
3. Browse for the jar file and click ok
4. Select “Order and Export” tab, and tick the included library, and click Ok
/ DEVELOPER DAYNokia Internal Use Only
NIAP API: COM.NOKIA.PAYMENT Interface Summary
NPayListener Interface for Nokia In-App Payment Enabler callback functions.
Class Summary
NPayManager Payment flow control class, responsible for payment process.
ProductData Product data class to hold the product catalogue information
PurchaseData Payment response data clas to hold purchase results.
Exception Summary
NPayException Payment logical error exception.
/ DEVELOPER DAYNokia Internal Use Only
CODING THE API INTO PROJECT (1/3)• All API parts are implemented under com.nokia.payment, so add imports.
import com.nokia.payment.NPayException;import com.nokia.payment.NPayListener;import com.nokia.payment.NPayManager;import com.nokia.payment.ProductData;import com.nokia.payment.PurchaseData;
public class .. extends MIDlet implements NPayListener…{
public void productDataReceived(ProductData[] dataItems) {// triggered when getProductData() is called for product info like price point}public void purchaseCompleted(PurchaseData purchaseData) {// triggered when purchaseProduct() is called. handles purchase response}public void restorableProductsReceived(ProductData[] arg0) {// triggered when getRestorableProducts() called for restorable product}
• Implement NPayListener interface and add unimplemented methods.
/ DEVELOPER DAYNokia Internal Use Only
CODING THE API INTO PROJECT (1/3)• Initialize NPayManager object in the startApp() method and pass one parameter, a
reference to app MIDlet to it, and Register NPayListener interface with NPayManagerpaymentManager = new NPayManager(this);paymentManager.setNPayListener(this);
• Request price for in-app items. paymentManager.getProductData(productIds);
• Incase the library does not contain localized prices, then they are retrieved from the Nokia store via the NIAP enabler. This will cause the Application to be destroyed and re-launched.
• Before starting the payment process, check the Nokia In-App Payment Enabler is installed, if doesn’t have then install itif (!paymentManager.isNPayAvailable()) {
paymentManager.launchNPaySetup();}
/ DEVELOPER DAYNokia Internal Use Only
CODING THE API INTO PROJECT (1/3)• Prepare product ids – price point mapping in .jad file(Nokia-IAP-PricePoint-
followed by product id, then a color(:), finally price point index)1. Click ”Application Descriptor” in project files view to open the jad editor2. Open ”Application Descriptor” tab add the values3. Write the values into the file and save changes
Nokia-IAP-Pricepoint-1023608: 1Nokia-IAP-Pricepoint-1023625: 4Nokia-IAP-Pricepoint-1023624: 3Nokia-IAP-Pricepoint-1023623: 4
• Make the purchase using purchaseProduct(). Enabler starts the payment process here.String productId ="1023608";paymentManager.purchaseProduct(productId);
/ DEVELOPER DAYNokia Internal Use Only
CONFIGURING THE EMULATOR• Clear Overrule default handset
behavior option in MIDP tab of Tools->preferences menu.
• If this is not done the purchase process can be started, but the application will not be re-launched when returning from purchase confirmation.
• Remember to restart the emulator to apply the changes made.
/ DEVELOPER DAYNokia Internal Use Only
PRODUCT IDS FOR TESTING• There are several predefined product ids for testing in emulator and
in the device defined in documentation.• The Offline test product ids are intended to be used with the emulator
and online test product ids should be used with device testing• The Offline product ids are not making any connections to the Nokia
store at all.• Trying to utilize the predefined online test product ids in emulator
environment will cause the payment process to fail in all cases..• Online product ids in the device doesn’t initiate the actual payment.
Remember that device needs to have SIM card and online connectivity supported.
/ DEVELOPER DAYNokia Internal Use Only
GET PRODUCT IDS (1/3)• Go to https://publish.nokia.com/ and Add new content item as usual• Make sure that Enable In-App purchase item option is selected, this allows you to add NIAP
items into the added content item.
/ DEVELOPER DAYNokia Internal Use Only
GET PRODUCT IDS (2/3)• Create In-App purchase item by clicking ‘Add In-App purchase’ button
/ DEVELOPER DAYNokia Internal Use Only
SUMMARY
Register in-app purchase products, declare price points with Nokia Publish and retrieve product IDs
Test your app using the in-app purchase flow
Submit your final app to Nokia Publish and be ready to generate revenue
Download and install Java Development Environment for Asha and Nokia In-App Payment library
Update your application using the product IDs
Implement in-app payment feature using the test product IDs provided in the documentation
Test your app in the emulator or on device with the test purchase flow
/ DEVELOPER DAYNokia Internal Use Only
SIGN UP FOR BETA ACCESShttps://developer.nokia.com/Distribute/In-app_payment/