Skip to main content

Overview

The Devdraft PHP SDK provides a complete client library for integrating payment processing, customer management, and webhook functionality into your PHP applications.

PSR-7 Compatible

Uses Guzzle HTTP client for reliable API communication

Composer Support

Easy installation via Composer package manager

Comprehensive

Access to all Devdraft API endpoints and features

Modern PHP

Built for PHP 8.1+ with type hints and modern features

Installation

Using Composer

composer require devdraftengineer/php
Or add to your composer.json:
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/devdraftengineer/php.git"
    }
  ],
  "require": {
    "devdraftengineer/php": "*@dev"
  }
}
Then run:
composer install

Requirements

  • PHP 8.1 or higher
  • Composer
  • Guzzle HTTP client (automatically installed)

Quick Start

<?php
require_once(__DIR__ . '/vendor/autoload.php');

use Devdraft\Configuration;
use Devdraft\Api\TransfersApi;
use Devdraft\Api\WebhooksApi;
use Devdraft\Model\CreateDirectWalletTransferDto;
use GuzzleHttp\Client;

// Configure API credentials
$config = Configuration::getDefaultConfiguration()
    ->setApiKey('x-client-key', getenv('DEVDRAFT_CLIENT_KEY'))
    ->setApiKey('x-client-secret', getenv('DEVDRAFT_CLIENT_SECRET'))
    ->setHost('https://api.devdraft.ai');

// Create API instances
$httpClient = new Client();
$transfersApi = new TransfersApi($httpClient, $config);
$webhooksApi = new WebhooksApi($httpClient, $config);

try {
    // Create a transfer
    $transferDto = new CreateDirectWalletTransferDto([
        'wallet_id' => 'your-wallet-id',
        'network' => 'solana',
        'stable_coin_currency' => 'usdc',
        'amount' => 100.00
    ]);
    
    $transfer = $transfersApi->transferControllerCreateDirectWalletTransfer($transferDto);
    echo "Transfer created: " . $transfer->getId() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

API Classes

The SDK is organized into API classes, each handling a specific domain:
API ClassDescription
APIHealthApiService health checks and status monitoring
AppBalancesApiQuery application balances across stablecoins
CustomersApiCustomer management and KYC operations
ExchangeRatesApiReal-time currency exchange rates
InvoicesApiInvoice creation and management
LiquidationAddressesApiCryptocurrency liquidation addresses
PaymentIntentsApiPayment intent creation for bank and stablecoin
PaymentLinksApiGenerate and manage payment links
ProductsApiProduct catalog management
TaxesApiTax configuration and management
TestPaymentsApiTest payment processing in sandbox
TransfersApiInitiate and manage fund transfers
WalletsApiWallet management and balances
WebhooksApiWebhook configuration and management

API Health

Monitor service health and availability.

Methods

healthControllerCheckV0()

Authenticated health check endpoint requiring API credentials.
<?php
require_once(__DIR__ . '/vendor/autoload.php');

use Devdraft\Api\APIHealthApi;
use GuzzleHttp\Client;

$config = Devdraft\Configuration::getDefaultConfiguration()
    ->setApiKey('x-client-key', getenv('DEVDRAFT_CLIENT_KEY'))
    ->setApiKey('x-client-secret', getenv('DEVDRAFT_CLIENT_SECRET'));

$apiInstance = new APIHealthApi(new Client(), $config);

try {
    $apiInstance->healthControllerCheckV0();
    echo "Service is healthy and authenticated\n";
} catch (Exception $e) {
    echo "Health check failed: " . $e->getMessage() . "\n";
}
Returns: void

healthControllerPublicHealthCheckV0()

Public health check endpoint (no authentication required).
$status = $apiInstance->healthControllerPublicHealthCheckV0();
echo "Service status: " . $status->getStatus() . "\n";
Returns: \Devdraft\Model\PublicHealthResponseDto

App Balances

Query your application’s stablecoin balances.

Methods

balanceControllerGetAllBalances()

Get all stablecoin balances for your application.
<?php
use Devdraft\Api\AppBalancesApi;
use GuzzleHttp\Client;

$apiInstance = new AppBalancesApi(new Client(), $config);

try {
    $balances = $apiInstance->balanceControllerGetAllBalances();
    echo "USDC Balance: " . $balances->getUsdc() . "\n";
    echo "EURC Balance: " . $balances->getEurc() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Returns: \Devdraft\Model\AllBalancesResponse

balanceControllerGetUSDCBalance()

Get USDC balance only.
$usdcBalance = $apiInstance->balanceControllerGetUSDCBalance();
echo "USDC: " . $usdcBalance->getAmount() . "\n";
Returns: \Devdraft\Model\AggregatedBalanceResponse

balanceControllerGetEURCBalance()

Get EURC balance only.
$eurcBalance = $apiInstance->balanceControllerGetEURCBalance();
echo "EURC: " . $eurcBalance->getAmount() . "\n";
Returns: \Devdraft\Model\AggregatedBalanceResponse

Customers

Manage customer records and KYC information.

Methods

customerControllerCreate($create_customer_dto)

Create a new customer.
<?php
use Devdraft\Api\CustomersApi;
use Devdraft\Model\CreateCustomerDto;
use GuzzleHttp\Client;

$apiInstance = new CustomersApi(new Client(), $config);

try {
    $customerDto = new CreateCustomerDto([
        'first_name' => 'John',
        'last_name' => 'Doe',
        'email' => 'john.doe@example.com',
        'type' => 'INDIVIDUAL',
        'country' => 'US'
    ]);
    
    $customer = $apiInstance->customerControllerCreate($customerDto);
    echo "Customer created: " . $customer->getId() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $create_customer_dto: \Devdraft\Model\CreateCustomerDto - Customer details
Returns: \Devdraft\Model\Customer

customerControllerFindAll($page, $limit, $status)

Get all customers with optional filters.
$page = 1;
$limit = 20;
$status = 'ACTIVE';

try {
    $customers = $apiInstance->customerControllerFindAll($page, $limit, $status);
    
    foreach ($customers as $customer) {
        echo $customer->getFirstName() . " " . $customer->getLastName() . " - " . $customer->getEmail() . "\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $page: int - Page number (optional, default: 1)
  • $limit: int - Items per page (optional, default: 20)
  • $status: string - Filter by status (optional)
Returns: \Devdraft\Model\Customer[]

customerControllerFindOne($id)

Get a customer by ID.
$customer = $apiInstance->customerControllerFindOne('customer-id-here');
echo "Customer: " . $customer->getFirstName() . " " . $customer->getLastName() . "\n";
Parameters:
  • $id: string - Customer ID
Returns: \Devdraft\Model\Customer

customerControllerUpdate($id, $update_customer_dto)

Update a customer’s information.
use Devdraft\Model\UpdateCustomerDto;

$updateDto = new UpdateCustomerDto([
    'phone' => '+1234567890',
    'address' => '123 Main St'
]);

$updated = $apiInstance->customerControllerUpdate('customer-id-here', $updateDto);
echo "Customer updated: " . $updated->getId() . "\n";
Parameters:
  • $id: string - Customer ID
  • $update_customer_dto: \Devdraft\Model\UpdateCustomerDto - Fields to update
Returns: \Devdraft\Model\Customer

Exchange Rates

Get real-time currency exchange rates.

Methods

exchangeRateControllerGetExchangeRate($from, $to)

Get exchange rate between any two supported currencies.
<?php
use Devdraft\Api\ExchangeRatesApi;
use GuzzleHttp\Client;

$apiInstance = new ExchangeRatesApi(new Client(), $config);

try {
    $rate = $apiInstance->exchangeRateControllerGetExchangeRate('USD', 'EUR');
    
    echo "1 USD = " . $rate->getRate() . " EUR\n";
    echo "Rate expires at: " . $rate->getExpiresAt() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $from: string - Source currency code
  • $to: string - Target currency code
Returns: \Devdraft\Model\ExchangeRateResponseDto

exchangeRateControllerGetUSDToEURRate()

Get USD to EUR exchange rate.
$usdToEur = $apiInstance->exchangeRateControllerGetUSDToEURRate();
echo "USD to EUR: " . $usdToEur->getRate() . "\n";
Returns: \Devdraft\Model\ExchangeRateResponseDto

exchangeRateControllerGetEURToUSDRate()

Get EUR to USD exchange rate.
$eurToUsd = $apiInstance->exchangeRateControllerGetEURToUSDRate();
echo "EUR to USD: " . $eurToUsd->getRate() . "\n";
Returns: \Devdraft\Model\ExchangeRateResponseDto

Invoices

Create and manage invoices for your customers.

Methods

invoiceControllerCreate($create_invoice_dto)

Create a new invoice.
<?php
use Devdraft\Api\InvoicesApi;
use Devdraft\Model\CreateInvoiceDto;
use GuzzleHttp\Client;

$apiInstance = new InvoicesApi(new Client(), $config);

try {
    $invoiceDto = new CreateInvoiceDto([
        'customer_id' => 'customer-id',
        'items' => [
            [
                'description' => 'Premium Subscription',
                'quantity' => 1,
                'price' => 99.99,
                'currency' => 'USD'
            ]
        ],
        'due_date' => '2024-12-31'
    ]);
    
    $invoice = $apiInstance->invoiceControllerCreate($invoiceDto);
    echo "Invoice created: " . $invoice->getId() . "\n";
    echo "Total: " . $invoice->getTotal() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $create_invoice_dto: \Devdraft\Model\CreateInvoiceDto - Invoice details
Returns: \Devdraft\Model\Invoice

invoiceControllerFindAll($page, $limit, $status)

Get all invoices.
$invoices = $apiInstance->invoiceControllerFindAll(1, 50, 'UNPAID');

foreach ($invoices as $invoice) {
    echo "Invoice " . $invoice->getId() . ": " . $invoice->getTotal() . "\n";
}
Parameters:
  • $page: int - Page number (optional)
  • $limit: int - Items per page (optional)
  • $status: string - Filter by status (optional)
Returns: \Devdraft\Model\Invoice[]

invoiceControllerFindOne($id)

Get an invoice by ID.
$invoice = $apiInstance->invoiceControllerFindOne('invoice-id');
echo "Invoice total: " . $invoice->getTotal() . "\n";
Parameters:
  • $id: string - Invoice ID
Returns: \Devdraft\Model\Invoice

invoiceControllerUpdate($id, $update_invoice_dto)

Update an invoice.
$updateDto = [
    'status' => 'PAID',
    'paid_at' => date('c')
];

$updated = $apiInstance->invoiceControllerUpdate('invoice-id', $updateDto);
echo "Invoice updated: " . $updated->getId() . "\n";
Parameters:
  • $id: string - Invoice ID
  • $update_invoice_dto: array - Fields to update
Returns: \Devdraft\Model\Invoice

Liquidation Addresses

Manage cryptocurrency liquidation addresses for customers.

Methods

liquidationAddressControllerCreateLiquidationAddress($customer_id, $create_liquidation_address_dto)

Create a new liquidation address for a customer.
<?php
use Devdraft\Api\LiquidationAddressesApi;
use Devdraft\Model\CreateLiquidationAddressDto;
use GuzzleHttp\Client;

$apiInstance = new LiquidationAddressesApi(new Client(), $config);

try {
    $addressDto = new CreateLiquidationAddressDto([
        'network' => 'solana',
        'currency' => 'usdc'
    ]);
    
    $address = $apiInstance->liquidationAddressControllerCreateLiquidationAddress(
        'customer-id',
        $addressDto
    );
    
    echo "Liquidation address: " . $address->getAddress() . "\n";
    echo "Network: " . $address->getNetwork() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $customer_id: string - Customer ID
  • $create_liquidation_address_dto: \Devdraft\Model\CreateLiquidationAddressDto - Address details
Returns: \Devdraft\Model\LiquidationAddressResponseDto

liquidationAddressControllerGetLiquidationAddresses($customer_id)

Get all liquidation addresses for a customer.
$addresses = $apiInstance->liquidationAddressControllerGetLiquidationAddresses('customer-id');

foreach ($addresses as $addr) {
    echo $addr->getNetwork() . ": " . $addr->getAddress() . "\n";
}
Parameters:
  • $customer_id: string - Customer ID
Returns: \Devdraft\Model\LiquidationAddressResponseDto[]

liquidationAddressControllerGetLiquidationAddress($customer_id, $liquidation_address_id)

Get a specific liquidation address.
$address = $apiInstance->liquidationAddressControllerGetLiquidationAddress(
    'customer-id',
    'address-id'
);

echo "Address: " . $address->getAddress() . "\n";
Parameters:
  • $customer_id: string - Customer ID
  • $liquidation_address_id: string - Address ID
Returns: \Devdraft\Model\LiquidationAddressResponseDto

Payment Intents

Create payment intents for bank and stablecoin payments.

Methods

paymentIntentControllerCreateBankPaymentIntent($create_bank_payment_intent_dto)

Create a bank payment intent.
<?php
use Devdraft\Api\PaymentIntentsApi;
use Devdraft\Model\CreateBankPaymentIntentDto;
use GuzzleHttp\Client;

$apiInstance = new PaymentIntentsApi(new Client(), $config);

try {
    $intentDto = new CreateBankPaymentIntentDto([
        'customer_id' => 'customer-id',
        'amount' => 1000.00,
        'currency' => 'USD',
        'payment_rail' => 'wire'
    ]);
    
    $intent = $apiInstance->paymentIntentControllerCreateBankPaymentIntent($intentDto);
    echo "Payment intent: " . $intent->getId() . "\n";
    echo "Status: " . $intent->getStatus() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $create_bank_payment_intent_dto: \Devdraft\Model\CreateBankPaymentIntentDto - Intent details
Returns: \Devdraft\Model\PaymentIntent

paymentIntentControllerCreateStablePaymentIntent($create_stable_payment_intent_dto)

Create a stablecoin payment intent.
use Devdraft\Model\CreateStablePaymentIntentDto;

$stableIntentDto = new CreateStablePaymentIntentDto([
    'customer_id' => 'customer-id',
    'amount' => 500.00,
    'currency' => 'usdc',
    'network' => 'solana'
]);

$stableIntent = $apiInstance->paymentIntentControllerCreateStablePaymentIntent($stableIntentDto);
echo "Stable intent: " . $stableIntent->getId() . "\n";
Parameters:
  • $create_stable_payment_intent_dto: \Devdraft\Model\CreateStablePaymentIntentDto - Intent details
Returns: \Devdraft\Model\PaymentIntent
Generate and manage payment links for easy customer payments.

Methods

Create a new payment link.
<?php
use Devdraft\Api\PaymentLinksApi;
use Devdraft\Model\CreatePaymentLinkDto;
use GuzzleHttp\Client;

$apiInstance = new PaymentLinksApi(new Client(), $config);

try {
    $linkDto = new CreatePaymentLinkDto([
        'name' => 'Product Purchase',
        'amount' => 99.99,
        'currency' => 'USD',
        'products' => [
            [
                'name' => 'Premium Plan',
                'quantity' => 1,
                'price' => 99.99
            ]
        ]
    ]);
    
    $link = $apiInstance->paymentLinksControllerCreate($linkDto);
    echo "Payment link: " . $link->getUrl() . "\n";
    echo "Share this link with customers: " . $link->getShortUrl() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $create_payment_link_dto: \Devdraft\Model\CreatePaymentLinkDto - Link details
Returns: \Devdraft\Model\PaymentLink

paymentLinksControllerFindAll($page, $limit, $active)

Get all payment links.
$links = $apiInstance->paymentLinksControllerFindAll(1, 20, true);

foreach ($links as $link) {
    echo $link->getName() . ": " . $link->getUrl() . "\n";
}
Parameters:
  • $page: int - Page number (optional)
  • $limit: int - Items per page (optional)
  • $active: bool - Filter by active status (optional)
Returns: \Devdraft\Model\PaymentLink[]

paymentLinksControllerFindOne($id)

Get a payment link by ID.
$link = $apiInstance->paymentLinksControllerFindOne('link-id');
echo "Link: " . $link->getUrl() . "\n";
Parameters:
  • $id: string - Payment link ID
Returns: \Devdraft\Model\PaymentLink Update a payment link.
$updateDto = [
    'active' => false,
    'expires_at' => '2024-12-31T23:59:59Z'
];

$updated = $apiInstance->paymentLinksControllerUpdate('link-id', $updateDto);
echo "Link updated: " . $updated->getId() . "\n";
Parameters:
  • $id: string - Payment link ID
  • $update_payment_link_dto: array - Fields to update
Returns: \Devdraft\Model\PaymentLink

Products

Manage your product catalog.

Methods

productControllerCreate($create_product_dto)

Create a new product.
<?php
use Devdraft\Api\ProductsApi;
use GuzzleHttp\Client;

$apiInstance = new ProductsApi(new Client(), $config);

try {
    $productDto = [
        'name' => 'Premium Subscription',
        'description' => 'Access to all premium features',
        'price' => 99.99,
        'currency' => 'USD',
        'category' => 'subscriptions'
    ];
    
    $product = $apiInstance->productControllerCreate($productDto);
    echo "Product created: " . $product->getId() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $create_product_dto: array - Product details
Returns: \Devdraft\Model\Product

productControllerFindAll($category, $active)

Get all products.
$products = $apiInstance->productControllerFindAll('subscriptions', true);

foreach ($products as $product) {
    echo $product->getName() . ": $" . $product->getPrice() . "\n";
}
Parameters:
  • $category: string - Filter by category (optional)
  • $active: bool - Filter by active status (optional)
Returns: \Devdraft\Model\Product[]

productControllerFindOne($id)

Get a product by ID.
$product = $apiInstance->productControllerFindOne('product-id');
echo "Product: " . $product->getName() . "\n";
Parameters:
  • $id: string - Product ID
Returns: \Devdraft\Model\Product

productControllerUpdate($id, $update_product_dto)

Update a product.
$updateDto = [
    'price' => 89.99,
    'description' => 'Updated description'
];

$updated = $apiInstance->productControllerUpdate('product-id', $updateDto);
echo "Product updated: " . $updated->getId() . "\n";
Parameters:
  • $id: string - Product ID
  • $update_product_dto: array - Fields to update
Returns: \Devdraft\Model\Product

productControllerRemove($id)

Delete a product.
$apiInstance->productControllerRemove('product-id');
echo "Product deleted\n";
Parameters:
  • $id: string - Product ID
Returns: void

productControllerUploadImage($id, $images)

Upload images for a product.
$images = [
    new \SplFileObject('/path/to/image1.jpg'),
    new \SplFileObject('/path/to/image2.jpg')
];

$product = $apiInstance->productControllerUploadImage('product-id', $images);
echo "Images uploaded for product: " . $product->getId() . "\n";
Parameters:
  • $id: string - Product ID
  • $images: \SplFileObject[] - Image files
Returns: \Devdraft\Model\Product

Taxes

Configure and manage tax settings.

Methods

taxControllerCreate($create_tax_dto)

Create a new tax configuration.
<?php
use Devdraft\Api\TaxesApi;
use Devdraft\Model\CreateTaxDto;
use GuzzleHttp\Client;

$apiInstance = new TaxesApi(new Client(), $config);

try {
    $taxDto = new CreateTaxDto([
        'name' => 'Sales Tax',
        'percentage' => 8.5,
        'country' => 'US',
        'state' => 'CA'
    ]);
    
    $tax = $apiInstance->taxControllerCreate($taxDto);
    echo "Tax created: " . $tax->getId() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $create_tax_dto: \Devdraft\Model\CreateTaxDto - Tax details
Returns: \Devdraft\Model\Tax

taxControllerFindAll($country)

Get all tax configurations.
$taxes = $apiInstance->taxControllerFindAll('US');

foreach ($taxes as $tax) {
    echo $tax->getName() . ": " . $tax->getPercentage() . "%\n";
}
Parameters:
  • $country: string - Filter by country (optional)
Returns: \Devdraft\Model\Tax[]

taxControllerFindOne($id)

Get a tax configuration by ID.
$tax = $apiInstance->taxControllerFindOne('tax-id');
echo "Tax: " . $tax->getName() . "\n";
Parameters:
  • $id: string - Tax ID
Returns: \Devdraft\Model\Tax

taxControllerUpdate($id, $update_tax_dto)

Update a tax configuration.
use Devdraft\Model\UpdateTaxDto;

$updateDto = new UpdateTaxDto(['percentage' => 9.0]);
$updated = $apiInstance->taxControllerUpdate('tax-id', $updateDto);
echo "Tax updated: " . $updated->getId() . "\n";
Parameters:
  • $id: string - Tax ID
  • $update_tax_dto: \Devdraft\Model\UpdateTaxDto - Fields to update
Returns: \Devdraft\Model\Tax

taxControllerRemove($id)

Delete a tax configuration.
$apiInstance->taxControllerRemove('tax-id');
echo "Tax deleted\n";
Parameters:
  • $id: string - Tax ID
Returns: void

Test Payments

Process test payments in sandbox environment.

Methods

testPaymentControllerCreatePaymentV0($payment_request_dto)

Create a test payment.
<?php
use Devdraft\Api\TestPaymentsApi;
use Devdraft\Model\PaymentRequestDto;
use GuzzleHttp\Client;

$apiInstance = new TestPaymentsApi(new Client(), $config);

try {
    $paymentDto = new PaymentRequestDto([
        'amount' => 100.00,
        'currency' => 'USD',
        'customer_id' => 'test-customer-id',
        'idempotency_key' => 'unique-key-123'
    ]);
    
    $payment = $apiInstance->testPaymentControllerCreatePaymentV0($paymentDto);
    echo "Test payment: " . $payment->getId() . "\n";
    echo "Status: " . $payment->getStatus() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $payment_request_dto: \Devdraft\Model\PaymentRequestDto - Payment details
Returns: \Devdraft\Model\PaymentResponseDto

testPaymentControllerGetPaymentV0($id)

Get test payment details by ID.
$payment = $apiInstance->testPaymentControllerGetPaymentV0('payment-id');
echo "Payment status: " . $payment->getStatus() . "\n";
Parameters:
  • $id: string - Payment ID
Returns: \Devdraft\Model\PaymentResponseDto

testPaymentControllerRefundPaymentV0($id, $refund_amount)

Refund a test payment.
$refund = $apiInstance->testPaymentControllerRefundPaymentV0('payment-id', 50.00);
echo "Refund processed: " . $refund->getId() . "\n";
Parameters:
  • $id: string - Payment ID
  • $refund_amount: float - Amount to refund (optional, defaults to full amount)
Returns: \Devdraft\Model\RefundResponseDto

Transfers

Initiate and manage fund transfers between different payment rails.

Methods

transferControllerCreateDirectBankTransfer($create_direct_bank_transfer_dto)

Create a direct bank transfer.
<?php
use Devdraft\Api\TransfersApi;
use Devdraft\Model\CreateDirectBankTransferDto;
use GuzzleHttp\Client;

$apiInstance = new TransfersApi(new Client(), $config);

try {
    $transferDto = new CreateDirectBankTransferDto([
        'wallet_id' => 'wallet-id',
        'payment_rail' => 'wire',
        'source_currency' => 'usd',
        'destination_currency' => 'usdc',
        'amount' => 1000.00
    ]);
    
    $transfer = $apiInstance->transferControllerCreateDirectBankTransfer($transferDto);
    echo "Transfer created: " . $transfer->getId() . "\n";
    echo "Bank instructions: " . print_r($transfer->getSourceDepositInstructions(), true) . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $create_direct_bank_transfer_dto: \Devdraft\Model\CreateDirectBankTransferDto - Transfer details
Returns: \Devdraft\Model\Transfer See also: Direct Bank Transfer Guide

transferControllerCreateDirectWalletTransfer($create_direct_wallet_transfer_dto)

Create a direct wallet transfer.
use Devdraft\Model\CreateDirectWalletTransferDto;

$transferDto = new CreateDirectWalletTransferDto([
    'wallet_id' => 'wallet-id',
    'network' => 'solana',
    'stable_coin_currency' => 'usdc',
    'amount' => 500.00
]);

$transfer = $apiInstance->transferControllerCreateDirectWalletTransfer($transferDto);
echo "Transfer created: " . $transfer->getId() . "\n";
echo "Deposit address: " . $transfer->getSourceDepositInstructions()->getToAddress() . "\n";
Parameters:
  • $create_direct_wallet_transfer_dto: \Devdraft\Model\CreateDirectWalletTransferDto - Transfer details
Returns: \Devdraft\Model\Transfer See also: Direct Wallet Transfer Guide

transferControllerCreateExternalBankTransfer($create_external_bank_transfer_dto)

Create an external bank transfer (from your wallet to external bank).
use Devdraft\Model\CreateExternalBankTransferDto;

$transferDto = new CreateExternalBankTransferDto([
    'source_wallet_id' => 'wallet-id',
    'destination_bank_account_id' => 'bank-account-id',
    'amount' => 1000.00,
    'currency' => 'USD'
]);

$transfer = $apiInstance->transferControllerCreateExternalBankTransfer($transferDto);
echo "External bank transfer: " . $transfer->getId() . "\n";
Parameters:
  • $create_external_bank_transfer_dto: \Devdraft\Model\CreateExternalBankTransferDto - Transfer details
Returns: \Devdraft\Model\Transfer

transferControllerCreateExternalStablecoinTransfer($create_external_stablecoin_transfer_dto)

Create an external stablecoin transfer (from your wallet to external wallet).
use Devdraft\Model\CreateExternalStablecoinTransferDto;

$transferDto = new CreateExternalStablecoinTransferDto([
    'source_wallet_id' => 'wallet-id',
    'destination_address' => '0x742d35Cc6Ff82a8C2D8D1Da9da17c7eDfD5bE0a3',
    'network' => 'ethereum',
    'currency' => 'usdc',
    'amount' => 250.00
]);

$transfer = $apiInstance->transferControllerCreateExternalStablecoinTransfer($transferDto);
echo "External stablecoin transfer: " . $transfer->getId() . "\n";
Parameters:
  • $create_external_stablecoin_transfer_dto: \Devdraft\Model\CreateExternalStablecoinTransferDto - Transfer details
Returns: \Devdraft\Model\Transfer

transferControllerCreateStablecoinConversion($create_stablecoin_conversion_dto)

Convert between different stablecoins or networks.
use Devdraft\Model\CreateStablecoinConversionDto;

$conversionDto = new CreateStablecoinConversionDto([
    'source_wallet_id' => 'wallet-id',
    'destination_wallet_id' => 'wallet-id',
    'source_network' => 'ethereum',
    'destination_network' => 'solana',
    'source_currency' => 'usdc',
    'destination_currency' => 'usdc',
    'amount' => 1000.00
]);

$conversion = $apiInstance->transferControllerCreateStablecoinConversion($conversionDto);
echo "Conversion ID: " . $conversion->getId() . "\n";
echo "Exchange rate: " . $conversion->getExchangeRate()->getRate() . "\n";
echo "Estimated completion: " . $conversion->getEstimatedCompletion() . "\n";
Parameters:
  • $create_stablecoin_conversion_dto: \Devdraft\Model\CreateStablecoinConversionDto - Conversion details
Returns: \Devdraft\Model\Conversion See also: Stablecoin Conversion Guide

Wallets

Manage wallets and query balances.

Methods

walletControllerGetWallets()

Get all wallets for your application.
<?php
use Devdraft\Api\WalletsApi;
use GuzzleHttp\Client;

$apiInstance = new WalletsApi(new Client(), $config);

try {
    $apiInstance->walletControllerGetWallets();
    echo "Wallets retrieved successfully\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Returns: void
The response contains wallet IDs that you can use for transfers and other operations. In a future SDK version, this will return typed wallet objects.

Webhooks

Configure webhooks to receive real-time event notifications.

Methods

webhookControllerCreate($create_webhook_dto)

Create a new webhook.
<?php
use Devdraft\Api\WebhooksApi;
use Devdraft\Model\CreateWebhookDto;
use GuzzleHttp\Client;

$apiInstance = new WebhooksApi(new Client(), $config);

try {
    $webhookDto = new CreateWebhookDto([
        'url' => 'https://your-app.com/webhooks/devdraft',
        'name' => 'Production Webhook',
        'is_active' => true,
        'encrypted' => false
    ]);
    
    $webhook = $apiInstance->webhookControllerCreate($webhookDto);
    echo "Webhook ID: " . $webhook->getId() . "\n";
    echo "Signing secret: " . $webhook->getSigningSecret() . "\n";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
Parameters:
  • $create_webhook_dto: \Devdraft\Model\CreateWebhookDto - Webhook configuration
Returns: \Devdraft\Model\WebhookResponseDto See also: Webhooks Overview

webhookControllerFindAll($page, $limit, $active)

Get all webhooks.
$webhooks = $apiInstance->webhookControllerFindAll(1, 20, true);

foreach ($webhooks as $webhook) {
    echo $webhook->getName() . ": " . $webhook->getUrl() . "\n";
    echo "Active: " . ($webhook->getIsActive() ? 'Yes' : 'No') . "\n";
}
Parameters:
  • $page: int - Page number (optional)
  • $limit: int - Items per page (optional)
  • $active: bool - Filter by active status (optional)
Returns: \Devdraft\Model\WebhookResponseDto[]

webhookControllerFindOne($id)

Get a webhook by ID.
$webhook = $apiInstance->webhookControllerFindOne('webhook-id');

echo "Webhook: " . $webhook->getName() . "\n";
echo "URL: " . $webhook->getUrl() . "\n";
echo "Delivery stats: " . print_r($webhook->getDeliveryStats(), true) . "\n";
Parameters:
  • $id: string - Webhook ID
Returns: \Devdraft\Model\WebhookResponseDto

webhookControllerUpdate($id, $update_webhook_dto)

Update a webhook.
use Devdraft\Model\UpdateWebhookDto;

$updateDto = new UpdateWebhookDto([
    'url' => 'https://your-app.com/webhooks/new-endpoint',
    'is_active' => true
]);

$updated = $apiInstance->webhookControllerUpdate('webhook-id', $updateDto);
echo "Webhook updated: " . $updated->getId() . "\n";
Parameters:
  • $id: string - Webhook ID
  • $update_webhook_dto: \Devdraft\Model\UpdateWebhookDto - Fields to update
Returns: \Devdraft\Model\WebhookResponseDto

webhookControllerRemove($id)

Delete a webhook.
$apiInstance->webhookControllerRemove('webhook-id');
echo "Webhook deleted\n";
Parameters:
  • $id: string - Webhook ID
Returns: void

Error Handling

All SDK methods throw exceptions on errors. Handle them appropriately:
<?php
use Devdraft\ApiException;

try {
    $transfer = $apiInstance->transferControllerCreateDirectWalletTransfer($transferDto);
    echo "Transfer created: " . $transfer->getId() . "\n";
} catch (ApiException $e) {
    $statusCode = $e->getCode();
    $responseBody = $e->getResponseBody();
    
    switch ($statusCode) {
        case 400:
            echo "Invalid request: " . $e->getMessage() . "\n";
            break;
        case 401:
            echo "Authentication failed - check your API credentials\n";
            break;
        case 404:
            echo "Resource not found: " . $e->getMessage() . "\n";
            break;
        case 422:
            echo "Validation error: " . $e->getMessage() . "\n";
            break;
        case 429:
            $retryAfter = $e->getResponseHeaders()['Retry-After'] ?? 'unknown';
            echo "Rate limited - retry after: $retryAfter\n";
            break;
        default:
            echo "API error ($statusCode): " . $e->getMessage() . "\n";
    }
    
    // Log full response for debugging
    error_log("Response body: " . print_r($responseBody, true));
} catch (Exception $e) {
    echo "Unexpected error: " . $e->getMessage() . "\n";
}

Best Practices

1

Use Environment Variables for Credentials

Store API credentials in environment variables, never in source code.
<?php
$config = Devdraft\Configuration::getDefaultConfiguration()
    ->setApiKey('x-client-key', getenv('DEVDRAFT_CLIENT_KEY'))
    ->setApiKey('x-client-secret', getenv('DEVDRAFT_CLIENT_SECRET'));
2

Reuse Configuration and Client Instances

Create a single configuration and reuse it across your application.
<?php
// Bad: Creating new instances for each request
function processTransfer() {
    $config = Devdraft\Configuration::getDefaultConfiguration()
        ->setApiKey('x-client-key', getenv('DEVDRAFT_CLIENT_KEY'))
        ->setApiKey('x-client-secret', getenv('DEVDRAFT_CLIENT_SECRET'));
    $client = new GuzzleHttp\Client();
    $api = new Devdraft\Api\TransfersApi($client, $config);
    // use api...
}

// Good: Reuse configuration and client
class DevdraftService {
    private $transfersApi;
    
    public function __construct() {
        $config = Devdraft\Configuration::getDefaultConfiguration()
            ->setApiKey('x-client-key', getenv('DEVDRAFT_CLIENT_KEY'))
            ->setApiKey('x-client-secret', getenv('DEVDRAFT_CLIENT_SECRET'));
        
        $client = new GuzzleHttp\Client();
        $this->transfersApi = new Devdraft\Api\TransfersApi($client, $config);
    }
    
    public function processTransfer($transferDto) {
        return $this->transfersApi->transferControllerCreateDirectWalletTransfer($transferDto);
    }
}
3

Proper Exception Handling

Always wrap API calls in try-catch blocks and handle errors appropriately.
<?php
use Devdraft\ApiException;

try {
    $result = $apiInstance->someMethod($dto);
    // Process result
} catch (ApiException $e) {
    // Log error details
    error_log(sprintf(
        "API Error: %s (Code: %d, Response: %s)",
        $e->getMessage(),
        $e->getCode(),
        json_encode($e->getResponseBody())
    ));
    
    // Handle specific error codes
    if ($e->getCode() === 429) {
        // Implement retry logic
    }
} catch (Exception $e) {
    error_log("Unexpected error: " . $e->getMessage());
}
4

Use Type Hints

Leverage PHP’s type hints for better code quality and IDE support.
<?php
use Devdraft\Model\CreateDirectWalletTransferDto;
use Devdraft\Model\Transfer;

function createTransfer(string $walletId, float $amount): Transfer {
    $transferDto = new CreateDirectWalletTransferDto([
        'wallet_id' => $walletId,
        'network' => 'solana',
        'stable_coin_currency' => 'usdc',
        'amount' => $amount
    ]);
    
    return $apiInstance->transferControllerCreateDirectWalletTransfer($transferDto);
}
5

Validate Input Data

Validate input data before making API calls to catch errors early.
<?php
function createCustomer(array $data): void {
    // Validate required fields
    $required = ['first_name', 'last_name', 'email'];
    foreach ($required as $field) {
        if (empty($data[$field])) {
            throw new InvalidArgumentException("Missing required field: $field");
        }
    }
    
    // Validate email format
    if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
        throw new InvalidArgumentException("Invalid email format");
    }
    
    // Create customer
    $customerDto = new CreateCustomerDto($data);
    $apiInstance->customerControllerCreate($customerDto);
}
6

Implement Logging

Use PSR-3 compatible logging for debugging and monitoring.
<?php
use Psr\Log\LoggerInterface;
use Devdraft\ApiException;

class DevdraftService {
    private $logger;
    private $transfersApi;
    
    public function __construct(LoggerInterface $logger, TransfersApi $transfersApi) {
        $this->logger = $logger;
        $this->transfersApi = $transfersApi;
    }
    
    public function createTransfer(CreateDirectWalletTransferDto $dto): Transfer {
        $this->logger->info('Creating transfer', ['wallet_id' => $dto->getWalletId()]);
        
        try {
            $transfer = $this->transfersApi->transferControllerCreateDirectWalletTransfer($dto);
            $this->logger->info('Transfer created', ['transfer_id' => $transfer->getId()]);
            return $transfer;
        } catch (ApiException $e) {
            $this->logger->error('Transfer creation failed', [
                'error' => $e->getMessage(),
                'code' => $e->getCode(),
                'response' => $e->getResponseBody()
            ]);
            throw $e;
        }
    }
}

Testing with PHPUnit

Example PHPUnit test for SDK integration:
<?php
use PHPUnit\Framework\TestCase;
use Devdraft\Configuration;
use Devdraft\Api\WebhooksApi;
use Devdraft\Model\CreateWebhookDto;
use GuzzleHttp\Client;

class WebhookTest extends TestCase
{
    private $config;
    private $apiInstance;
    
    protected function setUp(): void
    {
        $this->config = Configuration::getDefaultConfiguration()
            ->setApiKey('x-client-key', getenv('DEVDRAFT_TEST_CLIENT_KEY'))
            ->setApiKey('x-client-secret', getenv('DEVDRAFT_TEST_CLIENT_SECRET'));
        
        $this->apiInstance = new WebhooksApi(new Client(), $this->config);
    }
    
    public function testCreateWebhook(): void
    {
        $webhookDto = new CreateWebhookDto([
            'url' => 'https://test.example.com/webhook',
            'name' => 'Test Webhook',
            'is_active' => true
        ]);
        
        $webhook = $this->apiInstance->webhookControllerCreate($webhookDto);
        
        $this->assertNotNull($webhook->getId());
        $this->assertEquals('Test Webhook', $webhook->getName());
        $this->assertTrue($webhook->getIsActive());
    }
    
    public function testInvalidWebhookUrl(): void
    {
        $this->expectException(\Devdraft\ApiException::class);
        
        $webhookDto = new CreateWebhookDto([
            'url' => 'invalid-url',
            'name' => 'Invalid Webhook',
            'is_active' => true
        ]);
        
        $this->apiInstance->webhookControllerCreate($webhookDto);
    }
}

Laravel Integration

Example Laravel service provider for Devdraft SDK:
<?php
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Devdraft\Configuration;
use Devdraft\Api\TransfersApi;
use Devdraft\Api\WebhooksApi;
use GuzzleHttp\Client;

class DevdraftServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(Configuration::class, function ($app) {
            return Configuration::getDefaultConfiguration()
                ->setApiKey('x-client-key', config('services.devdraft.client_key'))
                ->setApiKey('x-client-secret', config('services.devdraft.client_secret'))
                ->setHost(config('services.devdraft.api_url', 'https://api.devdraft.ai'));
        });
        
        $this->app->singleton(Client::class, function ($app) {
            return new Client();
        });
        
        $this->app->singleton(TransfersApi::class, function ($app) {
            return new TransfersApi(
                $app->make(Client::class),
                $app->make(Configuration::class)
            );
        });
        
        $this->app->singleton(WebhooksApi::class, function ($app) {
            return new WebhooksApi(
                $app->make(Client::class),
                $app->make(Configuration::class)
            );
        });
    }
}
Usage in Laravel controller:
<?php
namespace App\Http\Controllers;

use Devdraft\Api\TransfersApi;
use Devdraft\Model\CreateDirectWalletTransferDto;
use Illuminate\Http\Request;

class TransferController extends Controller
{
    private $transfersApi;
    
    public function __construct(TransfersApi $transfersApi)
    {
        $this->transfersApi = $transfersApi;
    }
    
    public function create(Request $request)
    {
        $validated = $request->validate([
            'wallet_id' => 'required|string',
            'amount' => 'required|numeric|min:0.01',
        ]);
        
        try {
            $transferDto = new CreateDirectWalletTransferDto([
                'wallet_id' => $validated['wallet_id'],
                'network' => 'solana',
                'stable_coin_currency' => 'usdc',
                'amount' => $validated['amount']
            ]);
            
            $transfer = $this->transfersApi->transferControllerCreateDirectWalletTransfer($transferDto);
            
            return response()->json([
                'success' => true,
                'transfer_id' => $transfer->getId()
            ]);
        } catch (\Devdraft\ApiException $e) {
            return response()->json([
                'success' => false,
                'error' => $e->getMessage()
            ], $e->getCode());
        }
    }
}

Next Steps

SDK Quickstart

Complete integration guide with examples

Transfers

Learn about initiating transfers

Webhooks

Set up webhook notifications

API Reference

Complete REST API documentation