Skip to content

Instantly share code, notes, and snippets.

@miniplay
miniplay / mpS2SItemValidationHandlingSample.php
Last active August 29, 2015 14:00
Sample on how to pre-validate item purchases with our Server 2 Server notifications.
<?php
/* ---- PLEASE MAKE SURE YOUR ENCODING IS: UTF-8 (without BOM) ---- */
$jsonString = file_get_contents("php://input"); /* Get the RAW POST DATA */
/* Validate signature */
if ( ! ( isset($_SERVER['HTTP_MINI_SIGNATURE'])
&& $_SERVER['HTTP_MINI_SIGNATURE'] == md5("[YOUR_API_KEY]".$jsonString) )) {
throw new Exception("Invalid signature");
}
/* Decode the JSON string received and convert it to an associative array */