PHP code example of sashalenz / ebay-api

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

    

sashalenz / ebay-api example snippets


use Sashalenz\EbayApi\Client\Auth\UserToken;
use Sashalenz\EbayApi\Client\EbayClient;

// After obtaining user's OAuth token through authorization flow:
$userToken = new UserToken(
    appId: config('ebay-api.app_id'),
    certId: config('ebay-api.cert_id'),
    environment: \Sashalenz\EbayApi\Enums\Environment::from(config('ebay-api.environment')),
    accessToken: $userAccessToken,
    refreshToken: $userRefreshToken,
    expiresAt: $expiresAt, // Unix timestamp
    cacheKey: 'ebay_user_token_'.$userId // Optional: for caching
);

// Use with client
$client = app(EbayClient::class);
$client->setUserToken($userToken);

// Now you can call Post-Order API methods
$return = GetReturnRequest::make($returnId)->asData();

// Clear user token when done (reverts to Application Token)
$client->clearUserToken();

return [
    'app_id' => env('EBAY_APP_ID'),
    'cert_id' => env('EBAY_CERT_ID'),
    'dev_id' => env('EBAY_DEV_ID'),
    'environment' => env('EBAY_ENVIRONMENT', 'sandbox'),
    'marketplace_id' => env('EBAY_MARKETPLACE_ID', 'EBAY_US'),
    'content_language' => env('EBAY_CONTENT_LANGUAGE', 'en-US'),
    'timeout' => env('EBAY_TIMEOUT', 30),
    'token_cache_ttl' => env('EBAY_TOKEN_CACHE_TTL', 3300),
];

use Sashalenz\EbayApi\Requests\Sell\Inventory\GetInventoryItemRequest;

// Client is automatically injected via Laravel Container
$item = GetInventoryItemRequest::make('SKU123')->asData();

// Type-safe access to properties
echo $item->sku; // 'SKU123'
echo $item->product?->title; // Product title
echo $item->condition; // 'NEW'

use Sashalenz\EbayApi\Facades\EbayApi;
use Sashalenz\EbayApi\Requests\Sell\Inventory\GetInventoryItemRequest;

// Get an inventory item
$request = new GetInventoryItemRequest(app(EbayApi::class), 'SKU123');
$response = $request->send();

if ($response->successful()) {
    $data = $response->json();
    // Process the data
}

use Sashalenz\EbayApi\Client\EbayClient;
use Sashalenz\EbayApi\Requests\Sell\Inventory\GetInventoryItemsRequest;

class InventoryService
{
    public function __construct(private EbayClient $client)
    {
    }

    public function getAllItems()
    {
        $request = new GetInventoryItemsRequest($this->client);
        $request->limit(50)->offset(0);
        
        $response = $request->send();
        return $response->json();
    }
}

use Sashalenz\EbayApi\Requests\Sell\Inventory\InventoryItem\GetInventoryItemRequest;

// Auto-injection + Data mapping (recommended)
$item = GetInventoryItemRequest::make('YOUR-SKU')->asData();

// Access all properties type-safely
echo "SKU: {$item->sku}" . PHP_EOL;
echo "Title: {$item->product?->title}" . PHP_EOL;
echo "Condition: {$item->condition?->value}" . PHP_EOL;
echo "Quantity: {$item->availability?->shipToLocationAvailability?->quantity}" . PHP_EOL;

// Product details
echo "Brand: {$item->product?->brand}" . PHP_EOL;
echo "Description: {$item->product?->description}" . PHP_EOL;

// Images
foreach ($item->product?->imageUrls ?? [] as $imageUrl) {
    echo "Image: {$imageUrl}" . PHP_EOL;
}

use Sashalenz\EbayApi\Requests\Sell\Inventory\InventoryItem\GetInventoryItemsRequest;

// Auto-injection + automatic mapping to DataCollection
$items = GetInventoryItemsRequest::make()
    ->limit(50)
    ->offset(0)
    ->asData();

// $items is DataCollection<InventoryItemData>
foreach ($items as $item) {
    echo "SKU: {$item->sku}" . PHP_EOL;
    echo "Title: {$item->product?->title}" . PHP_EOL;
    echo "Condition: {$item->condition?->value}" . PHP_EOL;
}

// DataCollection methods
$skus = $items->pluck('sku');
$newItems = $items->filter(fn($item) => $item->condition === Condition::NEW);

use Sashalenz\EbayApi\Requests\Sell\Inventory\InventoryItem\CreateOrReplaceInventoryItemRequest;
use Sashalenz\EbayApi\Data\Sell\Inventory\ProductData;
use Sashalenz\EbayApi\Data\Sell\Inventory\AvailabilityData;
use Sashalenz\EbayApi\Data\Sell\Inventory\ShipToLocationAvailabilityData;
use Sashalenz\EbayApi\Enums\Condition;
use Sashalenz\EbayApi\Enums\Locale;

// Using Builder Pattern with Data objects and Enums
$response = CreateOrReplaceInventoryItemRequest::make('YOUR-SKU')
    ->product(ProductData::from([
        'title' => 'Apple iPhone 15 Pro',
        'description' => 'Brand new Apple iPhone 15 Pro with 256GB storage',
        'brand' => 'Apple',
        'mpn' => 'MTUW3',
        'aspects' => [
            'Brand' => ['Apple'],
            'Model' => ['iPhone 15 Pro'],
            'Storage Capacity' => ['256 GB'],
        ],
        'imageUrls' => ['https://example.com/image1.jpg'],
    ]))
    ->condition(Condition::NEW)
    ->locale(Locale::EN_US)
    ->availability(AvailabilityData::from([
        'shipToLocationAvailability' => ShipToLocationAvailabilityData::from([
            'quantity' => 10,
        ]),
    ]))
    ->send();

if ($response->successful()) {
    echo "Inventory item created/updated successfully";
}

use Sashalenz\EbayApi\Requests\Sell\Inventory\InventoryItem\DeleteInventoryItemRequest;

// Delete inventory item (also deletes unpublished offers and listings)
$response = DeleteInventoryItemRequest::make('YOUR-SKU')->send();

if ($response->successful()) {
    echo "Inventory item deleted successfully";
}

use Sashalenz\EbayApi\Requests\Sell\Inventory\Offer\CreateOfferRequest;
use Sashalenz\EbayApi\Data\Sell\Inventory\PricingSummaryData;
use Sashalenz\EbayApi\Data\Sell\Inventory\AmountData;
use Sashalenz\EbayApi\Data\Sell\Inventory\ListingPoliciesData;
use Sashalenz\EbayApi\Enums\MarketplaceId;

$offer = CreateOfferRequest::make('YOUR-SKU', MarketplaceId::EBAY_US, 'FIXED_PRICE')
    ->categoryId('139971')
    ->pricingSummary(PricingSummaryData::from([
        'price' => AmountData::from([
            'currency' => 'USD',
            'value' => '999.99',
        ]),
    ]))
    ->listingPolicies(ListingPoliciesData::from([
        'fulfillmentPolicyId' => 'policy-123',
        'paymentPolicyId' => 'policy-456',
        'returnPolicyId' => 'policy-789',
    ]))
    ->quantityLimitPerBuyer(5)
    ->merchantLocationKey('warehouse-01')
    ->asData();

echo "Offer ID: {$offer->offerId}";

use Sashalenz\EbayApi\Requests\Sell\Inventory\InventoryItem\BulkUpdatePriceQuantityRequest;
use Sashalenz\EbayApi\Data\Sell\Inventory\AvailabilityData;
use Sashalenz\EbayApi\Data\Sell\Inventory\PricingSummaryData;

// Update price and quantity for multiple items
$response = BulkUpdatePriceQuantityRequest::make()
    ->addRequest(
        'SKU-001',
        AvailabilityData::from(['shipToLocationAvailability' => ['quantity' => 50]]),
        PricingSummaryData::from(['price' => ['value' => '29.99', 'currency' => 'USD']])
    )
    ->addRequest(
        'SKU-002',
        AvailabilityData::from(['shipToLocationAvailability' => ['quantity' => 100]]),
        PricingSummaryData::from(['price' => ['value' => '49.99', 'currency' => 'USD']])
    )
    ->send();

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\GetDefaultCategoryTreeIdRequest;
use Sashalenz\EbayApi\Enums\MarketplaceId;

// Get default category tree for US marketplace
$tree = GetDefaultCategoryTreeIdRequest::make(MarketplaceId::EBAY_US)->asData();

echo "Tree ID: {$tree->categoryTreeId}" . PHP_EOL;
echo "Version: {$tree->categoryTreeVersion}" . PHP_EOL;

// For different marketplaces
$ukTree = GetDefaultCategoryTreeIdRequest::make(MarketplaceId::EBAY_GB)->asData();
$deTree = GetDefaultCategoryTreeIdRequest::make(MarketplaceId::EBAY_DE)->asData();

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\GetCategorySuggestionsRequest;

// Client auto-injected + automatic mapping to DataCollection<CategorySuggestionData>
$suggestions = GetCategorySuggestionsRequest::make('0', 'iphone')->asData();

foreach ($suggestions as $suggestion) {
    echo "Category: {$suggestion->category?->categoryName}" . PHP_EOL;
    echo "ID: {$suggestion->category?->categoryId}" . PHP_EOL;
    echo "Relevancy: {$suggestion->relevancy}" . PHP_EOL;
}

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\GetCategoryTreeRequest;

// Client auto-injected + automatic mapping to CategoryTreeData with full recursive structure
$tree = GetCategoryTreeRequest::make('0')->asData();

echo "Tree ID: {$tree->categoryTreeId}" . PHP_EOL;
echo "Version: {$tree->categoryTreeVersion}" . PHP_EOL;

// applicableMarketplaceIds is array<MarketplaceId>
foreach ($tree->applicableMarketplaceIds ?? [] as $marketplace) {
    echo "Marketplace: {$marketplace->value}" . PHP_EOL;
}

// Navigate the tree
$rootNode = $tree->rootCategoryNode;
echo "Root: {$rootNode->category?->categoryName}" . PHP_EOL;

// Access child nodes (recursive structure)
foreach ($rootNode->childCategoryTreeNodes ?? [] as $child) {
    echo "- {$child->category?->categoryName}" . PHP_EOL;
}

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\GetCategorySubtreeRequest;

// Get subtree below a specific category
$subtree = GetCategorySubtreeRequest::make('0', '11450')->asData();

echo "Tree ID: {$subtree->categoryTreeId}" . PHP_EOL;
echo "Version: {$subtree->categoryTreeVersion}" . PHP_EOL;

$node = $subtree->categorySubtreeNode;
echo "Root: {$node->category?->categoryName}" . PHP_EOL;
echo "Children: {$node->childCategoryTreeNodes?->count()}" . PHP_EOL;

// Navigate subtree
foreach ($node->childCategoryTreeNodes ?? [] as $child) {
    echo "- {$child->category?->categoryName}" . PHP_EOL;
}

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\GetItemAspectsForCategoryRequest;

// Get aspects for a specific leaf category
$metadata = GetItemAspectsForCategoryRequest::make('0', '178090')->asData();

foreach ($metadata->aspects ?? [] as $aspect) {
    echo "Aspect: {$aspect->localizedAspectName}";
    
    if ($aspect->aspectConstraint?->aspectRequired) {
        echo " [Required]";
    }
    
    echo " ({$aspect->aspectConstraint?->aspectUsage?->value})" . PHP_EOL;
    
    // Available values
    if ($aspect->aspectValues !== null) {
        $values = $aspect->aspectValues->pluck('localizedValue')->take(3)->toArray();
        echo "  Values: " . implode(', ', $values) . PHP_EOL;
    }
}

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\GetCompatibilityPropertiesRequest;

// Get compatible vehicle properties for a parts category
$response = GetCompatibilityPropertiesRequest::make('100', '33733')->asData();

foreach ($response->compatibilityProperties ?? [] as $property) {
    echo "Property: {$property->name} (Localized: {$property->localizedName})" . PHP_EOL;
}

// Output: Year, Make, Model, Trim, Engine

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\GetCompatibilityPropertyValuesRequest;

// Get all 2018 Honda models
$models = GetCompatibilityPropertyValuesRequest::make('100', '33559', 'Model')
    ->filter('Year', '2018')
    ->filter('Make', 'Honda')
    ->asData();

foreach ($models->compatibilityPropertyValues ?? [] as $model) {
    echo "Model: {$model->value}" . PHP_EOL;
}

// Or use filters() method
$trims = GetCompatibilityPropertyValuesRequest::make('100', '6030', 'Trim')
    ->filters([
        'Year' => '2018',
        'Make' => 'Ferrari',
    ])
    ->asData();

foreach ($trims->compatibilityPropertyValues ?? [] as $trim) {
    echo "Trim: {$trim->value}" . PHP_EOL;
}

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\GetExpiredCategoriesRequest;

// Get mappings of expired categories to active replacements
$response = GetExpiredCategoriesRequest::make('0')->asData();

foreach ($response->expiredCategories ?? [] as $mapping) {
    echo "Expired: {$mapping->fromCategoryId} -> Active: {$mapping->toCategoryId}" . PHP_EOL;
}

use Sashalenz\EbayApi\Requests\Commerce\Taxonomy\CategoryTree\FetchItemAspectsRequest;

// Get all aspects for all leaf categories (large response, gzipped)
$response = FetchItemAspectsRequest::make('0')->asData();

echo "Tree ID: {$response->categoryTreeId}" . PHP_EOL;
echo "Version: {$response->categoryTreeVersion}" . PHP_EOL;
echo "Categories with aspects: {$response->categoryAspects?->count()}" . PHP_EOL;

// Iterate through category aspects
foreach ($response->categoryAspects ?? [] as $categoryAspect) {
    echo "Category: {$categoryAspect->category?->categoryName}" . PHP_EOL;
    
    foreach ($categoryAspect->aspects ?? [] as $aspect) {
        echo "  - {$aspect->localizedAspectName}";
        
        if ($aspect->aspectConstraint?->aspectRequired) {
            echo " (Required)";
        }
        
        echo PHP_EOL;
    }
}

use Sashalenz\EbayApi\Requests\Sell\Marketing\Campaign\CreateCampaignRequest;

$campaign = CreateCampaignRequest::make([
    'campaignName' => 'Holiday Sale 2025',
    'fundingStrategy' => 'COST_PER_SALE',
    'marketplaceId' => 'EBAY_US',
    'startDate' => '2025-12-01T00:00:00Z',
    'endDate' => '2025-12-31T23:59:59Z',
    'budget' => ['value' => '500.00', 'currency' => 'USD'],
])->asData();

echo "Campaign ID: {$campaign->campaignId}";

use Sashalenz\EbayApi\Requests\Sell\Marketing\Ad\BulkCreateAdsByListingIdRequest;

// Create multiple ads at once
$response = BulkCreateAdsByListingIdRequest::make('campaign-123', [
    ['listingId' => 'listing-001', 'bidPercentage' => '5.0'],
    ['listingId' => 'listing-002', 'bidPercentage' => '7.5'],
])->send();

use Sashalenz\EbayApi\Requests\Sell\Marketing\ItemPromotion\CreateItemPromotionRequest;

$promotion = CreateItemPromotionRequest::make([
    'name' => '20% Off Electronics',
    'promotionType' => 'ORDER_DISCOUNT',
    'marketplaceId' => 'EBAY_US',
    'startDate' => '2025-12-01T00:00:00Z',
    'endDate' => '2025-12-31T23:59:59Z',
    'discountRules' => [
        ['discountBenefit' => ['percentageOffOrder' => '20'], 'ruleOrder' => 1]
    ],
])->send();

use Sashalenz\EbayApi\Requests\Sell\Negotiation\Offer\FindEligibleItemsRequest;
use Sashalenz\EbayApi\Requests\Sell\Negotiation\Offer\SendOfferToInterestedBuyersRequest;

// Find eligible items
$eligible = FindEligibleItemsRequest::make()->limit(50)->asData();

// Send offers
SendOfferToInterestedBuyersRequest::make()
    ->addOfferedItem($eligible->eligibleItems->first()->listingId, discountPercentage: 10.0)
    ->message('Special offer!')
    ->send();

use Sashalenz\EbayApi\Requests\Sell\Catalog\GetProductRequest;
use Sashalenz\EbayApi\Requests\Sell\Catalog\SearchProductsRequest;

// Get a specific product by EPID
$product = GetProductRequest::make('123456789')->asData();
echo $product->title; // Product title
echo $product->brand; // Product brand
echo $product->mpn; // Manufacturer part number

// Search for products
$results = SearchProductsRequest::make()
    ->query('iPhone 15')
    ->brand('Apple')
    ->limit(20)
    ->asData();

foreach ($results as $product) {
    echo "{$product->title} - {$product->epid}" . PHP_EOL;
}

// Search by GTIN (UPC, EAN, ISBN)
$byGtin = SearchProductsRequest::make()
    ->gtin('885909950805')
    ->asData();

// Search with aspect filters
$filtered = SearchProductsRequest::make()
    ->categoryId('9355')
    ->aspectFilter('Storage Capacity:256 GB')
    ->asData();

use Sashalenz\EbayApi\Tests\Factories\InventoryItemDataFactory;
use Sashalenz\EbayApi\Tests\Factories\OfferDataFactory;

// Create test data
$item = InventoryItemDataFactory::make(['sku' => 'TEST-SKU']);
$offer = OfferDataFactory::makeComplete();

// Mock API responses
$mockResponse = $this->successResponse($this->loadFixture('OfferResponse.json'));
$client = $this->createMockClient([$mockResponse]);

use Sashalenz\EbayApi\Exceptions\AuthenticationException;
use Sashalenz\EbayApi\Exceptions\RequestException;

try {
    $response = $request->send();
} catch (AuthenticationException $e) {
    // Handle authentication errors
    Log::error('eBay authentication failed: ' . $e->getMessage());
} catch (RequestException $e) {
    // Handle request errors
    Log::error('eBay request failed: ' . $e->getMessage());
    
    // Get detailed error information
    $errors = $e->getErrors();
}

use Sashalenz\EbayApi\Events\Notifications\ItemSoldEvent;
use Sashalenz\EbayApi\Events\Notifications\MarketplaceAccountDeletionEvent;

protected $listen = [
    ItemSoldEvent::class => [
        SendOrderConfirmationEmail::class,
        UpdateInventoryQuantity::class,
    ],
    MarketplaceAccountDeletionEvent::class => [
        DeleteUserData::class, // GDPR compliance
    ],
];

namespace App\Listeners;

use Sashalenz\EbayApi\Events\Notifications\ItemSoldEvent;
use Illuminate\Support\Facades\Log;

class HandleItemSold
{
    public function handle(ItemSoldEvent $event): void
    {
        Log::info('Item sold on eBay', [
            'item_id' => $event->itemId,
            'transaction_id' => $event->transactionId,
            'buyer' => $event->buyerUserId,
            'quantity' => $event->quantityPurchased,
            'price' => $event->transactionPrice,
        ]);

        // Update your inventory
        // Send confirmation email
        // Create shipping label
        // etc.
    }
}

use Sashalenz\EbayApi\Events\Notifications\MarketplaceAccountDeletionEvent;

class DeleteUserData
{
    public function handle(MarketplaceAccountDeletionEvent $event): void
    {
        // Delete or anonymize user data
        User::where('ebay_user_id', $event->userId)->delete();
        
        Log::info('User data deleted for GDPR compliance', [
            'user_id' => $event->userId,
            'deletion_date' => $event->deletionDate,
        ]);
    }
}

use Sashalenz\EbayApi\Models\EbayNotification;

// Get unprocessed notifications
$pending = EbayNotification::unprocessed()->get();

// Get failed notifications
$failed = EbayNotification::failed()->get();

// Get notifications by event type
$itemSoldNotifications = EbayNotification::byEventName('ItemSold')->get();

// Get notifications for specific user
$userNotifications = EbayNotification::byRecipient('user123')->get();

use Sashalenz\EbayApi\Jobs\ProcessEbayNotificationJob;

$failedNotifications = EbayNotification::failed()->get();

foreach ($failedNotifications as $notification) {
    ProcessEbayNotificationJob::dispatch($notification->id);
}

use Sashalenz\EbayApi\Events\Notifications\MarketplaceAccountDeletionNotificationEvent;

protected $listen = [
    MarketplaceAccountDeletionNotificationEvent::class => [
        DeleteUserEbayData::class,
    ],
];

namespace App\Listeners;

use Sashalenz\EbayApi\Events\Notifications\MarketplaceAccountDeletionNotificationEvent;
use Illuminate\Support\Facades\Log;
use App\Models\User;

class DeleteUserEbayData
{
    public function handle(MarketplaceAccountDeletionNotificationEvent $event): void
    {
        $username = $event->getUsername();
        $userId = $event->getUserId();

        // Find user by eBay user ID
        $user = User::where('ebay_user_id', $userId)->first();

        if ($user) {
            // Delete or anonymize all eBay-related data
            $user->orders()->where('source', 'ebay')->delete();
            $user->ebay_listings()->delete();
            $user->ebay_transactions()->delete();
            
            // Anonymize user data
            $user->update([
                'ebay_user_id' => null,
                'ebay_username' => null,
                'ebay_access_token' => null,
                'ebay_refresh_token' => null,
            ]);

            Log::info('User eBay data deleted for GDPR compliance', [
                'username' => $username,
                'user_id' => $userId,
                'notification_id' => $event->notification->notification_id,
            ]);
        }
    }
}

use Sashalenz\EbayApi\Jobs\ProcessMarketplaceAccountDeletionJob;

// Manually dispatch job
ProcessMarketplaceAccountDeletionJob::dispatch($notificationId);

// Check queue status
php artisan queue:work --queue=default

use Sashalenz\EbayApi\Client\Auth\UserToken;
use Sashalenz\EbayApi\Requests\PostOrder\Return\CreateReturnRequest;
use Sashalenz\EbayApi\Requests\PostOrder\Cancellation\CreateCancellationRequest;

// Create user token
$userToken = new UserToken(
    appId: config('ebay-api.app_id'),
    certId: config('ebay-api.cert_id'),
    environment: \Sashalenz\EbayApi\Enums\Environment::from(config('ebay-api.environment')),
    accessToken: $user->ebay_access_token,
    refreshToken: $user->ebay_refresh_token,
    expiresAt: $user->ebay_token_expires_at,
    cacheKey: 'ebay_user_token_'.$user->id
);

// Set on client
$client = app(\Sashalenz\EbayApi\Client\EbayClient::class);
$client->setUserToken($userToken);

// Check return eligibility
$eligible = CheckReturnEligibilityRequest::make()
    ->itemId('110111222333')
    ->transactionId('123456')
    ->returnReason('NOT_AS_DESCRIBED')
    ->asData();

// Create return request
$return = CreateReturnRequest::make()
    ->itemId('110111222333')
    ->transactionId('123456')
    ->returnReason('NOT_AS_DESCRIBED')
    ->comments('Item has scratches not mentioned in description')
    ->preferredResolution('MONEY_BACK')
    ->asData();

echo "Return ID: {$return->returnId}";

// Search seller's returns
$returns = SearchReturnsRequest::make()
    ->returnState('RETURN_OPEN')
    ->role('SELLER')
    ->limit(50)
    ->asData();

foreach ($returns->returns as $return) {
    echo "Return {$return->returnId}: {$return->returnReason}\n";
}

// Seller provides return address
ProvideSellerInfoRequest::make($returnId)
    ->returnAddress([
        'addressLine1' => '123 Main St',
        'city' => 'San Jose',
        'stateOrProvince' => 'CA',
        'postalCode' => '95101',
        'country' => 'US'
    ])
    ->comments('Please return item to this address')
    ->send();

// Issue refund
IssueReturnRefundRequest::make($returnId)
    ->refundAmount('25.99', 'USD')
    ->comments('Refund issued for returned item')
    ->send();

// Buyer checks if order can be cancelled
$eligible = CheckCancellationEligibilityRequest::make()
    ->orderId('12-34567-89012')
    ->asData();

if ($eligible->eligible) {
    // Create cancellation request
    $cancellation = CreateCancellationRequest::make()
        ->orderId('12-34567-89012')
        ->cancelReason('BUYER_CANCEL_ORDER')
        ->cancelReasonMessage('Changed my mind')
        ->asData();
}

// Seller approves cancellation
ApproveCancellationRequest::make($cancelId)->send();

// Or seller rejects
RejectCancellationRequest::make($cancelId)
    ->rejectReasonMessage('Item already shipped')
    ->send();

// Search for open cases
$cases = SearchCasesRequest::make()
    ->caseStatusFilter('OPEN')
    ->role('SELLER')
    ->limit(50)
    ->asData();

// Get case details
$case = GetCaseRequest::make($caseId)
    ->fieldGroups('FULL')
    ->asData();

// Seller provides tracking info
ProvideShippingInfoRequest::make($caseId)
    ->trackingNumber('1Z999AA10123456784')
    ->shippingCarrierName('UPS')
    ->comments('Item was shipped on time')
    ->send();

// Upload evidence file
$file = UploadEvidenceFileRequest::make($caseId)
    ->file(file_get_contents($photoPath), 'proof.jpg')
    ->asData();

// Submit evidence with file
SubmitEvidenceRequest::make($caseId)
    ->evidenceType('PROOF_OF_SHIPMENT')
    ->trackingNumber('1Z999AA10123456784')
    ->fileIds([$file->fileId])
    ->text('Tracking shows delivered on time')
    ->send();

// Issue refund to resolve case
IssueCaseRefundRequest::make($caseId)
    ->refundAmount('50.00', 'USD')
    ->comments('Issuing full refund')
    ->send();

// Buyer creates inquiry
$inquiry = CreateInquiryRequest::make()
    ->itemId('110111222333')
    ->transactionId('123456')
    ->inquirySubject('SHIPPING_INFO')
    ->comments('When will item be shipped?')
    ->asData();

// Close inquiry (buyer satisfied)
CloseInquiryRequest::make($inquiryId)
    ->comments('Seller responded, issue resolved')
    ->send();

// Single object - client is auto-injected!
$item = GetInventoryItemRequest::make('SKU-123')->asData();
echo $item->sku;

// Collection
$items = GetInventoryItemsRequest::make()->asData();
foreach ($items as $item) {
    echo $item->product?->title;
}
bash
php artisan vendor:publish --tag="ebay-api-config"
bash
php artisan vendor:publish --tag="ebay-api-migrations"
php artisan migrate