فهرست مستندات پروژه
تیپاکس (Tipax)
شرکت حمل خصوصی سراسری. REST API. پشتیبانی از label، pickup، شعب و پسکرایه.
پیکربندی
use Eram\Ersal\Provider\Tipax\TipaxConfig;
$config = new TipaxConfig(
token: 'your-bearer-token',
sandbox: false,
baseUrl: null,
);
| پارامتر | نوع | اجباری | پیشفرض | توضیح |
|---|---|---|---|---|
token | string | بله | — | توکن Bearer از پرتال توسعهدهنده تیپاکس |
sandbox | bool | خیر | false | محیط تست |
baseUrl | ?string | خیر | null | بازنویسی آدرس API |
قابلیتها
| رابط | پشتیبانی |
|---|---|
ShippingInterface (quote, book, track, cancel) | ✅ |
SupportsLabel | ✅ |
SupportsPickup | ✅ |
SupportsBranches | ✅ |
SupportsCOD | ✅ |
راهاندازی
use Eram\Ersal\Ersal;
use Eram\Ersal\Provider\Tipax\TipaxConfig;
$ersal = new Ersal();
$tipax = $ersal->create('tipax', new TipaxConfig(token: 'your-token'));
quote() — استعلام قیمت
list<Quote> برمیگرداند. تیپاکس میتواند چند پیشنهاد (یکی به ازای هر سطح سرویس) بدهد.
use Eram\Ersal\Address\Address;
use Eram\Ersal\Address\Parcel;
use Eram\Ersal\Money\Amount;
use Eram\Ersal\Request\QuoteRequest;
$origin = new Address(
firstName: 'Shop', lastName: 'Owner',
phone: '09123456789',
province: 'تهران', city: 'تهران',
addressLine: 'خیابان ولیعصر، پلاک ۱۰۰',
postalCode: '1234567890',
);
$destination = new Address(
firstName: 'Customer', lastName: 'Name',
phone: '09121111111',
province: 'اصفهان', city: 'اصفهان',
addressLine: 'خیابان چهارباغ، پلاک ۲۰',
postalCode: '8159876543',
);
$parcel = new Parcel(
weightGrams: 1500,
lengthMm: 300, widthMm: 200, heightMm: 100,
declaredValue: Amount::fromToman(500_000),
contentsDescription: 'کتاب',
);
$quotes = $tipax->quote(new QuoteRequest(
origin: $origin, destination: $destination, parcel: $parcel,
));
foreach ($quotes as $quote) {
printf(
"%s: %d تومان (تحویل %d روز) — شناسه: %s\n",
$quote->serviceLevel,
$quote->cost->inToman(),
$quote->etaDays,
$quote->quoteId,
);
}
createShipment() — ثبت مرسوله
use Eram\Ersal\Request\BookingRequest;
$shipment = $tipax->createShipment(new BookingRequest(
origin: $origin, destination: $destination, parcel: $parcel,
orderId: 'ORDER-2026-0001',
serviceLevel: 'express',
quoteId: $quotes[0]->quoteId,
description: 'کتاب',
));
$shipment->getId(); // ShipmentId — برای فراخوانیهای بعدی
$shipment->getTrackingCode(); // کد رهگیری قابل نمایش به مشتری
$shipment->getStatus(); // ShipmentStatus::Booked
$shipment->getCost()->inToman(); // هزینه نهایی
پسکرایه (Cash-on-delivery)
use Eram\Ersal\Contracts\SupportsCOD;
if ($tipax instanceof SupportsCOD) {
$booking = (new BookingRequest(
origin: $origin, destination: $destination, parcel: $parcel,
orderId: 'ORDER-2026-0002',
))->withCashOnDelivery(Amount::fromToman(2_500_000));
$shipment = $tipax->createShipment($booking);
}
برای COD، تیپاکس معمولاً Address::$nationalId گیرنده را میخواهد.
track() — وضعیت و تاریخچه
$tracked = $tipax->track($shipment->getId());
$tracked->getStatus(); // ShipmentStatus
$tracked->getStatus()->label('fa'); // 'در حال ارسال'
$tracked->getStatus()->isTerminal(); // تا نرسیدن false
foreach ($tracked->getHistory() as $event) {
printf(
"[%s] %s — %s در %s\n",
$event->at->format('Y-m-d H:i'),
$event->status->label('fa'),
$event->description,
$event->location ?? 'نامشخص',
);
}
cancel() — لغو
use Eram\Ersal\Exception\CancellationException;
try {
$cancelled = $tipax->cancel($shipment->getId());
$cancelled->getStatus(); // ShipmentStatus::Cancelled
} catch (CancellationException $e) {
echo $e->getMessage();
}
getLabel() — دریافت برچسب
use Eram\Ersal\Contracts\SupportsLabel;
if ($tipax instanceof SupportsLabel) {
$label = $tipax->getLabel($shipment->getId());
file_put_contents("labels/{$shipment->getId()}.{$label->format}", $label->bytes);
if ($label->hasUrl()) {
echo "لینک برچسب: {$label->url}\n";
}
}
schedulePickup() — درخواست جمعآوری پیک
use Eram\Ersal\Contracts\SupportsPickup;
use Eram\Ersal\Request\PickupRequest;
if ($tipax instanceof SupportsPickup) {
$scheduled = $tipax->schedulePickup(
$shipment->getId(),
new PickupRequest(
windowStart: new DateTimeImmutable('tomorrow 10:00'),
windowEnd: new DateTimeImmutable('tomorrow 12:00'),
instructions: 'در ورودی اصلی ساختمان، پلاک ۱۰۰ واحد ۳',
),
);
}
listBranches() — فهرست شعب
use Eram\Ersal\Contracts\SupportsBranches;
if ($tipax instanceof SupportsBranches) {
$branches = $tipax->listBranches('تهران'); // null = همه شهرها
foreach ($branches as $branch) {
printf("%s — %s (تلفن: %s)\n",
$branch->name, $branch->address, $branch->phone ?? 'ندارد');
}
}
مدیریت خطا
use Eram\Ersal\Exception\BookingException;
use Eram\Ersal\Exception\ConnectionException;
use Eram\Ersal\Provider\Tipax\TipaxErrorCode;
try {
$shipment = $tipax->createShipment($booking);
} catch (BookingException $e) {
$code = TipaxErrorCode::tryFrom((int) $e->getErrorCode());
echo $code?->message('fa') ?? $e->getMessage();
} catch (ConnectionException $e) {
// خطای شبکه — میتوان دوباره تلاش کرد
}
نکات
- هزینه به ریال ارسال و دریافت میشود
- وزن به گرم، ابعاد به میلیمتر
- آدرس endpointها را با مستندات توسعهدهنده تیپاکس تایید کنید
⁅شرکت حمل خصوصی سراسری rest api پشتیبانی از label pickup شعب و پسکرایه پس کرایه use eram ersal provider tipax tipaxconfig config new tipaxconfig token your bearer token sandbox false baseurl null پارامتر نوع اجباری پیشفرض پیش فرض توضیح token string بله توکن bearer از پرتال توسعهد توسعه دهنده تیپاکس sandbox bool خیر false محیط تست baseurl string خیر null بازنویسی آدرس ادرس api رابط پشتیبانی shippinginterface quote book track cancel supportslabel supportspickup supportsbranches supportscod use eram ersal ersal use eram ersal provider tipax tipaxconfig ersal new ersal tipax ersal create tipax new tipaxconfig token your token list quote برمیگرد رمید گرداند تیپاکس توانست چند پیشنهاد یکی به ازای هر سطح سرویس داد use eram ersal address address use eram ersal address parcel use eram ersal money amount use eram ersal request quoterequest origin new address firstname shop lastname owner phone 09123456789 province تهران city تهران addressline خیابان ولیعصر پلاک 100 postalcode 1234567890 destination new address firstname customer lastname name phone 09121111111 province اصفهان city اصفهان addressline خیابان چهارباغ پلاک 20 postalcode 8159876543 parcel new parcel weightgrams 1500 lengthmm 300 widthmm 200 heightmm 100 declaredvalue amount fromtoman 500 000 contentsdescription کتاب quotes tipax quote new quoterequest origin origin destination destination parcel parcel foreach quotes as quote printf s d توم تحویل d روز شناسه s n quote servicelevel quote cost intoman quote etadays quote quoteid use eram ersal request bookingrequest shipment tipax createshipment new bookingrequest origin origin destination destination parcel parcel orderid order 2026 0001 servicelevel express quoteid quotes 0 quoteid description کتاب shipment getid shipmentid برای فراخوانی بعدی shipment gettrackingcode کد رهگیری قابل نمایش به مشتری shipment getstatus shipmentstatus booked shipment getcost intoman هزینه نهایی use eram ersal contracts supportscod if tipax instanceof supportscod booking new bookingrequest origin origin destination destination parcel parcel orderid order 2026 0002 withcashondelivery amount fromtoman 2 500 000 shipment tipax createshipment booking برای cod تیپاکس معمولا address nationalid گیرنده را خواست tracked tipax track shipment getid tracked getstatus shipmentstatus tracked getstatus label fa در حال ارسال tracked getstatus isterminal تا نرسید false foreach tracked gethistory as event printf s s s در s n event at format y m d h i event status label fa event description event location نامشخص use eram ersal exception cancellationexception try cancelled tipax cancel shipment getid cancelled getstatus shipmentstatus cancelled catch cancellationexception e echo e getmessage use eram ersal contracts supportslabel if tipax instanceof supportslabel label tipax getlabel shipment getid file put contents labels shipment getid label format label bytes if label hasurl echo لینک برچسب label url n use eram ersal contracts supportspickup use eram ersal request pickuprequest if tipax instanceof supportspickup scheduled tipax schedulepickup shipment getid new pickuprequest windowstart new datetimeimmutable tomorrow 10 00 windowend new datetimeimmutable tomorrow 12 00 instructions در ورودی اصلی ساختمان پلاک 100 واحد 3 use eram ersal contracts supportsbranches if tipax instanceof supportsbranches branches tipax listbranches تهران null همه شهر foreach branches as branch printf s s تلفن s n branch name branch address branch phone نداشت use eram ersal exception bookingexception use eram ersal exception connectionexception use eram ersal provider tipax tipaxerrorcode try shipment tipax createshipment booking catch bookingexception e code tipaxerrorcode tryfrom int e geterrorcode echo code message fa e getmessage catch connectionexception e خطا شبکه توان میتوان دوباره تلاش کرد هزینه به ریال ارسال و دریافت شد وزن به گرم بعد به میل میلی متر آدرس ادرس endpoint را با مستند توسعهد توسعه دهنده تیپاکس تای کرد⁆
⁅تیپاکس tipax⁆
⁅پیکربندیقابلیتهاراهاندازیquote پیکربندیقابلیت هاراه اندازیquote استعلام قیمتcreateshipment ثبت مرسولهپسکرایه مرسولهپس کرایه cash on delivery track وضعیت و تاریخچهcancel لغوgetlabel دریافت برچسبschedulepickup درخواست جمعآوری جمعاوری جمع آوری پیکlistbranches فهرست شعبمدیریت خطانک⁆