/** * Get a payment info structure from a TOKEN */ function get_payment($token) { require_once 'payson/lib/paysonapi.php'; $credentials = new PaysonCredentials(PAYSON_AGENT_ID, PAYSON_API_KEY); $api = new PaysonApi($credentials, IS_TEST); $response = $api->paymentDetails(new PaymentDetailsData($token)); if (!$response->getResponseEnvelope()->wasSuccessful()) { return false; } return payment_details_to_structure($response->getPaymentDetails()); }
<?php error_reporting(E_ALL); ini_set("display_errors", 1); require '../lib/paysonapi.php'; // Your agent ID and md5 key $agentID = "4"; $md5Key = "2acab30d-fe50-426f-90d7-8c60a7eb31d4"; // Fetch the token that are returned $token = $_GET["TOKEN"]; // Initialize the API in test mode $credentials = new PaysonCredentials($agentID, $md5Key); $api = new PaysonApi($credentials, TRUE); // Get the details about this purchase $detailsResponse = $api->paymentDetails(new PaymentDetailsData($token)); // First we verify that the call to payson succeeded. if ($detailsResponse->getResponseEnvelope()->wasSuccessful()) { // Get the payment details from the response $details = $detailsResponse->getPaymentDetails(); // If the call to Payson went well we also have to check the actual status // of the transfer if ($details->getType() == "TRANSFER" && $details->getStatus() == "COMPLETED") { echo "Purchase has been completed <br /><h4>Details</h4><pre>" . $details . "</pre>"; } elseif ($details->getType() == "INVOICE" && $details->getInvoiceStatus() == "ORDERCREATED") { echo "Invoice has been created <br /><h4>Details</h4><pre>" . $details . "</pre>"; } else { if ($details->getStatus() == "ERROR") { echo "An error occured has occured <br /><h4>Details</h4><pre>" . $details . "</pre>"; } } /* Below are the other data that can be retreived from payment details