What should be a json transaction validation check?

I am trying to check the sandboxReceipt transaction on https://sandbox.itunes.apple.com/verifyReceipt using php and cURL.

The original receipt, when it arrives at my server, looks like this:

{ "signature" = "AksOP5dmXwg 9WjlcE7PwBEFZgcqBnIb0Uv2lSKebWJJpcOZQRL6ejYyv20MzPFDSgAj3GRGoJXWZpyJLAU8qZSQFYQeGljWKZd3XTJN4j1E7fqOQRBdIXSDRJr1phB/11xp smk6m ... dgcxRHuOMZ2tm8npLUm7argOSzQ=="; "purchase-info" = "ewoJIml0ZW0taWQiID0gIj ... jAiOwp9"; "pod" = "100"; "signing-status" = "0"; }

1. Should they have equal and semicolons?

Wrapping this for transmission in the cURL I use:

$receipt = json_encode(array("receipt-data" => base64_encode($transactionReceipt)));

which gives:

{"receipt-data":"ewoJInNpZ25hdHVyZSIgPSAiQ ... <lots more of the same> ... XR1cyIgPSAiMCI7Cn0="} 

This results in: {"status": - 42023} from Apple

If I use:

$receipt = json_encode(array("receipt-data" => $transactionReceipt));

which gives:

{"receipt-data":"{\n\t\"signature\" = \"AksOP5dmXwg 9WjlcE7PwBEFZgcqBnIb0Uv2lSKebWJJpcOZQRL6ejYyv20MzPFDSgAj3GRGoJXWZpyJLAU8qZSQFYQeGljWKZd3XTJN4j1E7fqOQRBdIXSDRJr1phB\/11xp smk6m ... dgcxRHuOMZ2tm8npLUm7argOSzQ==\";\n\t\"purchase-info\" = \"ewoJIml0ZW0taWQiID0gIjM3NTgyNzIyOCI7Cgkib3JpZ2luYWwtdHJhbnNhY3Rpb24taWQiID0gIjEwMDAwMDAwMDA1ODQyNDIiOwoJInB1cmNoYXNlLWRhdGUiID0gIj ... jAiOwp9\";\n\t\"pod\" = \"100\";\n\t\"signing-status\" = \"0\";\n}"}

I get: {"status": 21002, "exception": "java.lang.IllegalArgumentException: Error parsing property list while trying to read a string without quotes No valid characters found: column: 0." }

2. -, , , - json?

!

+3
2

... :

$dataToPost = json_encode(array("receipt-data" => $receivedData));

$receivedData​​strong > - base64.

:

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $dataToPost
    )
);

$context  = stream_context_create($opts);
$result = file_get_contents('https://sandbox.itunes.apple.com/verifyReceipt', false, $context);

... !

+5

! , . Ooops:( ​​ 4 , stackoverflow . , , .

0

Source: https://habr.com/ru/post/1753714/


All Articles