Skip to content

How can I judge purchaseProduct failed or not? #197

Open
@pengcao1

Description

@pengcao1

Hi, everyone:
this code snippet was copied from my project.

        InAppUtils.purchaseProduct(productId, (purchaseError: Error, transaction: IProductTransaction) => {
          if (purchaseError) {
              //TODO purcuase error?
          }
        });

and this code snippet was copied from react-native-in-app-utils README.MD file

InAppUtils.purchaseProduct(productIdentifier, (error, response) => {
   // NOTE for v3.0: User can cancel the payment which will be available as error object here.
   if(response && response.productIdentifier) {
      Alert.alert('Purchase Successful', 'Your Transaction ID is ' + response.transactionIdentifier);
      //unlock store here.
   }
});

so my question is:

  • can I change the logic from if (purchaseError) to if(!(response && response.productIdentifier))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions