PHP code example of transferzero / transferzero-php-sdk
1. Go to this page and download the library: Download transferzero/transferzero-php-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
transferzero / transferzero-php-sdk example snippets
TransferZero\Configuration::getDefaultConfiguration()
->setHost("https://api-sandbox.transferzero.com/v1")
->setApiKey("<key>")
->setApiSecret("<secret>");
$apiInstance = new TransferZero\Api\APILogsApi();
$api_log_id = 'api_log_id_example'; // string | ID of the API log to retrieve Example: `/v1/api_logs/00485ce9-532b-45e7-8518-7e5582242407`
try {
$result = $apiInstance->getApiLog($api_log_id);
print_r($result);
} catch (Exception $e) {
if ($e->isValidationError()) {
$response = $e->getResponseObject();
echo "Validation error(s) occurred when calling the endpoint";
print_r($response);
} else {
echo "An exception occurred when calling APILogsApi#getApiLog";
echo $e->getMessage();
}
}
$webhook_content = "{ (...) }"; // The string received through the webhook callback url
$webhook_headers = [
"Authorization-Nonce" => "<authorization-nonce>",
"Authorization-Key" => "<authorization-key>",
"Authorization-Signature" => "<authorization-signature>"
]; // The headers from the webook callback url
$webhook_url = "<url>"; // The url of the webhook callback
$webhooksApi = new TransferZero\Api\WebhooksApi();
if (!$webhooksApi->validateWebhookRequest($webhook_url, $webhook_content, $webhook_headers)) {
echo "Webhook request validation failed";
return false;
}
$webhook = $webhooksApi->parseResponseString($webhook_content, 'Webhook');
if (strpos($webhook->getEvent(), 'transaction') === 0) {
$transactionWebhook = $webhooksApi->parseResponseString($webhook_content, 'TransactionWebhook');
print_r($transactionWebhook->getObject()->__toString());
} elseif (strpos($webhook->getEvent(), 'recipient') === 0) {
$recipientWebhook = $webhooksApi->parseResponseString($webhook_content, 'RecipientWebhook');
print_r($recipientWebhook->getObject()->__toString());
} elseif (strpos($webhook->getEvent(), 'payout_method') === 0) {
$payoutMethodWebhook = $webhooksApi->parseResponseString($webhook_content, 'PayoutMethodWebhook');
print_r($payoutMethodWebhook->getObject()->__toString());
} elseif (strpos($webhook->getEvent(), 'sender') === 0) {
$senderWebhook = $webhooksApi->parseResponseString($webhook_content, 'SenderWebhook');
print_r($senderWebhook->getObject()->__toString());
} elseif (strpos($webhook->getEvent(), 'document') === 0) {
$documentWebhook = $webhooksApi->parseResponseString($webhook_content, 'DocumentWebhook');
print_r($documentWebhook->getObject()->__toString());
}
composer