react-native-iap icon indicating copy to clipboard operation
react-native-iap copied to clipboard

How to correctly finish transaction for Apple subscription?

Open indapublic opened this issue 3 years ago • 7 comments

Version of react-native-iap

4.6.3

Version of react-native

0.63.4

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

Transaction should be finished and appeared in My subscriptions

Actual behavior

No errors but subscription is not appeared

Tested environment (Emulator? Real Device?)

Real Device, production mode

Steps to reproduce the behavior

await RNIAP.initConnection()
RNIAP.clearProductsIOS()
const products = await RNIAP.getProducts([productId])
RNIAP.purchaseUpdatedListener(async (purchase) => {	
	// Checking for prod mode first
	let result = await RNIAP.validateReceiptIos({
		"receipt-data": purchase.transactionReceipt,
		"password": env.IOS_IAP_SECRET,
	}, false)
	// Then for sandbox mode
	if (result.status === 21007) {
		result = await RNIAP.validateReceiptIos({
			"receipt-data": purchase.transactionReceipt,
			"password": env.IOS_IAP_SECRET,
		}, true)
	}
	if (result.status !== 0) {
		return
	}
	RNIAP.finishTransaction(purchase, true)
})
RNIAP.purchaseErrorListener(error => {
	reject(error)
})

return RNIAP.requestSubscription(productId, false)

indapublic avatar Apr 02 '21 12:04 indapublic

I have the same problem! I use RNIAP.finishTransaction(purchase) after the receipt checking everything works until i use getPurchaseHistory() / getAvailablePurchase() when i use the above functions, clicking the subscription button become checking the old receipt validation, instead of showing the purchase

PazuC10 avatar Apr 03 '21 12:04 PazuC10

I think you shouldn't be doing the validation in the client side if the user try to intercept the requests with a proxy and override the IOS_IAP_SECRET by Reverse engineering your app this should give premium access or features with a very simple atack

Ulisses1478 avatar Apr 12 '21 15:04 Ulisses1478

Hi @Ulisses1478 Thanks for your answer, but my question was different. In real life backend checks receipt.

indapublic avatar Apr 12 '21 23:04 indapublic

please check my reply on other question #1312 hope this can help you

PazuC10 avatar Jun 30 '21 04:06 PazuC10

@PazuC10 What's your version? Your code is almost same as mine

indapublic avatar Jun 30 '21 04:06 indapublic

@PazuC10 What's your version? Your code is almost same as mine

iap: 6.0.2, react-native: 0.64.0

PazuC10 avatar Jul 01 '21 14:07 PazuC10

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

stale[bot] avatar Apr 18 '22 19:04 stale[bot]

Use the latest version of the library and use finishTransaction

andresesfm avatar Sep 01 '22 23:09 andresesfm