react-native-iap
react-native-iap copied to clipboard
beginRefundRequest can't find product for sku
Description
Calling
IapIosSk2.beginRefundRequest(sku)
.then(resp => console.log({resp}))
.catch(e => console.log({e}));
it fails with [Error: Can't find product for sku <sku_here>]
I am using useIAP
for the purchase process and have already called the getProducts
call.
It looks like before I can make the beginRefundRequest
call, I probably should call getItems
which would set the products array internally but this is not exposed by IapIosSk2.
I may be completely wrong and may have misunderstood the implementation.
Expected Behavior
it should show the refund dialog screen
Environment:
- react-native-iap: 12.10.8
- react-native: 0.71.0
- Platforms (iOS, Android, emulator, simulator, device): iOS (16.6, physical device)
To Reproduce
import { useIAP, IapIosSk2 } from "react-native-iap";
....
const {
connected,
currentPurchase,
currentPurchaseError,
requestPurchase,
finishTransaction,
getProducts,
} = useIAP();
useEffect(() => {
// ... listen to currentPurchaseError, to check if any error happened
if (!currentPurchaseError) {
return;
}
switch (currentPurchaseError?.code) {
case "E_USER_CANCELLED":
toast.error("Purchase request cancelled.");
....
}
}, [currentPurchaseError]);
useEffect(() => {
// ... listen to currentPurchase, to check if the purchase went through
if (!currentPurchase) {
return;
}
const receipt = currentPurchase.transactionReceipt;
if (receipt) {
validatePurchase(... , { receipt })
.then(async response => {
await finishTransaction({
purchase: currentPurchase,
isConsumable: true,
});
toast.success("Purchase completed.", "success");
})
.catch(error => {
...
})
.finally(_ => {
...
});
}
}, [currentPurchase, finishTransaction]);
useEffect(() => {
const getIAPProducts = async () => {
if (connected && sku) {
try {
await getProducts({ skus: [sku] });
} catch (error) {
...
} finally {
// Do nothing
}
}
};
getIAPProducts();
}, [connected, getProducts, sku]);
..
const requestRefund= () => {
IapIosSk2.beginRefundRequest(sku)
.then(resp => console.log({resp}))
.catch(e => console.log({e}));
}
We are also facing the same issue, keep getting the error: 'can't find product for sku...'
the same issue, 'can't find product for sku...'
how to solve problems ? 😪
guys.. you need to understand storekit1, or 2. and Please set setup({storekitMode: 'STOREKIT2_MODE'}); beginRefundRequest only available above iOS 15
This code will work
import { IapIosSk2, getProducts, setup } from "react-native-iap";
setup({ storekitMode: "STOREKIT2_MODE" });
await getProducts({ skus: ["sku"] });
await IapIosSk2.beginRefundRequest("sku");