Wie bestätige ich den Kauf von Verbrauchsmaterialien in Apps?
Posted: 02 Feb 2025, 08:17
Wenn die App in Home geladen wird.tsx Ich habe:
In der aktuellen purchase @ subcriptionListener Ich sehe, dass der TransactionReceipt nach erfolgreichem Kauf gedruckt wird, aber es geht mir darum:
Wie Sie das bestätigt sehen können: false und ich bin nicht sicher, warum oder wie man es behebt.
Code: Select all
const {
currentPurchase,
finishTransaction,
getProducts,
} = useIAP();
useEffect(() => {
const subscriptionListener = purchaseUpdatedListener(
async (_purchase: Purchase) => {
if (currentPurchase) {
//TODO: Send the receipt to the server
await finishTransaction({
purchase: currentPurchase,
isConsumable: true,
});
console.log(
'currentPurchase @ subscriptionListener: ',
currentPurchase.transactionReceipt,
);
}
},
);
return () => {
subscriptionListener.remove();
};
}, []);
< /code>
Wenn eine Kauftaste gedrückt wird, mache ich: < /p>
const handleProductPurchase = async (sku: Sku) => {
try {
let purchaseParams: RequestPurchase = {
sku,
andDangerouslyFinishTransactionAutomaticallyIOS: false,
};
if (Platform.OS === 'android') {
purchaseParams = { skus: [sku] };
}
await requestPurchase(purchaseParams);
} catch (error) {
console.log('err: ', error);
setIsLoading(false);
}
};
Code: Select all
{\"orderId\":\"GPA.3393-1976-6765-68323\",\"packageName\":\"com.simformLLC.iapdemo\",\"productId\":\"com.simformllc.iapdemo.years\",\"purchaseTime\":1706781727369,\"purchaseState\":0,\"purchaseToken\":\"gdpkmemapmpmmbgjakpccknl...\",\"quantity\":1,\"autoRenewing\":true,\"acknowledged\":false}