Verifying in app purchase receipts

306 views
Skip to first unread message

Alexis L.

unread,
Feb 20, 2017, 6:24:04 AM2/20/17
to back{4}app
Hello,
this has nothing to do with b4a, but just in case someone has struggled with this.... I'm trying to validate in-app purchase receipts, from b4a back to Apple, using the following:

Parse.Cloud.define("myBeautifulVerifyReceipt",function(request,response){

var params = request.params;
var receipt = params["receipt-data"];//base64 encoded receipt, using [receipt base64EncodedStringWithOptions:0]

var url = ( request.params.production !== undefined ) ? 'https://buy.itunes.apple.com/verifyReceipt':'https://sandbox.itunes.apple.com/verifyReceipt';

Parse.Cloud.httpRequest({
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength({"receipt-data":receipt})
},
url:url,
body:{
"receipt-data":receipt
}
}).then(function(result){
response.success("ok");
},function(error){
response.error(error.message);
});
});

I always get the following response from apple ----> "data":{"status":21002}, on in other words "The data in the receipt-data property was malformed or missing."

As anyone managed to validate IAP receipts against the app store using parse api? I can't seem to figure out where the receipt payload  should go, or how it should be encoded...


cha...@back4app.com

unread,
Jul 10, 2017, 3:55:50 PM7/10/17
to Back4App
Hi!

Were you able to solve it?

Regards,

Charles Ramos

Alexis L.

unread,
Jul 11, 2017, 12:43:19 AM7/11/17
to Back4App
yes, thanks
Reply all
Reply to author
Forward
0 new messages