const _buyProduct = async (item: ProductsModel) => {
try {
setLoaderVisibility(true);
var transaction = await Iaphub.buy(item.sku);
console.log("TRANSACTION LOG", transaction);
if (transaction.webhookStatus === "failed") {
Alert.alert(
"Purchase delayed",
"Your purchase was successful but we need some more time to validate it, should arrive soon! Otherwise contact the support (support@myapp.com)"
);
} else {
// calling api for server side
}
} catch (err: any) {
// console.log("Purchase error", err);
setLoaderVisibility(false);
var errors: any = {
product_already_owned:
"Product already owned, please restore your purchases in order to fix that issue",
deferred_payment:
"Purchase awaiting approval, your purchase has been processed but is awaiting approval",
billing_unavailable: "In-app purchase not allowed",
network_error:
"Network error, please try to restore your purchases later (Button in the settings) or contact the support (support@myapp.com)",
receipt_failed:
"We're having trouble validating your transaction, give us some time, we'll retry to validate your transaction ASAP",
cross_platform_conflict:
"It seems like you already have a subscription on a different platform, please use the same platform to change your subscription or wait for your current subscription to expire",
user_conflict:
"Product owned by a different user, please use the account with which you originally bought the product or restore your purchases",
unexpected:
"We were not able to process your purchase, please try again later or contact the support (support@myapp.com)",
};
var errorsToIgnore = [
"user_cancelled",
"product_already_purchased",
];
var errorMessage = errors[err?.code];
if (!errorMessage && errorsToIgnore.indexOf(err?.code) == -1) {
errorMessage = errors["unexpected"];
}
if (errorMessage) {
Alert.alert("Error", errorMessage);
}
}
};
The transaction is returned properly.
We've trying to reach you in order to help by email without any success, I'm closing the issue but you can contact us (support@iaphub.com) at any time.
Please help me anyone.