in app purchase - What should be the developer payload in android in-app billing v3 api? -


i implementing in-app billing in app unlock premium features. in-app billing sets correctly. seems fine except 'developer payload' thing.

the sample app says

 /*      * todo: verify developer payload of purchase correct.      * same 1 sent when initiating purchase.      *      * warning: locally generating random string when starting purchase ,      * verifying here might seem approach, fail in      * case user purchases item on 1 device , uses app on      * different device, because on other device not have access      * random string generated.      *      * developer payload has these characteristics:      *      * 1. if 2 different users purchase item, payload different between them,      *    1 user's purchase can't replayed user.      *      * 2. payload must such can verify when app wasn't      *    1 initiated purchase flow (so items purchased user on      *    1 device work on other devices owned user).      *      * using own server store , verify developer payloads across app      * installations recommended.      */ 

the sample app uses empty string developer payload. question string use developer payload? can use user's primary email id?

please check below answer, may solved problem:

if using consumable item(managed item) can use random generated string

step 1: before on create method declare this:

         private static final char[] symbols = new char[36];                  static {                     (int idx = 0; idx < 10; ++idx)                         symbols[idx] = (char) ('0' + idx);                     (int idx = 10; idx < 36; ++idx)                         symbols[idx] = (char) ('a' + idx - 10);                 } 

step 2: set randomstring , sessionidentifiergenerator class in activity

          public class randomstring {          /*          * static { (int idx = 0; idx < 10; ++idx) symbols[idx] = (char)          * ('0' + idx); (int idx = 10; idx < 36; ++idx) symbols[idx] =          * (char) ('a' + idx - 10); }          */          private final random random = new random();          private final char[] buf;          public randomstring(int length) {             if (length < 1)                 throw new illegalargumentexception("length < 1: " + length);             buf = new char[length];         }          public string nextstring() {             (int idx = 0; idx < buf.length; ++idx)                 buf[idx] = symbols[random.nextint(symbols.length)];             return new string(buf);         }      }      public final class sessionidentifiergenerator {          private securerandom random = new securerandom();          public string nextsessionid() {             return new biginteger(130, random).tostring(32);         }      } 

step 3: pass payload puchase request:

randomstring randomstring = new randomstring(36);             system.out.println("randomstring>>>>" + randomstring.nextstring());             /* string payload = ""; */             // bgoa+v7g/yqdxvkrqq+jtfn4uqzbpiqjo4pf9rzj             string payload = randomstring.nextstring();             log.e("random generated payload", ">>>>>" + payload);          log.d(tag, "launching purchase flow infinite gas subscription.");             mhelper.launchpurchaseflow(this, sku_gas,                     iabhelper.item_type_inapp, rc_request,                     mpurchasefinishedlistener, payload); 

for more inforamation check link: token identify user

hope solve problem.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -