PHP code example of sodacards / sdk

1. Go to this page and download the library: Download sodacards/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/ */

    

sodacards / sdk example snippets


$config = Sodacards\Configuration::getDefaultConfiguration()
    ->setApiKey('X-API-Key', getenv('SODACARDS_API_KEY'));



ig = Sodacards\Configuration::getDefaultConfiguration()
    ->setApiKey('X-API-Key', getenv('SODACARDS_API_KEY'));

$api = new Sodacards\Api\DefaultApi(new GuzzleHttp\Client(), $config);

// 1. Discover what you can sell.
$catalog = $api->listCatalog();

// 2. Place an order for one product.
$request = new Sodacards\Model\SodacardsDevpublicV1PlaceOrderRequest([
    'lines' => [
        new Sodacards\Model\SodacardsDevpublicV1OrderLine([
            'product_id' => 'prod_123',
            'quantity'   => 1,
        ]),
    ],
    'reference' => 'my-internal-ref-0001',
]);
$order = $api->placeOrder($request);

// 3. Read back the delivered codes once the order is fulfilled.
$codes = $api->revealOrderCodes($order->getOrder()->getId());
print_r($codes);