react-native-iap icon indicating copy to clipboard operation
react-native-iap copied to clipboard

Billing is unavailable

Open pouya92 opened this issue 7 years ago β€’ 8 comments

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: Screen Shot 2019-09-23 at 6 24 13 PM

here is my setting.Gradle file: Screen Shot 2019-09-23 at 6 27 04 PM

here is my dependencies in build.gradle file: Screen Shot 2019-09-23 at 6 31 49 PM

mainApplication.java Screen Shot 2019-09-23 at 6 34 09 PM

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.

pouya92 avatar Sep 23 '19 15:09 pouya92

Check what you logged in google play service in your emulator.

abaddonGIT avatar Sep 23 '19 23:09 abaddonGIT

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

pouya92 avatar Sep 24 '19 09:09 pouya92

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        
      }
    });

pouya92 avatar Sep 24 '19 09:09 pouya92

Try changing RNIapX.initConnection() to await RNIapX.initConnection(). If this doesn't still work, please check what initConnection is returning.

hyochan avatar Sep 25 '19 09:09 hyochan

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) : WhatsApp Image 2019-09-25 at 4 53 56 PM

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 : warning

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?

pouya92 avatar Sep 25 '19 13:09 pouya92

hi, any update?

pouya92 avatar Oct 05 '19 10:10 pouya92

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.

stale[bot] avatar Jan 03 '20 10:01 stale[bot]

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.

stale[bot] avatar Feb 02 '20 11:02 stale[bot]