andyts93/laravel-ebay

Laravel package to integrate eBay REST API

dev-main 2025-05-29 15:34 UTC

This package is auto-updated.

Last update: 2025-05-29 15:35:01 UTC


README

A Simple eBay implementation for Laravel.

⚠️ This package is under development.

Installation

Install the package through Composer.

composer require andyts93/laravel-ebay

Configuration

Publish the config file:

php artisan vendor:publish --tag=ebay-config

Follow the official eBay guide to create your keys and the test account. Edit your .env file to add these mandatory fields:

EBAY_CLIENT_ID=
EBAY_CLIENT_SECRET=
EBAY_RU_NAME=

Publish the migrations and migrate

php artisan vendor:publish --tag=ebay-migrations
php artisan migrate

Model configuration

Use the EbayProduct trait in your product model. Define the sku column name in the function (if the column is named sku you can omit the function).

<?php

use \Illuminate\Database\Eloquent\Model;
use \Andyts93\LaravelEbay\Traits\EbayProduct;

class Product extends Model
{
    use EbayProduct;
    
    protected function getSkuKeyName(): string
    {
        return 'sku';
    }
    
    ...
}

Usage

1. Create inventory item

$product = Product::first();
$product->ebayCreateInventoryItem([
    'quantity' => $product->quantity,
    'title' => Str::limit($product->name, 80, ''),
    'description' => $product->description,
    'aspects' => [
        'Brand' => [$product->brand],
    ],
], [
    'packageWeightAndSize' => [
        'weight' => [
            'unit' => 'KILOGRAM',
            'value' => $product->weight,
        ]
    ],
]);

2. Create offer

$offer = $product->ebayCreateOffer([
    'category_id' => EBAY_CATEGORY_ID,
    'price' => $product->price,
]);

3. Publish the offer

$offer->publishOffer();

Other functions

Get product's offers

$product->ebayListings()->get();

Update an offer

$offer->update([
    'category_id' => EBAY_CATEGORY_ID,
    'price' => $product->price + 10.00,
]);