Android in app purchase quick guide.

Android in app purchase quick guide.

Few days before i have posted in google+ about android in app purchase. The discussion is totally interesting. Here is the link for google+ post https://plus.google.com/+ahesanalisuthar/posts/HckTGcAw8Gn

Here is text of post i have extracted.

Question:
I would like to integrate in-app purchases in my app.

But i have few questions.

  1. If app user successfully purchase item how can i activate feature? Does another apk will be downloaded from playstore? Does google play developer console manages these?

  2. If i have to manage in same app which is installed Should i use some persistance mechanism like database or shared preferences after user successfully made purchase? If yes than my most important question is , if user uninstall app or clear data from settings, how that purchase will be restored? Does user have to re-purchase that feature again?

Comments:

  1. After purchase you will obtain some response with product id. Then you can activate your feature – this is your responsibility.
    You can save info about the purchase and use it in the app.
    Also there is an API which allows to check if some product has been purchased. You can check this at the start-up of the app or have special option for do this. Anyway you should have this, because the store will not allow the user to buy the same product.
    This is true if product is not consumable (i.e. not like extra money in the game).
    Also take into account that there are can be following cases which can be handled if you check that the product has been purchased:
  • User redeem the product via promocode.
  • User buy the product on one device, but uses multiple devices (in this case the user think that the feature will be available on all devices).
  1. Using in-app billing API v3, your app calls getPurchases() to retrieve the features the user has purchased.
    https://developer.android.com/google/play/billing/billing_integrate.html#QueryPurchases

They are stored on the Google Play server so if the app is reinstalled the user will get his purchases back.

Purchases are cached locally on the device so you don’t need to manage your own database of purchased items if you don’t want to.
https://developer.android.com/google/play/billing/api.html#caching
3. +Christophe Beyls (https://plus.google.com/116805029264699613929) thanks, but how can i activate feature ?
Before user purchase feature how can i check that user has not yet made purchase so that let app disable that feature.
4. You disable the feature by default and only enable it when it is returned in the list returned by getPurchases().
5. Play store should cache the value, but it happens several times that is not true or the caching period is really too low, so yes, you need to have some backup because for example the device has no connectivity.

Advertisements

Why should I choose PHP over ROR for my web application?

First of let me clear one thing that i have not much experience of writing ROR apps, nor i am favouring php as i have a some experience in it.
Simplicity:

Talking about php language it is simple and easy to learn who knows c or other programming language.

Ruby is used in ROR. But it is not as simple as PHP.

Dev. Environmnet:

To getting started with php you just haveto set up a local web server with php integrated like xampp or wamp and start developing with php in few minutes.

Wel with ROR you have to do a lot of excercise to setup working environment in your machine unless you use RailsInstalle.

Deployment:

The way we deploy php application is extremley makes me happy while working with php. I just change the code right away on the server and saved and my change in production. The biggest advantage is you can host your php application on shared host as well which is cheap.

Well to deploy ROR app you at least have vps pr it’s dedicated server like passenger. You must have to install all gems . So you have to manage your server too.
Frameworks in Php:

RoR itself a framework in ruby which is awesome for rapid developement. In php there are numbers of framework you will find but i prefer laravel due to simplicity and it’s features.

I can say php is a lnguage where you can solve problems in a way that you know the logic. 

Use laravel blade template out side of laravel

Php is a very nice platform and programming langauge for building web application. To build web application we have to build dynamic html using php tags and have to process data. But presenting html is a different construct and processing data is a different construct. So if we would like to separete these both construct in php we have to use template system. Laravel provides awesome template engine but if we do not have to use laravel but it’s blade template engine we can.

We just have to add below dependency in our project composer.json file

Link for laravel blade template php packe: https://packagist.org/packages/philo/laravel-blade

"require":
      {
        "philo/laravel-blade": "3.*"
      },

Than we have to install it via below command

$ > composer install 
or 
$ > composerupdate

Once php package for blade template engine is installed let’s see how we can use it.

Create cache and view folders inside your app directory.

Now let’s create one example template view file inside views directory.

Let’s use this template to show data pass from php.

This is how we can use an awesome laravel blade template engine out side of laravel in php project.

Convert HTML and CSS page to PDF and send in email attachement in PHP

I am mainting one web based product in php. Application is about hotel management for tariff calculation and all. My client has requested to email invoice as pdf generated by php based software.

I have divided process in two steps.

  1. Dynamically Generate PDF file some where on the server using html css produces by php
  2. Attach  this generated pdf invoice in email

First of all I did tried using dompdf famous php library to generate HTML css invoice but due to incompatibility with tables i did not get accurate invoice pdf as i want. So i started searching on google and also posted on google+. Finally from my google+ php community post i came across wkhtmltopdf which is really nice tool and solve my problem.

Wkhtmltopdf

Wkhtmltopdf is a command line utility that has nothing to do with php. But we can call this utility to generate pdf file from html.

Continue reading “Convert HTML and CSS page to PDF and send in email attachement in PHP”

Some cool Array functions in PHP

When ever you have an array and you have to find an element or filter an array for different situation most of the time this is achieved by writing loop. Some times its okay to write loop. But php offers some nice set of array functions which can help you to achieve your goal without writing a loop.

Let say we have an array for a list of products.

If we want to increment each product price by 10%, we can achieve this by using array_map function.

array map

you can do var_dump new product price have 10% more than previous one.

If i have to look for an item having category is mobile, array_filter can help here

array_filter

If i would like to sum all products price array_reduce work out of box.
array_reduce

In array_reduce function when callback function iterate over first item, $current_iteration_value is 0.

array_chunk
array_chunk is a function which i like most, i achieved pagination using this function.
It split array in to number of chunks.

Let say if we have numbers of products to display, where each page have only 22 products to display and whole products array have 500 products. You can achieve this by array_chunk

There are other good array_functions available in php which you can see here.

Don’t make me think: Book Review


Don’t make me think book gives very nice explanation about web usablity for website designers and web product developers.

  • The book mainly focuses on general guideline about how to make a web pages so that a user doesn’t have to think much and can understand fast from the design and placement of the sections.
  • It also explain how to design different sections of the page so that user can easily identify what he/she is looking for and how to go back from here.
  • How a home page should look a like. What a home page should contain.

Book is really nice for a web developer as well web deigner.


Updated: 1st Aug, 2016

  • It also cover how we can do usability testing for our site. Author has covered nice explanation about usability testing and how we can proceed for such a testing with different different situation. If we have bar minimum team how we can test if we have enough budget should we have to higher professional for such testing.
  • Usability is not just about how we can use and how it looks good and attractive. But how user feels after using it first time. How it is easy and comfortable for them to use. Is it simple and map with their domain. Does it require to learn to use our web page. All these things matters.

Problem always occurs at customer side

Problem always occurs at customer side because customer uses it maximum.

 We as a developer building things regularly and test it fast and in hurry. Also we can’t test it for all use cases that customer is going to execute in practical.

From last couple of days i am driving a car. There is a problem in breaks. It makes sound when i try to control it after running at 80Km/h.  But when i consult technician, technician took a test drive and problem reproduce after several attempt and the behaviour is not exactly same as i was facing. So my point is this type of situation occurs in each discipline. A patient knows what a pain is, doctor doesn’t know. Doctor simply tries to understand the behaviour and diagnose it.

In software development also while developing software it works perfectly at developer front. But when we ship and after some times customer will asks for specific cases or complaints that are only arise at customer side only. When we as a developer tries to reproduce same problem it may or may not be reproduce exactly in same fashion.

In conclusion we must have to listen our customer carefully and tries to provide solutions for their complaints.And our solutions should makes them feel happy in use of our services or products.