I have an Electron app with In-App Purchases integrated.
The In-App Purchases themselves are working - I can pull down the price and display it - and the user can buy the IAP. However, I'm having trouble validating the Apple receipt.
I'm using this apple-store-receipt-validator-in-php PHP script to validate the Apple receipt. And this works fine if I use the default encoded receipt data ("ewoJInNpZ25hdHVyZSIgPSAiQX..." - line 18 on the PHP script) where I get this response:
{
"receipt":{
"original_purchase_date_pst":"2012-04-30 08:05:55 America\/Los_Angeles",
"original_transaction_id":"1000000046178817",
"original_purchase_date_ms":"1335798355868",
"transaction_id":"1000000046178817",
"quantity":"1",
"product_id":"com.mindmobapp.download",
"bvrs":"20120427",
"purchase_date_ms":"1335798355868",
"purchase_date":"2012-04-30 15:05:55 Etc\/GMT",
"original_purchase_date":"2012-04-30 15:05:55 Etc\/GMT",
"purchase_date_pst":"2012-04-30 08:05:55 America\/Los_Angeles",
"bid":"com.mindmobapp.MindMob",
"item_id":"521129812"
},
"status":0
}
However, when I read the Apple receipt file, base64 encode it and post it to the validator script within Electron, I get the following response:
{
status:21002
}
According to the Apple Developer site, this error code means:
The data in the receipt-data property was malformed or missing.
Here is how I'm reading the Apple receipt, base64 encoding it and sending it to the php script:
inAppPurchase.on('transactions-updated', (event, transactions) => {
transactions.forEach(function (transaction) {
var payment = transaction.payment
switch (transaction.transactionState) {
case 'purchased':
// Get the receipt url.
let receiptURL = inAppPurchase.getReceiptURL()
// get receipt data from file
var receiptRaw = fs.readFileSync(receiptURL)
// base64 encode the receipt data
var receiptEncoded = receiptRaw.toString('base64')
// submit the receipt file to the server and check if it is valid
$this.$axios({
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
data: {
res: receiptEncoded
},
url: 'http://temp.dconnell.co.uk'
}).then(function (response) {
console.log('response: ', response);
if (!response.data.status) {
console.log('Valid receipt.');
}
else {
console.log('Invalid receipt!');
}
}).catch(function (error) {
console.log(error);
});
// Finish the transaction.
inAppPurchase.finishTransactionByDate(transaction.transactionDate)
break
default:
break
}
})
})
I've also tried using the js-base64 library to encode the Apple receipt data instead, to no avail:
var receiptEncoded = Base64.encode(receiptRaw)
Here is the server side code I'm using:
<?php
error_reporting(-1);
if(empty($_SERVER['CONTENT_TYPE']))
{
$_SERVER['CONTENT_TYPE'] = "application/x-www-form-urlencoded";
}
header("Access-Control-Allow-Origin: *");
#######################################################################
#######################################################################
## ##
## ##
## PROGRAMMED BY AMIN MAHDI MAMDOOH (ARS NETWORK DEVELOPER TEAMS), ##
## ARS Network (M) Sdn. Bhd. , http://www.ars-network.com ##
## http://www.ARSgroupco.com , http://www.mamdooh.me ##
## ##
## Copyright (c) 2000-2015 ARSgroupco.com ##
## Created @ 2015.01.28 ##
## iOS Web Application Control Panel VERSION 2.00 ##
## ##
## ##
#######################################################################
#######################################################################
// $res = "ewoJInNpZ25hdHVyZSIgPSAiQXBNVUJDODZBbHpOaWtWNVl0clpBTWlKUWJLOEVk
// ZVhrNjNrV0JBWHpsQzhkWEd1anE0N1puSVlLb0ZFMW9OL0ZTOGNYbEZmcDlZWHQ5
// aU1CZEwyNTBsUlJtaU5HYnloaXRyeVlWQVFvcmkzMlc5YVIwVDhML2FZVkJkZlcr
// T3kvUXlQWkVtb05LeGhudDJXTlNVRG9VaFo4Wis0cFA3MHBlNWtVUWxiZElWaEFB
// QURWekNDQTFNd2dnSTdvQU1DQVFJQ0NHVVVrVTNaV0FTMU1BMEdDU3FHU0liM0RR
// RUJCUVVBTUg4eEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUtEQXBCY0hCc1pT
// QkpibU11TVNZd0pBWURWUVFMREIxQmNIQnNaU0JEWlhKMGFXWnBZMkYwYVc5dUlF
// RjFkR2h2Y21sMGVURXpNREVHQTFVRUF3d3FRWEJ3YkdVZ2FWUjFibVZ6SUZOMGIz
// SmxJRU5sY25ScFptbGpZWFJwYjI0Z1FYVjBhRzl5YVhSNU1CNFhEVEE1TURZeE5U
// SXlNRFUxTmxvWERURTBNRFl4TkRJeU1EVTFObG93WkRFak1DRUdBMVVFQXd3YV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2TlRV
// Z1FXMWxjbWxqWVM5TWIzTmZRVzVuWld4bGN5STdDZ2tpYjNKcFoybHVZV3d0Y0hW
// eVkyaGhjMlV0WkdGMFpTSWdQU0FpTWpBeE1pMHdOQzB6TUNBeE5Ub3dOVG8xTlNC
// RmRHTXZSMDFVSWpzS2ZRPT0iOwoJImVudmlyb25tZW50IiA9ICJTYW5kYm94IjsK
// CSJwb2QiID0gIjEwMCI7Cgkic2lnbmluZy1zdGF0dXMiID0gIjAiOwp9";
if (isset($_GET['res'])) {
$res = $_GET['res'];
}
// iTunes Validator V2 Start Function
function receipt_Result_ITC($isSandbox,$receipt_data) {
if ($isSandbox) {
$url = "https://sandbox.itunes.apple.com/verifyReceipt/";
}
else {
$url = "https://buy.itunes.apple.com/verifyReceipt";
}
$ch = curl_init($url);
$data_string = json_encode(array(
'receipt-data' => $receipt_data
));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (200 != $httpCode) {
echo "Error validating App Store transaction receipt. Response HTTP code $httpCode";
}
$decoded = json_decode($output, TRUE);
return $decoded;
}
// iTunes Validator V2 End Function
$result = receipt_Result_ITC (true,$res);
$jsonResult = json_encode($result);
echo $jsonResult;
?>
I believe I'm not reading and / or encoding the Apple receipt file data correctly before sending. How can I do this correctly?
This is the result of var receiptEncoded = receiptRaw.toString('base64')
:
MIITvQYJKoZIhvcNAQcCoIITrjCCE6oCAQExCzAJBgUrDgMCGgUAMIIDXgYJKoZIhvcNAQcBoIIDTwSCA0sxggNHMAoCAQgCAQEEAhYAMAsCAQECAQEEAwIBADALAgELAgEBBAMCAQAwCwIBDgIBAQQDAgEBMAsCA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natn9xSg1ug++Qdck+cJaOt7QyKE3blhr7PoVnUpEmRlYy4XnaOja8I/Ac6n+mhnV7ITnCSfPFnZmAREXcylWxCUvm6RDtR9dNmyWXhhvQDK/vlA9rbGQi7KOrW6y2TuMy2mc8Ircd7qbzGs3GAossD39u7Xs+AUmuA=
Or if I use var receiptEncoded = Base64.encode(receiptRaw)
then this is the result:
MO+/vRPvv70GCSrvv71I77+977+9DQEHAu+/ve+/vRPvv70w77+9E++/vQIBATELMAkGBSsOAwIaBQAw77+9A2MGCSrvv71I77+977+9DQEHAe+/ve+/vQNUBO+/vQNQMe+/vQNMMAoCAQgCAQEEAhYAMAsCAQECAQEEAwIBADALAgELAgEBBAMCAQAwCwIBDgIBAQQDAgEBMAsCAQ8CAQEEAwIBADALAgEQAgEBBAMCAQAwCwIBGQIBAQQDAgECMAwCAQoCAQEEBBYCNCswDAIBDQIBAQQEAgJP77+9MA0CARMCAQEEBQwDMS4wMA4CAQkCAQEEBgIEUDI1MDAPAgEDAgEBBAcMBTMuMS4wMBgCAQQCAQIEEFVz77+977+9H2Nd77+9Lzjvv73vv73vv70QVxMwGwIBAAIBAQQTDBFQcm9kdWN0aW9uU2FuZGJveDAcAgEFAgEBBBTvv73vv73vv73vv71j77+9D3YnZR/vv71QGe+/ve+/vQvvv73vv73vv70wHgIBDAIBAQQWFhQyMDE5LTAyLTI4VDExOjMwOjQwWjAeAgESAgEBBBYWFDIwMTMtMDgtMDFUMDc6MDA6MDBaMCgCAQICAQEEIAweY29tLmRhbm55Y29ubmVsbC5lbWFpbHNuaXBwZXRzMD0CAQcCAQEENS5w77+9Ke+/vT/vv71LMu+/vVRNUO+/ve+/vQXvv73vv71j77+977+977+9Rn7vv71iZu+/vdCW77+9Vm7vv71/77+9BWHvv71BE++/ve+/ve+/vRtY77+977+977+9VO+/ve+/vTBSAgEGAgEBBErvv73vv73vv73vv70SADt2NxPvv73vv73vv70777+9J8On77+977+977+9X38M77+977+9ZVc0Fe+/vUHvv73vv70e77+917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ApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzDvv70BIjANBgkq77+9SO+/ve+/vQ0BAQEFAAPvv70BDwAw77+9AQoC77+9AQEA77+9z4Hvv70l77+977+9W9aH77+9I++/vTMc77+977+9I++/ve+/ve+/vSbvv709xp/vv71KDVXvv73vv73vv70C15fvv705VG19f++/vVQY77+977+9LFJx77+9ZHvvv73Oie+/vUnvv70I5bSIce+/vT9bRi7vv73vv70d77+9A++/vVjvv70EPiF477+927fQjhLvv73vv71MWypoN++/ve+/ve+/vR7vv73SoQxKWFLvv70S77+977+977+9H++/vRXvv701Le+/ve+/vRLKjUjvv73vv71YeFRr77+9MTYfSgYMR1Tvv70377+977+977+977+977+9fV/vv73vv71K77+977+977+94Lqk77+977+977+9Y++/vSvvv73vv73vv70+b++/ve+/ve+/vTzvv73vv71SGu+/vSUKdg7vv73vv73vv73vv73vv73vv71r77+9W17vv71zUUkIVu+/ve+/vUPvv73Mju+/vQLQoO+/ve+/vVzvv73vv71pae+/ve+/vRBoJiY577+9HRBz77+9Cl3vv71z77+977+9djvvv70t2Yge77+977+9B++/ve+/ve+/ve+/ve+/vSZV77+977+977+9A0kjAgMBAAHvv73vv70B77+9MO+/vQHvv70wPwYIKwYBBQUHAQEEMzAxMC8GCCsGAQUFBzAB77+9I2h0dHA6Ly9vY3NwLmFwcGxlLmNvbS9vY3NwMDMtd3dkcjA0MB0GA1UdDgQWBBTvv73vv73vv73vv73vv71277+977+977+977+977+9Te+/ve+/vTZd77+9KwTvv70wDAYDVR0TAQHvv70EAjAAMB8GA1UdIwQYMBbvv70U77+9JxcJ77+977+9GGDvv73vv73vv73vv71HWe+/vVJU77+977+9MO+/vQEeBgNVHSAE77+9ARUw77+9AREw77+9AQ0GCirvv71I77+977+9Y2QFBgEw77+977+9MO+/ve+/vQYIKwYBBQUHAgIw77+977+9DO+/ve+/vVJlbGlhbmNlIG9uIHRoaXMgY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0YW5jZSBvZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBjb25kaXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZpY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMDYGCCsGAQUFBwIBFipodHRwOi8vd3d3LmFwcGxlLmNvbS9jZXJ0aWZpY2F0ZWF1dGhvcml0eS8wDgYDVR0PAQHvv70EBAMCB++/vTAQBgoq77+9SO+/ve+/vWNkBgsBBAIFADANBgkq77+9SO+/ve+/vQ0BAQUFAAPvv70BAQAN77+9G++/vS4977+9WysHbkLvv71s77+977+9QzDvv71f77+9XNGN77+977+9D++/vRrvv70l77+924zvv73DgFnvv73vv73vv73vv70uBRTvv70N27bvv73vv73vv701LnzLrRdr77+9fx/vv71377+977+9Z++/ve+/vRNe77+9Ge+/vXbvv71aIO+/ve+/vWPvv70Pc++/ve+/ve+/ve+/vR/vv73vv73vv71lSFzvv73vv70oOu+/vRA3Le+/ve+/vQQ5H3Pvv73vv70F77+977+977+9fxoqKm4rAe+/ve+/vSBc77+977+9fSfvv70z77+977+977+977+9RNuxTGfvv71uCk/vv73vv70G77+90pfvv71rUe+/vVrvv711Ze+/vRYEYu+/ve+/vV/vv70I77+977+9aNmSAO+/ve+/ve+/ve+/ve+/ve+/vQBk77+9WGDvv71877+977+9de+/vWnvv71bKu+/vR1obu+/vULvv71M77+9Nxnvv73vv707HHoZQ++/vW3vv71IYAYMNu+/vSvvv73vv70Y77+9Ee+/vS0j0I7vv73vv71p77+9Fxvvv73vv717OUdFMGEv77+9E++/vTDvv70EIjDvv70DCu+/vQMCAQICCAHevO+/vTlt77+9EDANBgkq77+9SO+/ve+/vQ0BAQUFADBiMQswCQYDVQQGEwJVUzETMBEGA1UEChMKQXBwbGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxFjAUBgNVBAMT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+/vUdNfwheMC4GA1UdHwQnMCUwI++/vSHvv70f77+9HWh0dHA6Ly9jcmwuYXBwbGUuY29tL3Jvb3QuY3JsMA4GA1UdDwEB77+9BAQDAgHvv70wEAYKKu+/vUjvv73vv71jZAYCAQQCBQAwDQYJKu+/vUjvv73vv70NAQEFBQAD77+9AQEAT++/ve+/vVnvv70s77+977+9bC/vv73vv70T77+9Mu+/vQU177+9bu+/vX3vv71pDO+/ve+/vRfvv713LO+/vWfvv73vv73vv71tOllc34MB77+977+977+9KmFy77+977+977+977+9RTDvv73vv73vv70N77+9HUfvv73xk4qjdO+/ve+/vcOYcu+/vTs+77+9RQvvv71U77+9Mu+/ve+/vRhTawpOEO+/ve+/vR1QbCHvv70K77+9Tlfvv71rWzw977+977+977+977+9DSMdC0om77+9P++/ve+/ve+/vUzvv70ZEhltV++/vXpY77+9e2jvv73khoxK77+977+9SRTvv73vv73vv71VAO+/ve+/ve+/vUsw77+94aCx77+9Ke+/ve+/vQl377+9NO+/vQHvv71/77+977+9Cu+/vTvvv73vv73vv71i77+977+9BWNB77+977+9DzsdTO+/ve+/vdur77+9yZXvv71P77+9Te+/vSbvv73vv73vv73vv73vv70p77+9AXpm77+9Lu+/ve+/vSHvv73vv73vv7144YGu77+905Dvv73vv73vv73vv73vv704Gu+/vWcwHFHvv71c77+9ce+/ve+/ve+/vWwPDBUfMO+/vQTvv70w77+9A++/ve+/vQMCAQICAQIwDQYJKu+/vUjvv73vv70NAQEFBQAwYjELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkFwcGxlIEluYy4xJjAkBgNVBAsTHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRYwFAYDVQQDEw1BcHBsZSBSb290IENBMB4XDTA2MDQyNTIxNDAzNloXDTM1MDIwOTIxNDAzNlowYjELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkFwcGxlIEluYy4xJjAkBgNVBAsTHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRYwFAYDVQQDEw1BcHBsZSBSb290IENBMO+/vQEiMA0GCSrvv71I77+977+9DQEBAQUAA++/vQEPADDvv70BCgLvv70BAQDkkakJH++/ve+/vR5HUO+/vQXvv71eee+/vS3vv70277+9V0xV77+9Ge+/ve+/ve+/vUts77+9B++/vSIwAu+/vRg+77+9UAnvv71/Qe+/ve+/ve+/ve+/ve+/vWbvv70kaxHQo++/ve+/vRsq77+9H++/ve+/vXoM77+9R++/vVvvv70WNzPvv73vv70PTe+/vRRp77+977+9GXLvv71dDu+/vX9f77+977+9JQPvv71V77+9TV0N77+9ZDUjFUsVWR3vv73vv73vv73vv73vv73vv73vv71Q77+977+9WFBn77+9CO+/vSDvv73LrCwgb3Dvv70/ATDvv73vv71D77+9D++/vT3vv70rSSga77+977+9zrXvv70O77+9Xhzvv73vv70977+9Ou+/ve+/vQ8OAO+/vQvvv70hFi5077+9PA3vv71iFu+/ve+/vXHvv71HU1Xvv73vv70vQe+/ve+/ve+/ve+/vXDvv73vv71MRX4fTGtQ77+9Qe+/ve+/vXRiCxDvv71B77+9M++/ve+/ve+/vTBY77+9WgQy77+9aO+/ve+/vR3vv71lc++/vWdeZe+/vUnvv71277+9MxRl77+9d++/ve+/vS0CAwEAAe+/ve+/vQF6MO+/vQF2MA4GA1UdDwEB77+9BAQDAgEGMA8GA1UdEwEB77+9BAUwAwEB77+9MB0GA1UdDgQWBBQr77+9aUfvv712Ce+/ve+/vWvvv70uQO+/ve+/vUdNfwheMB8GA1UdIwQYMBbvv70UK++/vWlH77+9dgnvv73vv71r77+9LkDvv73vv71HTX8IXjDvv70BEQYDVR0gBO+/vQEIMO+/vQEEMO+/vQEABgkq77+9SO+/ve+/vWNkBQEw77+977+9MCoGCCsGAQUFBwIBFh5odHRwczovL3d3dy5hcHBsZS5jb20vYXBwbGVjYS8w77+977+9BggrBgEFBQcCAjDvv73vv70a77+977+9UmVsaWFuY2Ugb24gdGhpcyBjZXJ0aWZpY2F0ZSBieSBhbnkgcGFydHkgYXNzdW1lcyBhY2NlcHRhbmNlIG9mIHRoZSB0aGVuIGFwcGxpY2FibGUgc3RhbmRhcmQgdGVybXMgYW5kIGNvbmRpdGlvbnMgb2YgdXNlLCBjZXJ0aWZpY2F0ZSBwb2xpY3kgYW5kIGNlcnRpZmljYXRpb24gcHJhY3RpY2Ugc3RhdGVtZW50cy4wDQYJKu+/vUjvv73vv70NAQEFBQAD77+9AQEAXDbvv71MLXjvv73tjJvvv73vv71377+977+9du+/vXcwT++/vR/vv73vv73vv70b77+9PUc377+9QO+/vSzUse+/vRLYvu+/vXPvv73vv73vv71kD++/vXlPNNiiPu+/vXjvv71r77+9B++/vX0577+977+9UyDvv704xLHvv73vv71PCmvvv70r77+9We+/vQUJfBdAVhEedNO377+9IztH77+977+9byTvv73vv73Rt3Dvv70PRe+/vSfvv73vv71teO+/ve+/vRcX77+977+9fiI177+9Je+/ve+/vQ/vv71r1KIkIxHvv73vv73vv73vv71z77+9YO+/vRtbCS/vv73vv73vv71ESO+/vWA477+9Fe+/vT0mZyDvv70zau+/vQ3vv73vv73vv73vv70v77+9U2pbZO+/vWMzd++/vToHLFbvv73vv70PIQ7aunMZT++/ve+/vTZ/77+977+9Vdmn77+977+9MkLvv73vv73vv71x77+9fu+/vVLvv70b77+977+9QiQSKu+/vQ8d77+9Te+/vV5j77+9S++/vRdQ77+977+977+977+977+977+977+9CQc377+9dXUhMe+/vQHvv70w77+9Ae+/vQIBATDvv73vv70w77+977+9MQswCQYDVQQGEwJVUzETMBEGA1UECgwKQXBwbGUgSW5jLjEsMCoGA1UECwwjQXBwbGUgV29ybGR3aWRlIERldmVsb3BlciBSZWxhdGlvbnMxRDBCBgNVBAMMO0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENlcnRpZmljYXRpb24gQXV0aG9yaXR5AggO77+9V++/ve+/vQnvv70wCQYFKw4DAhoFADANBgkq77+9SO+/ve+/vQ0BAQEFAATvv70BAH81AO+/vT7vv71LW++/vXU8HFzutpzvv73Mnu+/vR/vv70tPcyW77+9ce+/ve+/ve+/ve+/vQsbKe+/vUbvv73vv70877+9Ehfvv706e143Ou+/vT4E77+9Bu+/vRTvv71sMe+/ve+/vWMlLe+/ve+/vSYa77+9Dj3vv73vv70C77+9PUoA77+977+9Sj3Nk++/ve+/vRfvv70JakLvv71UGu+/vXxT77+977+9c0NJ77+9Kwjvv73vv70AGHTvv70QMWMr77+9P++/ve+/vU0jLe+/vVvvv73vv71XEe+/vc6q77+977+9RO+/vQbvv73vv70/Ou+/vX8a77+977+977+977+9BO+/ve+/vRxzZXnvv73vv73vv70YRTfvv71kW++/vUB6NWrvv73vv71CZ++/vULvv71jTFsJH++/vRV0wp/vv73vv70v77+9Hu+/vXnvv73vv73vv70UJu+/vQHvv70477+9Y0wgbe+/ve+/vQx0NO+/vVDevO+/vVxo77+9T3UZL3vvv71BUHHvv71nG++/ve+/vW0I77+9Xe+/ve+/vQjvv70377+9Ge+/ve+/vStSfGPvv73WrXI=
Also, here is the result of let receiptURL = inAppPurchase.getReceiptURL()
:
/Applications/MAMP/htdocs/email-snippets/node_modules/electron/dist/Electron.app/Contents/_MASReceipt/receipt
The server-side works and receiptRaw.toString('base64')
is correct.
If I send the following to https://sandbox.itunes.apple.com/verifyReceipt/ I get "status": 0
(so it works).
{
"receipt-data": "MIITvQYJKoZIhvcNAQcCoIITrjCCE6oCAQExCzAJBgUrDgMCGgUAMIIDXgYJKoZIhvcNAQcBoIIDTwSCA0sxggNHMAoCAQgCAQEEAhYAMAsCAQECAQEEAwIBADALAgELAgEBBAMCAQAwCwIBDgIBAQQDAgEBMAsCAQ8CAQEEAwIBADALAgEQAgEBBAMCAQAwCwIBGQIBAQQDAgECMAwCAQoCAQEEBBYCNCswDAIBDQIBAQQEAgJPsDANAgETAgEBBAUMAzEuMDAOAgEJAgEBBAYCBFAyNTAwDwIBAwIBAQQHDAUzLjEuMDAYAgEEAgECBBDZH25y3AVp0DiRwqCbmOYUMBsCAQACAQEEEwwRUHJvZ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QgY2VydGlmaWNhdGlvbiBwcmFjdGljZSBzdGF0ZW1lbnRzLjANBgkqhkiG9w0BAQUFAAOCAQEAXDaZTC14t+2Mm9zzd5vydtJ3ME/BH4WDhRuZPUc38qmbQI4s1LGQEti+9HOb7tJkD8t5TzTYoj75eP9ryAfsfTmDi1Mg0zjEsb+aTwpr/yv8WacFCXwXQFYRHnTTt4sjO0ej1W8k4uvRt3DfD0XhJ8rxbXjt57UXF6jcfiI1yiXV2Q/Wa9SiJCMR96Gsj3OBYMYbWwkvkrL4REjwYDieFfU9JmcgijNq9w2Cz97roy/5U2pbZMBjM3f3OgcsVuvaDyEO2rpzGU+12TZ/wYdV2aeZuTJC+9jVcZ5+oVK3G72TQiQSKscPHbZNnF5jyEuAF1CqitXa5PzQCQc3sHV1ITGCAcswggHHAgEBMIGjMIGWMQswCQYDVQQGEwJVUzETMBEGA1UECgwKQXBwbGUgSW5jLjEsMCoGA1UECwwjQXBwbGUgV29ybGR3aWRlIERldmVsb3BlciBSZWxhdGlvbnMxRDBCBgNVBAMMO0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENlcnRpZmljYXRpb24gQXV0aG9yaXR5AggO61eH554JjTAJBgUrDgMCGgUAMA0GCSqGSIb3DQEBAQUABIIBADI4d1kkuyKPadpuUOsloajh0qAe7imW3ezfSwdmAyGVPqLgm8sXYrms3oP9DQUp1280UZP+ZStjGxSHL++u1zl33v/Gbl1KOM+QPuPtj49967l9VqOlzI2Pm1uxBOa8ztqIpU/fdO5GMapJAyJ95If/BgrXLvb7dqNCOSjAZnqBXbCjucr2natn9xSg1ug++Qdck+cJaOt7QyKE3blhr7PoVnUpEmRlYy4XnaOja8I/Ac6n+mhnV7ITnCSfPFnZmAREXcylWxCUvm6RDtR9dNmyWXhhvQDK/vlA9rbGQi7KOrW6y2TuMy2mc8Ircd7qbzGs3GAossD39u7Xs+AUmuA="
}
However, your server decodes the parameter when you call $_GET['res']
.
The GET variables are passed through urldecode(). (http://php.net/manual/en/reserved.variables.get.php)
So what you send to the Apple's verification endpoint is not a base64 encoded receipt.
Moreover, you use $_GET['res']
while you call your server with a POST.
I suggest you to use $res = $_POST['res']
or Content-Type: application/json
instead of application/x-www-form-urlencoded
(see https://www.stevenrombauts.be/2018/06/read-json-request-data-with-php/).