PHP code example of sch-group / correos

1. Go to this page and download the library: Download sch-group/correos 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/ */

    

sch-group / correos example snippets


    $trackNumber = $shipment->getClippedTrackNumber();

    $createdShipmentDateTime = $shipment->getDateRequest();

    $labelPdfByteCode = $this->client->printLabel($trackNumber, $createdShipmentDateTime);


    $trackNumber = $invoice->getClippedTrackNumber();

    $isCancelShipment = $this->client->cancelShipment($trackNumber);


   $receiverAddress = new Address(
            "TEST CITY NAME",
            "TEST STREET NAME",
            "MADRIDO",
            "20"
        );
        $receiverIdentity = new Identification(
            "TEST TEST",
        );
        $receiverUnitedIdentity = new ReceiverUnitedIdentity(
            $receiverAddress,
            $receiverIdentity,
            "480590", // must be less than < 6
            "US", // Zip
        );

        $product = new ProductDescription(
            '1',
            '189',
            '200',
            '96000'
        );
        $productList = new ProductList();
        $productList->addProduct($product);

        $sendingInsides = new SendingInsides(
            SendingInsides::GOODS_CONTENT_TYPE, // GOODS,, // GOODS,
            SendingInsides::YES_CHOICE, // S
            $totalPrice > 50000 ? SendingInsides::YES_CHOICE : null,
            $productList,
            $totalPrice > 50000 ? SendingInsides::NO_CHOICE : null
        );
        $packageSize = new PackageSize(
            15,
            15,
            15,
            500
        );

        $sendingContent = new SendingContent(
            SendingContent::PAQ_LIGHT_INTERNATIONAL_TARIFF, // PAQ LIGHT INTERNATIONAL(I)
            SendingContent::POSTAGE_PAID_PAYMENT_TYPE,
            SendingContent::STANDARD_DELIVERY_MODE,
            $packageSize,
            $sendingInsides
        );

        $shipment = new Shipment($receiverUnitedIdentity, $sendingContent);
        $shipment->setTrackNumber($createdShipment->getTrackNumber());
        $shipment->setDateRequest($createdShipment->getDateRequest());

        $shipment = $this->client->updateShipment($shipment);