User Tools

Site Tools


inapp_payment

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

inapp_payment [2020/06/22 10:43] (current)
Line 1: Line 1:
 +======InApp Payment======
 +
 +====Introduction====
 +InApp Payment allows you to collect payments from inside your applications on Firstouch Devices. You can use the service
 +to collect payments from users of your application. The InApp Payment service handles the payment process easing the
 +need for you to process financial payments. Even App Bazaar application on Firstouch devices uses the same service to
 +process payments for paid applications making users to experience the same flow while using InApp Payment. Applications
 +that are published on the App Bazaar can make use of the InApp Payment service to enable users to make payments. Users
 +do not need to have credit/​debit card to make a payment using InApp Payment, all the payments done are processed via
 +**Operator Billing**. The amount paid is either deducted from the prepaid balance of the user or appears on the bills of their
 +postpaid connections. Operator Billing is an integrated payment mechanism that is cellphone network provider specific and
 +removes the need for a credit/​debit card.
 +
 +====Process to integrate InApp Payment====
 +One needs to have a developer account registered with Firstouch and an application created on the developer portal to
 +make use of the InApp Payment service in their application.
 +There are two major steps involved in the integration process.
 +  - Procurement of **inappcode** from the [[http://​developer.firstouchmobile.com|developer portal]]
 +  - Integration of the InApp Payment library in the application source
 +
 +====Procurement of inappcode from the developer portal====
 +  - Register as a developer on the Firstouch developer portal at [[http://​developer.firstouchmobile.com|developer portal]]
 +  - After logging in click on the “Add New Apps”, fill in the details for your application,​ hit the submit button and then you can see the **inappcode** under Application Details section in the Application details page
 +  - If you already have an account/app on the App Bazaar and would like to integrate InApp Payment in your existing application,​ then simply login to the developer portal using your credentials,​ select the application in which you would want to integrate InApp Payment in the Applications tab. You can find the **inappcode** under Application Details section in the Application details page
 +
 +Remember that you have to use this **inappcode** that is generated uniquely for every app while integrating the InApp Payment library in the application.\\ ​ **Please note** the **inappcode** generated is random, so you might see different **inappcode** every time you visit the portal.  ​
 +
 +====Integration of the InApp Payment library in the application source====
 +  - Download the **appbazaar-inapp-payment-1.0.jar** library and **sample code** from {{:​appbazaarinapp_paymentv1.zip|here}}
 +  - Add the library to your application source project. If you are using Eclipse, this amounts to adding the jar to the libs/folder of the project
 +
 +====Implementing in the application source code====
 +Implementation of InApp Payment involves
 +  - Checking for the availability of Firstouch InApp Payment
 +    - Ensure you have imported the **com.firstouch.inapppayment.Payment** class wherever you are implementing this piece of code\\ ''​**import com.firstouch.inapppayment.Payment;​**''​
 +    - Create a object of the class **Payment**. You would need to pass a reference to Context (android.content.Context generally the Activity where from the payment is to be initiated) to create an instance of Payment.\\ ''​**Payment payment = Payment.getInstance(context);​**''​
 +    - Check if the payment method is available. This will be used to verify if the device where this is running supports Firstouch’s InApp Payment or not. Developer’s may use this to fall back onto other payment mechanisms like Google Checkout which works on credit card based payments.\\ ''​**boolean isFirstouchPaymentAvailable = payment.isAvailable();​**''​
 +  - Invoking the payment
 +    - Call the initiatePayment method on the payment object while passing the inappcode of the app and the amount of the payment. The amount must be in Indian Rupees. Currently we only support payments in Indian Rupees.\\ ''​**payment.initiatePayment("​sampleinappcode",​ "​10"​);​**''​
 +    - Please ensure that that this call is made on the main UI thread itself as this invokes new activities to perform the entire payment process.
 +  - Receiving & Handling the Payment Response
 +    - One would need to handle the response of the payment process to manage the application flow post successful payment.
 +    - In order to handle response, implement the interface **PaymentResponseHandler** and its methods (ensure that you import **com.firstouch.inapppayment.PaymentResponseHandler** in the file where you plan to implement the same)
 +    - Pass a reference of the instance of **PaymentResponseHandler** to the **Payment** object via a **setListener()** method before calling the **initiatePayment**\\
 +    - Appropriate responses for success, cancelled and failure can be handled in implemented methods of interface **com.firstouch.inapppayment.PaymentResponseHandler**. These methods will get called post the payment process - **onSuccess** is called if the payment has been successfully processed, **onCancel** is called if the user has cancelled the payment & **onFailed** is called when the payment has failed.
 +
 +  payment.setListener(new PaymentResponseHandler(){
 +      public void onSuccess(String code, String response_message) {
 +        //do anything you want with the Success response here
 +      }
 +      public void onCancel(String code, String response_message) {
 +        //do anything you want with the Success response here
 +      }
 +      public void onFailed(String code, String response_message) {
 +        //do anything you want with the Success response here
 +      }
 +    });
 +====Sample Code====
 +    ​
 +    Payment payment = Payment.getInstance(context);​
 +    boolean isFirstouchPaymentAvailable = payment.isAvailable();​
 +    ​
 +    if(isFirstouchPaymentAvailable){
 +        payment.setListener(new PaymentResponseHandler(){
 +            public void onSuccess(String code, String response_message) {
 +             //do anything you want with the Success response here
 +            }
 +    ​
 +            public void onCancel(String code, String response_message) {
 +             //do anything you want with the Cancelled response here
 +            }
 +    ​
 +            public void onFailed(String code, String response_message) {
 +             //do anything you want with the Failed response here
 +            }
 +         });
 +    ​
 +      payment.initiatePayment("​sampleinappcode",​ "​10"​);​
 +    }
 +
 +
 +====Viewing Payment Reports====
 +Payment details can be viewed at the developer portal at [[http://​developer.firstouchmobile.com]] under the **Reports** section. Payments processed via the InApp Payment are tagged separately in the reports.
 +
 +====Terms====
 +  - All the purchases are done in Indian currency INR only
 +  - Firstouch only provides a mechanism for InApp Payments
 +  - Service/​product/​content delivery is not the responsibility of Firstouch
 +
 +
  

Page Tools