Reputation: 41
Since few days I'm trying to implement the iOS in-app purchase verification on the beforeSave of a purchase (on sandbox), but it always fail. I tried the receipt with postman, and it works.
So, it's the Parse.Cloud.httpRequest the problem.
I tried also to put the receipt directly in the Cloud Code and it's always the same error (21002). https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html
Here is my code :
Parse.Cloud.httpRequest({
method: 'POST',
url:'https://sandbox.itunes.apple.com/verifyReceipt',
body:{'receipt-data':receipt},
success: function (httpResponse) {
console.log(httpResponse.text);
if (httpResponse.status == 0) {
// success
} else {
// error
}
},
error: function (httpResponse) {
// error
}
});
Is there someone that did it?
Upvotes: 3
Views: 898
Reputation: 16301
If this a auto-renewal subscription? If so, you missed the password field:
password Only used for receipts that contain auto-renewable subscriptions. Your app’s shared secret (a hexadecimal string).
in the jsonBody:
var jsonBody = {
"receipt-data" : reference,
"password" : "xxxxx"
};
Also you should JSON encode the POST BODY (node example in the following)
itunes_client.post("", {}, JSON.stringify(jsonBody),
Upvotes: 3