Billing Service, getSubscriptions error 27

#1

Hi,
I am developing an application with React Native using Java to communicate with Poynt.
Following the guide to setup the billing I started implementing a check for the subscription status using the getSubscriptions method.

Initial declaration:

    private IPoyntInAppBillingService mBillingService;
    private ServiceConnection mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            Log.e("PoyntBilling", "Disconnected");
            mBillingService = null;
        }

        @Override
        public void onServiceConnected(ComponentName name,
                                       IBinder service) {
            Log.e("PoyntBilling", "Connected");
            mBillingService = IPoyntInAppBillingService.Stub.asInterface(service);
        }
    };

I connect the billing service.

@ReactMethod
public void connectBilling(final Promise promise) {
        Log.e("PoyntBilling", "Connecting");
        Intent serviceIntent =
                new Intent("com.poynt.store.PoyntInAppBillingService.BIND");
        serviceIntent.setPackage("com.poynt.store");
        getReactApplicationContext().bindService(serviceIntent, mServiceConn, getCurrentActivity().BIND_AUTO_CREATE);
        promise.resolve(true);
    }

Then invoke the checkSubscriptionStatus.

    @ReactMethod
    private void checkSubscriptionStatus(final Promise promise) {
        try {
            if (mBillingService != null) {
                Log.d("PoyntBilling", "Calling checkSubscriptionStatus()");
                String requestId = UUID.randomUUID().toString();
                String packageName = getReactApplicationContext().getPackageName();
                        mBillingService.getSubscriptions(packageName, requestId,
                        new IPoyntInAppBillingServiceListener.Stub() {
                            @Override
                            public void onResponse(final String resultJson, final PoyntError poyntError, String requestId) throws RemoteException {
                                Log.d("PoyntBilling", "Received response from InAppBillingService for " + "getSubscriptions(" + requestId + ")");

                                if (poyntError != null) {
                                    Log.d("PoyntBilling", "poyntError: " + poyntError.toString());
                                    promise.resolve(false);
                                } else {
                                    JsonParser parser = new JsonParser();
                                    promise.resolve(parser.parse(resultJson));
                                }
                            }
                        });

            } else {
                Log.e("PoyntBilling", "Not connected to InAppBillingService!");
                promise.resolve(false);
            }
        } catch (SecurityException e) {
            Log.e("PoyntBilling", e.getMessage());
            promise.resolve(false);
        } catch (RemoteException e) {
            e.printStackTrace();
            promise.resolve(false);
        }
    }

The logcat tells me:

PoyntBilling: Connecting
PoyntBilling: Connected
PoyntBilling: Calling checkSubscriptionStatus()
PoyntInAppBillingSvc: onTokenResponse
PoyntBilling: Received response from InAppBillingService for getSubscriptions(bdc5fc54-9b74-49d2-8fea-fcc7ff125c05)
    poyntError: PoyntError{code=27, httpStatusCode=0, apiErrorCode=null, reason='null', data='null', requestId='null', throwable=}

I am doing something wrong? What code = 27 means?

#2

The error code 27 is for TOKEN_UNAVAILABLE
Can you share the device SN, i can help with this

#3

For future reference for this and other errors:
https://poynt.github.io/developer/javadoc/constant-values.html#co.poynt.os.model.PoyntError.CODE_TOKEN_UNAVAILABLE

#4

The phisical Device serial is P6SW189JS001440.

Can the integration be tested using the emulator?

#5

Not at this time. I have pushed an updated version of Poynt Store to your device. Hopefully that will resolve the issue.

#6

@dennis thank you. Using real device now gives error 30 that is API ERROR. Any idea what it could be?

#7

Can you post the logcat?

#8

15:03:58

#9

@dennis @attilio
I’m getting same error (CODE_API_ERROR 30) from getPlans() and getSubscriptions() methods.
I get the same error if I try the PoyntSamples’ InAppBillingActivity activity.
Do I need an update?

I’m calling the Billing Service like this (following Poynt’s samples):

billingService.getPlans(BuildConfig.APPLICATION_ID, requestId, new IPoyntInAppBillingServiceListener.Stub() {…}

This is the response from your API:

<-- 401 Unauthorized https://billing.poynt.net/apps/db.donapp.it.donappos.poynt.dev/plans?currency=USD&status=ACTIVE&status=INACTIVE (556ms)
    Content-Type: application/json
    Date: Fri, 17 Aug 2018 12:20:27 GMT
    Server: Apache-Coyote/1.1
    Content-Length: 130
    Connection: keep-alive
    {"code":"INVALID_ACCESS_TOKEN","httpStatus":401,"message":"Access token is missing or invalid","developerMessage":"Invalid token"}

<-- END HTTP (130-byte body)

Thank you.

#10

@diego.baldi86, as discussed over email, you had an older version of com.poynt.store (App marketplace app) which was still pointing to US (https://billing.poynt.net).

1 Like
#12

@dennis anything for me?

1 Like
#13

@deepak maybe you can help me?

#14

@attilio, you are filtering out some messages in logcat, so it’s hard to diagnose. What is your terminal serial number? Can you also post output of:

adb shell dumpsys package com.poynt.store
#15

P6SW189JS001440 is the SN, @attilio and @luca will try running the command today and give you a feedback

#16

The output of adb shell dumpsys package com.poynt.store is:

Activity Resolver Table:
  Schemes:
      http:
        e0fbd56 com.poynt.store/.view.ui.details.AppDetailsActivity
        ee801d7 com.poynt.store/.view.AppDetailActivity
      https:
        e0fbd56 com.poynt.store/.view.ui.details.AppDetailsActivity
        ee801d7 com.poynt.store/.view.AppDetailActivity

  Non-Data Actions:
      android.intent.action.MAIN:
        ca27ac4 com.poynt.store/.view.ui.main.PoyntStoreMainActivity
      com.poynt.store.SHOW_ACCESSORIES:
        a2e2dad com.poynt.store/.view.AccessoryAppActivity

Receiver Resolver Table:
  Full MIME Types:
      application/vnd.android.package-archive:
        86258e2 com.poynt.store/.install.PackageVerifierReceiver

  Base MIME Types:
      application:
        86258e2 com.poynt.store/.install.PackageVerifierReceiver

  Non-Data Actions:
      com.poynt.store.action.NOTIFICATION_POSITIVE:
        9c0e473 com.poynt.store/.receiver.ActionTrackerReceiver
      com.poynt.store.action.NOTIFICATION_NEGATIVE:
        9c0e473 com.poynt.store/.receiver.ActionTrackerReceiver
      poynt.intent.action.CLOUD_MESSAGE_RECEIVED:
        ae7f30 com.poynt.store/.receiver.PoyntCloudMessageReceiver
      com.google.android.gms.analytics.ANALYTICS_DISPATCH:
        42cf7a9 com.poynt.store/com.google.android.gms.analytics.AnalyticsReceiver
      com.android.vending.INSTALL_REFERRER:
        51212e com.poynt.store/com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver
      com.google.android.c2dm.intent.RECEIVE:
        23b54cf com.poynt.store/com.google.firebase.iid.FirebaseInstanceIdReceiver
      android.intent.action.BOOT_COMPLETED:
        e345e5c com.poynt.store/.receiver.UpdateCheckWakefulReceiver

  MIME Typed Actions:
      android.intent.action.PACKAGE_NEEDS_VERIFICATION:
        86258e2 com.poynt.store/.install.PackageVerifierReceiver
      android.intent.action.PACKAGE_VERIFIED:
        86258e2 com.poynt.store/.install.PackageVerifierReceiver

Service Resolver Table:
  Non-Data Actions:
      com.google.firebase.INSTANCE_ID_EVENT:
        8346565 com.poynt.store/com.google.firebase.iid.FirebaseInstanceIdService
      com.poynt.store.INSTALL:
        652223a com.poynt.store/.install.PoyntAppInstallerService
      com.poynt.store.PoyntInAppBillingService.BIND:
        a426eeb com.poynt.store/.service.PoyntInAppBillingService
      com.poynt.store.PoyntAppBillingService.BIND:
        d70448 com.poynt.store/.service.PoyntAppBillingService

Permissions:
  Permission [com.poynt.store.BILLING] (68af2e1):
    sourcePackage=com.poynt.store
    uid=10012 gids=null type=0 prot=normal
    perm=Permission{a302806 com.poynt.store.BILLING}
    packageSetting=PackageSetting{d570ec7 com.poynt.store/10012}
  Permission [com.poynt.store.INSTALL_PROGRESS] (97c1cf4):
    sourcePackage=com.poynt.store
    uid=10012 gids=null type=0 prot=signature|privileged
    perm=Permission{362dc1d com.poynt.store.INSTALL_PROGRESS}
    packageSetting=PackageSetting{d570ec7 com.poynt.store/10012}
  Permission [com.poynt.store.permission.C2D_MESSAGE] (b96be92):
    sourcePackage=com.poynt.store
    uid=10012 gids=null type=0 prot=signature
    perm=Permission{42bd063 com.poynt.store.permission.C2D_MESSAGE}
    packageSetting=PackageSetting{d570ec7 com.poynt.store/10012}

Registered ContentProviders:
  com.poynt.store/com.google.firebase.provider.FirebaseInitProvider:
    Provider{fb81460 com.poynt.store/com.google.firebase.provider.FirebaseInitProvider}

ContentProvider Authorities:
  [com.poynt.store.firebaseinitprovider]:
    Provider{fb81460 com.poynt.store/com.google.firebase.provider.FirebaseInitProvider}
      applicationInfo=ApplicationInfo{9d61d19 com.poynt.store}

Key Set Manager:
  [com.poynt.store]
      Signing KeySets: 2

Packages:
  Package [com.poynt.store] (d570ec7):
    userId=10012
    pkg=Package{75e31de com.poynt.store}
    codePath=/data/app/com.poynt.store-2
    resourcePath=/data/app/com.poynt.store-2
    legacyNativeLibraryDir=/data/app/com.poynt.store-2/lib
    primaryCpuAbi=null
    secondaryCpuAbi=null
    versionCode=67 targetSdk=25
    versionName=1.0-DEV__
    splits=[base]
    applicationInfo=ApplicationInfo{9d61d19 com.poynt.store}
    flags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA UPDATED_SYSTEM_APP ALLOW_BACKUP ]
    privateFlags=[ PRIVILEGED ]
    pkgFlagsEx=[ ]
    dataDir=/data/user/0/com.poynt.store
    supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]
    timeStamp=2018-08-14 10:42:10
    firstInstallTime=2018-07-15 21:21:21
    lastUpdateTime=2018-08-14 10:42:30
    signatures=PackageSignatures{6010fbf [dfa168c]}
    installPermissionsFixed=true installStatus=1
    pkgFlags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA UPDATED_SYSTEM_APP ALLOW_BACKUP ]
    declared permissions:
      com.poynt.store.BILLING: prot=normal, INSTALLED
      com.poynt.store.INSTALL_PROGRESS: prot=signature|privileged, INSTALLED
      com.poynt.store.permission.C2D_MESSAGE: prot=signature, INSTALLED
    requested permissions:
      android.permission.INTERNET
      android.permission.ACCESS_NETWORK_STATE
      android.permission.ACCESS_WIFI_STATE
      android.permission.RECEIVE_BOOT_COMPLETED
      android.permission.WAKE_LOCK
      android.permission.WRITE_EXTERNAL_STORAGE
      android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
      android.permission.INSTALL_PACKAGES
      android.permission.DELETE_PACKAGES
      android.permission.PACKAGE_VERIFICATION_AGENT
      com.cyanogenmod.updater.CONTROL_UPDATER
      poynt.permission.DEVICE_ADMIN
      android.permission.MASTER_CLEAR
      android.permission.REBOOT
      android.permission.WRITE_SETTINGS
      android.permission.WRITE_SECURE_SETTINGS
      co.poynt.checkin.permission.INITIATE_CHECKIN
      android.permission.SYSTEM_ALERT_WINDOW
      com.poynt.store.BILLING
      co.poynt.checkin.AccessSharedPrefs
      poynt.permission.TOKEN_SERVICE
      poynt.permission.BUSINESS_SERVICE
      android.permission.USE_CREDENTIALS
      poynt.permission.SECOND_SCREEN_SERVICE
      com.google.android.c2dm.permission.RECEIVE
      com.poynt.store.permission.C2D_MESSAGE
      android.permission.READ_EXTERNAL_STORAGE
    install permissions:
      android.permission.DOWNLOAD_WITHOUT_NOTIFICATION: granted=true
      android.permission.WRITE_SETTINGS: granted=true
      android.permission.USE_CREDENTIALS: granted=true
      android.permission.SYSTEM_ALERT_WINDOW: granted=true
      android.permission.INSTALL_PACKAGES: granted=true
      android.permission.MASTER_CLEAR: granted=true
      android.permission.RECEIVE_BOOT_COMPLETED: granted=true
      com.poynt.store.BILLING: granted=true
      android.permission.INTERNET: granted=true
      co.poynt.checkin.AccessSharedPrefs: granted=true
      android.permission.WRITE_SECURE_SETTINGS: granted=true
      co.poynt.checkin.permission.INITIATE_CHECKIN: granted=true
      poynt.permission.BUSINESS_SERVICE: granted=true
      android.permission.PACKAGE_VERIFICATION_AGENT: granted=true
      android.permission.ACCESS_NETWORK_STATE: granted=true
      com.cyanogenmod.updater.CONTROL_UPDATER: granted=true
      android.permission.REBOOT: granted=true
      poynt.permission.DEVICE_ADMIN: granted=true
      poynt.permission.TOKEN_SERVICE: granted=true
      android.permission.ACCESS_WIFI_STATE: granted=true
      poynt.permission.SECOND_SCREEN_SERVICE: granted=true
      android.permission.WAKE_LOCK: granted=true
      com.poynt.store.permission.C2D_MESSAGE: granted=true
      android.permission.DELETE_PACKAGES: granted=true
    User 0:  installed=true hidden=false stopped=false notLaunched=false enabled=0
      gids=[3003]
      runtime permissions:
        android.permission.READ_EXTERNAL_STORAGE: granted=true, flags=[ SYSTEM_FIXED GRANTED_BY_DEFAULT ]
        android.permission.WRITE_EXTERNAL_STORAGE: granted=true, flags=[ SYSTEM_FIXED GRANTED_BY_DEFAULT ]

Hidden system packages:
  Package [com.poynt.store] (2a271d5):
    userId=10012
    pkg=Package{d978dea com.poynt.store}
    codePath=/system/priv-app/PoyntStore
    resourcePath=/system/priv-app/PoyntStore
    legacyNativeLibraryDir=/system/priv-app/PoyntStore/lib
    primaryCpuAbi=null
    secondaryCpuAbi=null
    versionCode=65 targetSdk=25
    versionName=1.0-nexi-625_NEXI_
    splits=[base]
    applicationInfo=ApplicationInfo{3c0e8db com.poynt.store}
    flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ]
    privateFlags=[ ]
    pkgFlagsEx=[ ]
    dataDir=null
    supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]
    timeStamp=2018-07-15 21:21:21
    firstInstallTime=2018-07-15 21:21:21
    lastUpdateTime=2018-07-15 21:21:21
    signatures=PackageSignatures{4780f78 []}
    installPermissionsFixed=false installStatus=1
    pkgFlags=[ SYSTEM ]
    declared permissions:
      com.poynt.store.BILLING: prot=normal
      com.poynt.store.INSTALL_PROGRESS: prot=signature|privileged
      com.poynt.store.permission.C2D_MESSAGE: prot=signature
    requested permissions:
      android.permission.INTERNET
      android.permission.ACCESS_NETWORK_STATE
      android.permission.ACCESS_WIFI_STATE
      android.permission.RECEIVE_BOOT_COMPLETED
      android.permission.WAKE_LOCK
      android.permission.WRITE_EXTERNAL_STORAGE
      android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
      android.permission.INSTALL_PACKAGES
      android.permission.DELETE_PACKAGES
      android.permission.PACKAGE_VERIFICATION_AGENT
      com.cyanogenmod.updater.CONTROL_UPDATER
      poynt.permission.DEVICE_ADMIN
      android.permission.MASTER_CLEAR
      android.permission.REBOOT
      android.permission.WRITE_SETTINGS
      android.permission.WRITE_SECURE_SETTINGS
      co.poynt.checkin.permission.INITIATE_CHECKIN
      android.permission.SYSTEM_ALERT_WINDOW
      com.poynt.store.BILLING
      co.poynt.checkin.AccessSharedPrefs
      poynt.permission.TOKEN_SERVICE
      poynt.permission.BUSINESS_SERVICE
      android.permission.USE_CREDENTIALS
      poynt.permission.SECOND_SCREEN_SERVICE
      com.google.android.c2dm.permission.RECEIVE
      com.poynt.store.permission.C2D_MESSAGE
      android.permission.READ_EXTERNAL_STORAGE
    install permissions:
      android.permission.DOWNLOAD_WITHOUT_NOTIFICATION: granted=true
      android.permission.WRITE_SETTINGS: granted=true
      android.permission.USE_CREDENTIALS: granted=true
      android.permission.SYSTEM_ALERT_WINDOW: granted=true
      android.permission.INSTALL_PACKAGES: granted=true
      android.permission.MASTER_CLEAR: granted=true
      android.permission.RECEIVE_BOOT_COMPLETED: granted=true
      com.poynt.store.BILLING: granted=true
      android.permission.INTERNET: granted=true
      co.poynt.checkin.AccessSharedPrefs: granted=true
      android.permission.WRITE_SECURE_SETTINGS: granted=true
      co.poynt.checkin.permission.INITIATE_CHECKIN: granted=true
      poynt.permission.BUSINESS_SERVICE: granted=true
      android.permission.PACKAGE_VERIFICATION_AGENT: granted=true
      android.permission.ACCESS_NETWORK_STATE: granted=true
      com.cyanogenmod.updater.CONTROL_UPDATER: granted=true
      android.permission.REBOOT: granted=true
      poynt.permission.DEVICE_ADMIN: granted=true
      poynt.permission.TOKEN_SERVICE: granted=true
      android.permission.ACCESS_WIFI_STATE: granted=true
      poynt.permission.SECOND_SCREEN_SERVICE: granted=true
      android.permission.WAKE_LOCK: granted=true
      com.poynt.store.permission.C2D_MESSAGE: granted=true
      android.permission.DELETE_PACKAGES: granted=true
    User 0:  installed=true hidden=false stopped=false notLaunched=false enabled=0
      gids=[3003]
      runtime permissions:
#17

older version of Poynt Store. What is your device serial #?

#18

Hi Dennis, SN is P6SW189JS001440

#19

@flavio.morrone has Poynt Store v67, so it should not be a problem any more.

#20

Yes correct; problem solved…

Thank you.

#21

@dennis same problem here, INVALID_ACCESS_TOKEN asking for plans
com.poynt.store is versionCode=65

SN : P6SW20XJS003508