gabrielbull / php-ups-api

PHP Wrapper for all UPS API
MIT License
456 stars 255 forks source link

Shipment/ReferenceNumber is not allowed for this shipment (120541) #333

Open WEBMASTERV2 opened 3 years ago

WEBMASTERV2 commented 3 years ago

HI, I am using gabrill php - ups api for my ERP. Label is generated successful but without a reference number. when i use the code for the same it shows the following error :

Shipment/ReferenceNumber is not allowed for this shipment (120541)

can some help me about that?

// Set service
$service = new \Ups\Entity\Service;
$service->setCode(\Ups\Entity\Service::S_STANDARD);
$service->setDescription($service->getName());
$shipment->setService($service);

//------------GET REFERENCE NUMBER
$order_id0 = $_POST['invoice_nu'];

$referencenumber=new \Ups\Entity\ReferenceNumber;
    //$referencenumber->setCode('RZ');
    $referencenumber->setValue($order_id0);
    $shipment->setReferenceNumber($referencenumber);

above code shows me an error, if i will not use this it generate label successfully ..

mfrederico commented 2 years ago

Duplicate of #https://github.com/gabrielbull/php-ups-api/issues/327

timramseyjr commented 2 years ago

I ran into a similar situation and fixed it by adding the reference number to the package instead of the shipment

$package->setReferenceNumber($referencenumber);