ℹ 4.0.0
ℹ N/A.
ℹ I'm migrating from version 3 to 4 and found the API removed the method refreshReceipt. My app handles the verification flow on server. So in the client, I need to retrieve the receiptData and post to my server. So I called refreshReceipt before upload it to server to make sure it is the latest but now it's not available anymore. I know I can workaround by just upload the localReceipt, but I'm not sure it is latest or not. Please advise.
ℹ Migrate from version 3 to 4
ℹ Need refreshReceipt method.
Oh... we was already ask about this in the 223 issue. But author don't want move back refreshReceipt method. It's so sad :(
Apologies for the late reply.
If you want to do receipt validation on your server, verifyReceipt is your friend and you can use it like this:
// Implement MyCustomReceiptValidator to send the encrypted receipt data to your server
let validator = MyCustomReceiptValidator(service: .production)
SwiftyStoreKit.verifyReceipt(using: validator, password: "your-shared-secret", forceRefresh: false) { result in
switch result {
case .success(let receipt):
print("Verify receipt Success: \(receipt)")
case .error(let error):
print("Verify receipt Failed: \(error)")
}
}
If you want to send the plain text receipt data to your server instead, but keep the default AppleReceiptValidator for decryption, you can do this:
let appleValidator = AppleReceiptValidator(service: .production)
SwiftyStoreKit.verifyReceipt(using: appleValidator, password: "your-shared-secret", forceRefresh: false) { result in
switch result {
case .success(let receipt):
// send plain text receipt to server
case .error(let error):
print("Verify receipt Failed: \(error)")
}
}
In both cases, refreshReceipt is not strictly needed. You can use forceRefresh: true if desired.
Makes sense?
No it’s not make sense
On Tue, Oct 10, 2017 at 7:06 PM Andrea Bizzotto notifications@github.com
wrote:
Apologies for the late reply.
If you want to do receipt validation on your server, verifyReceipt
https://github.com/bizz84/SwiftyStoreKit#verify-receipt is your friend
and you can use it like this:// Implement MyCustomReceiptValidator to send the encrypted receipt data to your serverlet validator = MyCustomReceiptValidator(service: .production)
SwiftyStoreKit.verifyReceipt(using: validator, password: "your-shared-secret", forceRefresh: false) { result in
switch result {
case .success(let receipt):
print("Verify receipt Success: (receipt)")
case .error(let error):
print("Verify receipt Failed: (error)")
}
}If you want to send the plain text receipt data to your server instead,
but keep the default AppleReceiptValidator for decryption, you can do
this:let appleValidator = AppleReceiptValidator(service: .production)
SwiftyStoreKit.verifyReceipt(using: appleValidator, password: "your-shared-secret", forceRefresh: false) { result in
switch result {
case .success(let receipt):
// send plain text receipt to server case .error(let error):
print("Verify receipt Failed: (error)")
}
}In both cases, refreshReceipt is not strictly needed. You can use forceRefresh:
true if desired.Makes sense?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/bizz84/SwiftyStoreKit/issues/272#issuecomment-335451313,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABOOA4l7I24DuosqVaASS3aCs3d1UcFdks5sq13igaJpZM4PdW-V
.
I agree with itleo31.
@bizz84 : We just need to load the receipt data and upload to server. Server will do all logic like verify receipt and update models and other stuffs. On client, this process is not verify receipt. So we just need "loadReceipt" only.
@itleo31 I think I understand now, apologies or the confusion.
So basically you want access to the localReceiptData, or refresh the receipt if this is missing or outdated.
Ok, I will implement this. My idea is to add a new method:
func fetchReceipt(forceRefresh: Bool, completion: (receipt: String) -> Void))
forceRefresh = false, it just returns the local receipt, or refreshes the receipt if missingforceRefresh = true, always refreshes the receipt regardlessThis way, you can then send the encrypted receipt to your server for processing.
Would this work for you?
Ya that will be great. Thank you very much.
Cool. Will do this now, should be available today.
@itleo31 This is now implemented in #278 in case you want to give it a quick test.
Will be doing a bit more cleanup and publish a new version soon.
@itleo31 do you think it makes more sense to return the receipt as Data or as a base64EncodedString?
Currently all receipt verification methods use String.
@bizz84 I would return as Data. That way it will match to localReceiptData.
@bizz84 why you didn't do this 4 month ago?? (issue 223)
P.S. thx.
P.P.S. I think need return Data and need function for encoding ofc.
@shuhrat10 RE string vs data, done in #284.
@vovkaprigarin Apologies, I did not understand the problem clearly back then.
@bizz84 : Same with @shuhrat10 , I think return Data is good. Can I close this issue?
@itleo31 the fix is currently on develop.
I'm waiting for CI to finish on a separate PR, merge, and publish a new pod version.
Feel free to close it.
@bizz84 can you release new pod with this changes?
@shuhrat10 I've been trying to but I'm having problems with it. See #285. Any ideas?
For the time being, you can point your pod to master.
Version 0.11.0 has been published with this fix.
Please consider move back refreshReceipt