PHP code example of codefit / vl-conversion

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

    

codefit / vl-conversion example snippets


use VaseLekarny\Conversion;

$conversion = new Conversion();
$conversion->setApiKey('your-api-key');

try {
    $result = $conversion->sendConversion([
        // Your conversion data here
    ]);

    // Process the result
} catch (\VaseLekarny\Exceptions\ApiException $e) {
    // Handle API errors
    $errorResponse = $e->getResponse();
}

$conversionData = [
    'order_id' => '12345',           // Required: Unique identifier of the order
    'customer' => [                   // Required: Customer information
        'email' => '[email protected]', // Required: Customer's email address
        'name' => 'John Doe'          // Required: Customer's full name
    ],
    'products' => [                   // Required: Array of ordered products
        [
            'id' => 'PROD001',        // Required: Product identifier
            'name' => 'Test Product',  // Required: Product name
            'price' => 199.99,        // Required: Product price (including VAT)
            'quantity' => 1           // Required: Quantity of the product
        ]
    ],
    'total_value' => 199.99          // Required: Total order value (including VAT)
];

try {
    $result = $conversion->sendConversion($data);
} catch (\VaseLekarny\Exceptions\ApiException $e) {
    // Get the error message
    $message = $e->getMessage();

    // Get the full response from the API
    $response = $e->getResponse();
}