In App Billing implementation in Titanium
Posted By : Chandan Wadhwa | 10-May-2016
In-App purchase is a native way to buy product or add some extra features in app. Many time you came into the situation where you were asked to pay for some extra options / features in an mobile App. This are totally optional functionality, but depending on what is being offered we sometimes get new functionality.
In this tutorial i will explain you how to define products for In-App Billing in Google play developer Console and implementation in titanium.
Types of product in Google play developer console :-
Managed :- Managed product are one time service eg :- fish food in a fishing app.
Subscription:- A subscription is a product type offered in In-app Billing that lets you sell content, services, or features to users from inside your app with recurring monthly or annual billing.
Defining In-App Purchase products in Google play developer console :-
Open google play developer console and navigate to your app.
Inside your app visit “In-App Product”. A Screen will appear asking you about the Managed and Subscription product choose any product type as per your requirement.
Fill the product details for Manages or Subscription product.
Initial requirements for In-App Purchases :-
- Google Payments merchant account must be activated in google play developer console.
- Product must be defined inside your app
- Real Device for testing in-app purchase.
- Create signed apk for testing.
- ti.inappbilling module.
- App must be submit for beta testing for sandbox testing.
Integrating Module code in Titanium App:-
- Add ti.inappbilling module in titanium app.
- Import module using requite("ti.inappbilling") in controller.
- Integratde module code in controller.
- Replace PUBLIC_KEY with you app public key.
Inside module code runSetup() function will be called first and after successful setup setupcomplete event will be executed.
After purchase purchasecomplete event will be executed you can execute you payment logic after receiving success response of purchase.