PHP code example of dealt / dealt-sdk

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

    

dealt / dealt-sdk example snippets


use Dealt\DealtSDK\DealtClient;
use Dealt\DealtSDK\DealtEnvironment;

$client = new DealtClient([
    "api_key" => "secret_dealt_api_key",
    "env" => DealtEnvironment::$PRODUCTION
]);

/** @var Dealt\DealtSDK\GraphQL\Types\Object\OfferAvailabilityQuerySuccess */
$offer = $client->offers->availability([
    'offer_id' => 'your-offer-uuid',
    'address'  => [
        'country' => 'France',
        'zip_code' => '75016',
    ]
]);

$available = $offer->available;

/** @var Dealt\DealtSDK\GraphQL\Types\Object\Money */
$net_price = $offer->net_price;

/** @var Dealt\DealtSDK\GraphQL\Types\Object\Money */
$gross_price = $offer->gross_price;

/** @var Dealt\DealtSDK\GraphQL\Types\Object\Money */
$vat_price = $offer->vat_price;

/** @var Dealt\DealtSDK\GraphQL\Types\Object\MissionQuerySuccess */
$result = $client->missions->get("your-mission-id");

/** @var Dealt\DealtSDK\GraphQL\Types\Object\Mission */
$mission = $result->mission;

/** @var Dealt\DealtSDK\GraphQL\Types\Object\Offer */
$offer = $mission->offer;

/** @var Dealt\DealtSDK\GraphQL\Types\Object\MissionsQuerySuccess */
$result = $client->missions->all();

/** @var Dealt\DealtSDK\GraphQL\Types\Object\Mission[] */
$missions = $result->missions;

/** @var Dealt\DealtSDK\GraphQL\Types\Object\SubmitMissionMutationSuccess */
$result = $client->missions->submit([
    "offer_id" => "your-offer-id",
    "address" => [
        "country" => "France",
        "zip_code" => "92190",
        "city" => "Antony",
        "street1" => "XX Rue de la Paix"
    ],
    "customer" => [
        "first_name" => "John",
        "last_name" => "Doe",
        "email_address" => "[email protected]",
        "phone_number" => "+33700000000"
    ],
    "webHookUrl" => "https://optional.webhook.url",
    "extraDetails" => "https://test-shop.com/optional/product.html"
]);

/** @var Dealt\DealtSDK\GraphQL\Types\Object\Mission */
$mission = $result->mission;

/** @var Dealt\DealtSDK\GraphQL\Types\Object\CancelMissionMutationSuccess */
$result = $client->missions->cancel("your-mission-id");

/** @var Dealt\DealtSDK\GraphQL\Types\Object\Mission */
$mission = $result->mission;