question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to correctly finish transaction for Apple subscription?

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
indapubliccommented, Apr 12, 2021

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

0reactions
andresesfmcommented, Sep 1, 2022

Use the latest version of the library and use finishTransaction

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling Subscriptions Billing - Apple Developer
For this event, the App Store notifies your server with a notification of type RENEWAL and a new receipt will be generated for...
Read more >
Auto-renewing subscription: app-store completes transaction ...
I think before you call recordSubscription method, you can call finish finishTransaction method to remove payment from payment queue because you have ...
Read more >
9 fixes for if your iTunes or App Store purchase could not be ...
Seeing the message "{lease contact iTunes support to complete this transaction" or "Your purchase could not be completed"? How to fix it.
Read more >
Apple Pay | Stripe Documentation
Using Stripe and Apple Pay versus in-app purchases · Accept Apple Pay · Set up Stripe. Server-side. Client-side · Register for an Apple...
Read more >
I'm unable to make credit card purchases! - Wildlife Studios
In-app purchases (IAPs) are mediated by Google or Apple, depending on the ... This is because subscriptions will automatically renew at the end...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found