chirag04 / react-native-in-app-utils

A react-native wrapper for handling in-app payments
MIT License
892 stars 187 forks source link

Invalid Product Identifiers get ignored. #38

Open joshuapinter opened 7 years ago

joshuapinter commented 7 years ago

If you supply an invalid product identifier, it gets ignored. No error or warning is produced.

This is what the response object looks like when an invalid product identifier is passed: screenshot 2016-08-04 16 06 28

I think we should populate the returned error object with the invalid product identifiers.

Originally discovered in #29

chirag04 commented 7 years ago

happy to accept a PR for this. In dev mode, we can raise a warning with invalid products

wilbyang commented 7 years ago

I have created a product with type being 'Non-consumable' and status 'Waiting for review'. I am trying to load the product, with the right indentifier copying from the product, but the repsonse contains no products and just something like _invalidindentifers staff (get it from debugging windows). Does I mis-understanding some staff ? How can I check and make sure the identifier is the valid one

hamzauzumcu commented 6 years ago

I lost a lot of time but i find solution. you have to define product identifier "com.xx.xx.test" on itunes connect side. After this.

My Payment.js

` import {RestApi, Preference} from '../core'; import { NativeModules } from 'react-native' const { InAppUtils } = NativeModules;

export default class Payment { static purchase = async (id, productId) => {

    InAppUtils.receiptData((error, receiptData)=> {
      if(error) {
        console.log('itunes Error', 'Receipt not found.');
      } else {
        console.log('receiptdata: ', receiptData);
      }
    });

    var productsIDS = [
       'com.x.mobil.a5',
       'com.x.mobil.a4',
       'com.x.mobil.a3',
       'com.x.mobil.a2',
       'com.x.mobil.a1',
       'com.x.mobil.a',
    ];

    console.log('Selected Product ID:', productId);

            // routine control
    InAppUtils.canMakePayments((enabled) => {
      if(enabled) {
        console.log('IAP enabled');
      } else {
        console.log('IAP disabled');
      }
    });

    InAppUtils.loadProducts(productsIDS, (error, products) => {

        console.log('Product Informations', products);

       InAppUtils.purchaseProduct(productId, (error, response) => {

        console.log('pay response:', response);

         if (response && response.productIdentifier) {

           console.log('Purchase Successful. Your Transaction ID is ' + response.transactionIdentifier);
           alert(response);
           // var result = await Api.buyItem(id);
           // return true;

         }
       });
    });

}

`