1. Go to this page and download the library: Download friendz/orderz-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/ */
friendz / orderz-php-sdk example snippets
use Friendz\Orderz\Api\Client as OrderzClient;
use Friendz\Orderz\Api\Models\User as UserModel;
use Friendz\Orderz\Api\Requests\CreateOrder as CreateOrderRequest;
function foo(): array
{
$client = new OrderzClient('api-token');
return $client->getProducts();
}
function bar(int $productId)
{
$client = new OrderzClient('api-token');
$orderRequest = new CreateOrderRequest;
$orderRequest->externalId = 'your-unique-id';
$orderRequest->productId = $productId;
$orderRequest->quantity = 1;
$orderRequest->user = new UserModel(
'John',
'Doe',
'[email protected]',
'Sesame Street, 1119'
);
$client->createOrder($orderRequest);
}
function foo(int $productId)
{
/**
* ...
*/
$shouldRetry = true;
/* NB: Don't use this code in production! */
do {
try {
$response = $client->createOrder($orderRequest);
$shouldRetry = false;
} catch (ApiException | MalformedResponseException $e) {
$shouldRetry = $e->shouldRetry();
}
} while($shouldRetry);
/* Use $response somehow */
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.