-
Notifications
You must be signed in to change notification settings - Fork 796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/verifyReceipt
endpoint is forbidden by Apple
#490
Comments
Hi @gerchicov-bp, |
@canhth the problem I faced is another one - my customers want to have a possibility to move apps from a publisher to another and it is not possible when receipts are checked with remote server. |
Yes, you are correct, Apple says:
This can actually be fixed rather easily. Look at the struct So in my case, I am using PHP so I make a new PHP page that mimics exactly what apple's <?php
header('Content-type: application/json');
$encoded = file_get_contents('php://input');
$data = json_decode($encoded, true);
const APPLE_SHARED_SECRET = "<insert your shared secret here>";
const APPLE_RECEIPT_VERIFY_URL = "https://buy.itunes.apple.com/verifyReceipt";
const APPLE_SANDBOX_RECEIPT_VERIFY_URL = "https://sandbox.itunes.apple.com/verifyReceipt";
$request = json_encode(array("receipt-data" => $data["receipt-data"],"password"=>APPLE_SHARED_SECRET));
$ch = curl_init(APPLE_RECEIPT_VERIFY_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$jsonresult = curl_exec($ch);
$jsonresult = json_decode($jsonresult);
$http_status = $jsonresult->status;
curl_close($ch);
if($http_status == 21007){
$ch = curl_init(APPLE_SANDBOX_RECEIPT_VERIFY_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$jsonresult = curl_exec($ch);
$jsonresult = json_decode($jsonresult);
$http_status = $jsonresult->status;
curl_close($ch);
}
echo json_encode($jsonresult);
?> Create a new struct that conforms to the case custom = "https://www.mywebsite.com/verifyReceipt.php" Now change the default if receiptStatus == .valid {
// The receipt is valid...
} Since we check for the I hope this helps someone 🥂 ! |
Platform
In-app purchase type
Environment
Version
Latest (0.15.0), maybe all versions
Related issues
Report
Issue summary
What did you expect to happen
verifyReceipt
endpoint is not used (how it is explained in the official Apple documentation)What happened instead
verifyReceipt
endpoint is usedThe text was updated successfully, but these errors were encountered: