benjaminmayo / merchantkit

A modern In-App Purchases management framework for iOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to check original app purchase?

melvitax opened this issue · comments

I would like to move an app from fixed price to free with in app purchase. How can I check the original receipt of the app itself so I can unlock the in app purchase to all the users who paid for the app originally?

Full receipt introspection is not yet implemented in MerchantKit. This is definitely something I want to flesh out in the future. If you are looking for an interim solution, you could copy paste the ASN1 parsing methods into your own project and decode the receipt yourself.

Thanks!

commented

@melvitax I was wondering whether you've done that work in the meantime and would be able to share some of the steps needed as I've been struggling with this part! Thanks

@s2imon Not yet but I plan on tackling it soon.

Hey, check out Merchant.receiptMetadataTask() on the latest release. This exposes the original application version.

Hi,

I wanted to do something similar to OP but I can't get Merchant.receiptMetadataTask() to work.
When I run the following code:

let task = self.merchant.receiptMetadataTask()
task.start()
task.onCompletion = { result in
	switch result {
	case .success(let metadata):
		print(metadata.originalApplicationVersion)
	case .failure(let error):
		print(error.localizedDescription)
	}
}

The completion handler is never called. However, in the logs, I can see that the receipt was fetched successfully. Am I doing something wrong?

Did you try setting the completion handler before calling start()?

That worked, I feel so stupid. Thanks for the quick help!