Parse iOS in Verifying App Purchases from Cloud Code

Ever since a few days I have been trying to implement iOS in-app purchase check on beforeSave purchase (in sandbox) but it always fails. I tried the postman receipt and it works.

So this is the Parse.Cloud.httpRequest issue.

I tried putting the receipt directly in Cloud Code as well and it is 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 anyone who has done this?

+3


source to share


1 answer


If this is an auto-renewal subscription? If so, you missed the password field:

password Used only for receipts that contain auto-renewable Subscriptions. Your apps were sharing a secret (hex string).

in jsonBody:



var jsonBody = {
                "receipt-data" : reference,
                "password" : "xxxxx"
            };

      

Also you have to JSON encode the POST BODY example (node ​​in the following)

itunes_client.post("", {}, JSON.stringify(jsonBody), 

      

+3


source







All Articles