getMessage()); } $validationURL = isset($postedData['validationURL']) ? filter_var($postedData['validationURL'], FILTER_SANITIZE_URL) : ''; $URLcomponents = parse_url($validationURL); if (!isset($URLcomponents['scheme']) || !isset($URLcomponents['host'])) die('The validation URL is not valid.'); if ('https' !== strtolower($URLcomponents['scheme'])) die('The validation URL scheme is not valid.'); $validationHost = strtolower($URLcomponents['host']); if (!('apple.com' === $validationHost || '.apple.com' === substr($validationHost, -10))) die('The validation URL host is not valid.'); $merchantIdentifier = isset($postedData['merchantIdentifier']) ? $postedData['merchantIdentifier'] : MERCHANT_IDENTIFIER; $displayName = isset($postedData['displayName']) ? $postedData['displayName'] : DISPLAY_NAME; $intiative = isset($postedData['intiative']) ? $postedData['intiative'] : INITIATIVE; $intiativeContext = isset($postedData['intiativeContext']) ? $postedData['intiativeContext'] : INITIATIVE_CONTEXT; $postData = array( 'merchantIdentifier' => $merchantIdentifier, 'displayName' => $displayName, 'domainName' => $intiativeContext, 'initiative' => $intiative, 'initiativeContext' => $intiativeContext ); $postDataFields = json_encode($postData); $curlOptions = array( CURLOPT_URL => $validationURL, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postDataFields, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSLCERT => MERCHANT_IDENTITY_CERTIFICATE, CURLOPT_SSLKEY => MERCHANT_IDENTITY_KEY, CURLOPT_SSLKEYPASSWD => MERCHANT_IDENTITY_KEY_PASS, CURLOPT_SSLKEYPASSWD => MERCHANT_IDENTITY_KEY_PASS, CURLOPT_SSL_VERIFYPEER => true ); $curlConnection = curl_init(); curl_setopt_array($curlConnection, $curlOptions); if (!$result = curl_exec($curlConnection)) die('An error occurred when connecting to the validation URL.')); curl_close($curlConnection); header('Content-Type: application/json'); echo $result; exit();