<?php // make sure you place the purchasedat_sdk.php file is present on your server require_once 'purchasedat_sdk.php'; $apiKey = 'REPLACE_WITH_API_KEY'; $apiClient = new PurchasedAt\APIClient($apiKey); $result = $apiClient->parseTransactionNotificationForRequest(); if (!$result->success) { error_log(sprintf('failed to process notification: %s'), $result->errorCode); die('failed to handle request'); } $notification = $result->result; error_log(sprintf('transaction: %s, external transaction: %s, new state: %s, revision number: %d, timestamp: %s, test: %s', $notification->getTransactionId(), $notification->getExternalTransactionId(), $notification->getNewState(), $notification->getRevisionNumber(), date('c', $notification->getTimestamp()), $notification->isTest() ? 'true' : 'false'), 0); // react to transaction status accordingly // (e.g. provision service, write to database) // in order to access more transaction details simply fetch the transaction $result = $apiClient->fetchTransaction($notification->getTransactionId()); if (!$result->success) { error_log(sprintf('failed to fetch transaction: %s'), $result->errorCode); die('failed to handle request'); } $transaction = $result->result; // acknowledge the transaction notification (writes a corresponding response) $apiClient->acknowledgeTransactionNotification();