Billing is unavailable
Version of react-native-iap
3.3.9
Version of react-native
0.59.6
Platforms you faced the error (IOS or Android or both?)
Android
Expected behavior
get product list
Actual behavior
get unhandled promise Rejection, Billing is unavailable.
Tested environment (Emulator? Real Device?)
Emulator and Real device
Steps to reproduce the behavior
at first I should tell its working great on iOS, my problem is only on android,
Here is my codes.
this is my androidManifest file:

here is my setting.Gradle file:

here is my dependencies in build.gradle file:

mainApplication.java

here is my code in store scene : First I input the library
import * as RNIapX from 'react-native-iap';
import RNIap, {
purchaseErrorListener,
purchaseUpdatedListener,
type ProductPurchase,
type PurchaseError
} from 'react-native-iap';
after that I get my product Ids something like 'gem_30',... as following code:
this.itemSkus = Platform.select({
ios: props.settingProps.allConf.store_pids.app_store,
android: props.settingProps.allConf.store_pids.play_store
});
in componentDidMount I try to get product list with these codes:
_getProductListRequestFromStore = async () => {
RNIapX.initConnection()
try {
const products: Product[] = await RNIapX.getProducts(this.itemSkus);
} catch(err) {
console.warn('error',err)
}
}
in above code I will catch this error : error{"farmeToPop" : 1, "nativeStackAndroid":[], "userInfo":null,...}
and here is my listener function:
_createIAPListenner = () => {
//IAP
//console.log('in create listenner func')
this.purchaseUpdateSubscription = purchaseUpdatedListener((purchase: ProductPurchase) => {
//this.setState({loading: true})
//console.log('purchaseUpdatedListener', purchase);
const receipt = purchase.transactionReceipt;
if (receipt) {
//Call server Api
this._sendPurchaseDataToServer(receipt, purchase);
//Call server Api
}
});
this.purchaseErrorSubscription = purchaseErrorListener((error: PurchaseError) => {
this.setState({loading: false})
//console.warn('purchaseErrorListener', error);
});
//IAP
}
this code works greate on ios but keeps getting me this error on android. Also, I published my app and makes tester group and attach it to alpha version to test purchase flow. please help me to find where I'm going wrong.
thanks for your great library and efforts.
Check what you logged in google play service in your emulator.
I checked and I'm logged in, I'm using real device to test. my account is the one I add in google play console testers account
in listener I get unhandled promise error, Billing is not available:
this.purchaseUpdateSubscription = purchaseUpdatedListener((purchase: ProductPurchase) => {
//console.log('purchaseUpdatedListener', purchase);
const receipt = purchase.transactionReceipt;
if (receipt) {
//Call server Api
this._sendPurchaseDataToServer(receipt, purchase);
//Call server Api
}
});
Try changing RNIapX.initConnection() to await RNIapX.initConnection(). If this doesn't still work, please check what initConnection is returning.
Hi, thanks for answer, I did as you told but nothings changed.
_getProductListRequestFromStore = async () => {
await RNIapX.initConnection()
console.warn('Hello');
try {
const products: Product[] = await RNIapX.getProducts(this.itemSkus);
console.warn("store products",products)
} catch(err) {
console.warn('err', err); // standardized err.code and err.message available
}
}
when I add await, It seems it wont do anything. Not even show me error anymore, or even hello warning, it seems it wont go any further.
but if I dont use await I get this warning in RNIapX.getProducts(this.itemSkus) :

In Lisstenner part I also add await RNIapX.initConnection() so I dont get Unhandled Prommise warning anymore but before that I always got this error :

I think its related to my account, on iOS it's working like a charm, on android I have this issue. I checked I'm signed in google play. Do I need to add a payment method to my account or dont?
hi, any update?
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.