bizz84 / bizz84/SwiftyStoreKit

Major Issue - verifyReceipt method returns invalidate base64 encoded string with receipt["latest_receipt"]

Open
#428 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
6.7k
Forks
801
PR merge metrics
No merged PRs in 30d

Description

### Platform

- [12.1] iOS
- [ ] macOS
- [ ] tvOS

### In app purchase type

- [ ] Consumable
- [ ] Non-consumable
- [Y] Auto-Renewable Subscription
- [ ] Non-Renewing Subscription

### Environment

- [Y] Sandbox
- [Y] Production

### Version
ℹ 0.13.2

### Related issues
ℹ Please replace this with references to similar issues (either open or already closed).

## Report

### Issue summary
ℹ I want to update base64 latest_receipt on our server to auto renew using cron setup. We are getting wrong latest_receipt some time which returns as below :
{"status":21002, "exception":"com.apple.jingle.mzfairplay.validators.DrmInvalidArgumentException"}
We are getting proper base64 latest_receipt some time and some time not. It's serious issue for us. Because, user subscription is not updating through system using receipt.

We are using code as below :

let appleValidator = AppleReceiptValidator(service: .sandbox, sharedSecret: JSConstant.IAPSharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
switch result {
case .success(let receipt):
let purchaseResult = SwiftyStoreKit.verifySubscriptions(productIds: JSConstant.productIdentifiers, inReceipt: receipt)
debugPrint(receipt["latest_receipt"]) //WE ARE GETTING WRONG BASE64 ENCODED STRING.SOME TIME,IT'S RETURNING PROPER & SOMETIME NOT!!!
switch purchaseResult {
case .purchased(let expiryDate, let items):
print("\(JSConstant.productIdentifiers) are valid until \(expiryDate)\n\(items)\n")
case .expired(let expiryDate, let items):
print("\(JSConstant.productIdentifiers) are expired since \(expiryDate)\n\(items)\n")
case .notPurchased:
print("The user has never purchased \(JSConstant.productIdentifiers)")
}
case .error(let error):
print("Receipt verification failed: \(error)")
}
}

### What did you expect to happen
ℹ It should return valid base64 string for latest_receipt with below code in verifyReceipt result success block:
debugPrint(receipt["latest_receipt"])

### What happened instead
ℹ It is returning invalid base64 string for latest_receipt with below code in verifyReceipt result success block:
debugPrint(receipt["latest_receipt"])
Please check the attached Sandbox_Receipt.txt for your reference. I have taken log from iOS application.

Let me know if you need any further detail. I would like to fix this asap. Because,lots of user is facing this issue.

[Sandbox_Receipt.txt](https://github.com/bizz84/SwiftyStoreKit/files/2637014/Sandbox_Receipt.txt)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.