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?