1. Go to this page and download the library: Download ibercheck/ibercheck-api-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/ */
ibercheck / ibercheck-api-sdk example snippets
$hash = Ibercheck\Api\Sale::createSaleHash(
's3cr3t', // Affiliate Secret
'ABCD_123456', // Order number
'autocheck' // Product mnemonic
);
if(!Ibercheck\Api\Webhook::isAuthentic(
's3cr3t', // Affiliate Secret
'596f6838cb5b....ae812fb62f91c6', // Value of `X-Ibercheck-Signature` header
'{....}' // Webhook payload
)
) {
throw new Exception('Fraudulent webhook received');
}
// Exchange affiliate credentials with a private access token.
$oAuthRequest = new Ibercheck\Api\ApiRequest('POST', 'http://api_dev.ibercheck.net/oauth');
$oAuthRequest = $oAuthRequest->withJsonSerializableData(
[
'grant_type' => 'client_credentials',
'client_id' => 'ACME_SL', // Affiliate Name
'client_secret' => 's3cr3t', // Affiliate Secret
]
);
$oAuthResponsePayload = sendRequestToApi($oAuthRequest);
// Use the new private access token for authenticate your API requests.
$meRequest = new Ibercheck\Api\ApiRequest('GET', 'http://api_dev.ibercheck.net/me');
$meRequest = $meRequest->withAuthentication($oAuthResponsePayload['access_token']);
$meResponsePayload = sendRequestToApi($meRequest);
print_r($meResponsePayload);
function sendRequestToApi(Psr\Http\Message\RequestInterface $request) {
$psr18HttpClient = new Psr\Http\Client\ClientInterface();
$ibercheckApiClient = new Ibercheck\Api\Client($psr18HttpClient);
try {
$response = $ibercheckApiClient->sendRequest($request);
$payload = $ibercheckApiClient->decodeResponseBody((string) $response->getBody());
} catch (Ibercheck\Api\ApiCommunicationException $apiCommunicationException) {
// A network error has occurred while sending the request or receiving the response.
// Retry
} catch (Ibercheck\Api\DeserializeException $deserializationException) {
// Nobody knows when this happen, may an HTTP Proxy on our side or on your side started to return HTML responses with errors.
// Retry
} catch (Ibercheck\Api\ApiServerException $apiServerException) {
// Our server has crashed. We promise to fix it ASAP.
echo 'Error code', $apiClientException->getStatus(), PHP_EOL;
echo 'Error type', $apiClientException->getType(), PHP_EOL;
echo 'Error message', $apiClientException->getMessage(), PHP_EOL;
echo 'Error detail', var_export($apiClientException->getDetail(), true), PHP_EOL;
} catch (Ibercheck\Api\ApiClientException $apiClientException) {
// Your client has sent an invalid request. Please check your code.
echo 'Error code', $apiClientException->getStatus(), PHP_EOL;
echo 'Error type', $apiClientException->getType(), PHP_EOL;
echo 'Error message', $apiClientException->getMessage(), PHP_EOL;
echo 'Error detail', var_export($apiClientException->getDetail(), true), PHP_EOL;
}
return $payload;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.