Swiftystorekit: How to get receipt

Created on 3 Jul 2017  Â·  2Comments  Â·  Source: bizz84/SwiftyStoreKit

Platform

  • [* ] iOS
  • [ ] macOS
  • [ ] tvOS

In app purchase type

  • [ ] Consumable
  • [ ] Non-consumable
  • [* ] Auto-Renewable Subscription
  • [ ] Non-Renewing Subscription

Environment

  • [* ] Sandbox
  • [ ] Production

Version

ℹ Please replace this with the version of SwiftyStoreKit you're using.

Related issues

ℹ How to get Apple Receipt

Report

Issue summary

ℹ I want to send apple receipt to server and also want see human readable receipt.

What did you expect to happen

ℹ Please replace this with what you expected to happen.

What happened instead

ℹ Please replace this with what happened instead.

answered question

All 2 comments

To get receipt data, use

if let receiptData = SwiftyStoreKit.localReceiptData {
   let receiptDataAsString = receiptData.base64EncodedString(options: [])
}

or

if let receiptURL = Bundle.main.appStoreReceiptURL, 
   let receiptData = try? Data(contentsOf: receiptURL) {
   let receiptDataAsString = receiptData.base64EncodedString(options: [])
}

In order to see human readable receipt content, you should use iTunes Store to parse the receipt, as iTunes Store is the only source of truth when dealing with subscriptions. https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html
You should make a request to https://buy.itunes.apple.com/verifyReceipt with your receipt data to get the receipt content.

@ashishfission @mihai8804858 I would also recommend to read the Receipt Verification section.

To get a human readable receipt in SwiftyStoreKit, you can use the verifyReceipt() method.

Closing this. Feel free to reopen if you have any more questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cwinUser picture cwinUser  Â·  3Comments

Sam-Spencer picture Sam-Spencer  Â·  5Comments

Erumaru picture Erumaru  Â·  4Comments

mrmasterwill picture mrmasterwill  Â·  7Comments

jerry317 picture jerry317  Â·  7Comments