2 if (!isset($_POST['blob'])) {
3 echo "blob key missing in POST data\n";
6 $innerJson = base64_decode($_POST['blob']);
8 $inner = json_decode($innerJson);
10 echo "Error decoding inner JSON data\n";
13 $buyRequest = json_decode(base64_decode($inner->blob));
14 if ($buyRequest === null) {
15 echo "Error decoding encrypted inner JSON data\n";
18 if (!isset($buyRequest->uuid)) {
19 echo "uuid key missing in JSON data\n";
22 if (!isset($buyRequest->identifier)) {
23 echo "identifier key missing in JSON data\n";
27 ini_set('html_errors', false);
30 __DIR__ . '/../developers/*/products/'
31 . $buyRequest->identifier . '.json'
33 if (!count($productFiles)) {
34 echo "Cannot find product file for product identifier\n";
37 $product = json_decode(file_get_contents($productFiles[0]))->products[0];
38 if ($product === null) {
39 echo "could not find product in purchases file\n";
44 $payload->uuid = $buyRequest->uuid;
46 //"god of blades" and "pinball arcade" want double-encrypted responses
47 // muffin knights works with single encryption
49 'key' => base64_encode('0123456789abcdef'),
50 'iv' => 't3jir1LHpICunvhlM76edQ==',//random bytes
51 'blob' => base64_encode(
52 json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
57 'key' => base64_encode('0123456789abcdef'),
58 'iv' => 't3jir1LHpICunvhlM76edQ==',//random bytes
59 'blob' => base64_encode(
60 json_encode($enc1, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
63 echo json_encode($enc2, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";