Antidot-be / bpost-api-library

Other
24 stars 21 forks source link

Question: create label for international pick-up point (pugo)? #24

Open jochensengier opened 5 years ago

jochensengier commented 5 years ago

First of all a big thanks to the creators and maintainers of this package 👏

So far I’ve used this package to create thousands of shipping labels for national and international deliveries, including pugo addresses in Belgium. But now I’m stuck on how to create a shipping label for an international pick-up point such as the Netherlands or France.

I noticed AtBpost extends National and there is no international alternative, setting or switch. Can anyone point me into the right direction or is this feature not (yet) implemented?

According to Shipping Manager support, this is the required API call:

<?xml version="1.0" encoding="UTF-8"?>
<tns:order xmlns="http://schema.post.be/shm/deepintegration/v3/national" xmlns:common="http://schema.post.be/shm/deepintegration/v3/common" xmlns:tns="http://schema.post.be/shm/deepintegration/v3/" xmlns:international="http://schema.post.be/shm/deepintegration/v3/international" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.post.be/shm/deepintegration/v3/">
   <tns:accountId>XXXXXX</tns:accountId>
   <tns:reference>customer reference xxxx08</tns:reference>
   <tns:costCenter>Cost Center</tns:costCenter>
   <tns:orderLine>
       <tns:text>Product 1</tns:text>
       <tns:nbOfItems>1</tns:nbOfItems>
   </tns:orderLine>
   <tns:box>
       <tns:sender>
               <common:name>SENDER_NAME</common:name>
               <common:company>SENDER_COMPANY</common:company>
               <common:address>
                   <common:streetName>sender_street_name</common:streetName>
                   <common:number>1</common:number>
                   <common:box>1</common:box><!-- When box is empty this tag has to be removed -->
                   <common:postalCode>1000</common:postalCode>
                   <common:locality>sender_city</common:locality>
                   <common:countryCode>BE</common:countryCode>
               </common:address>
               <common:emailAddress>sender@test.be</common:emailAddress>
               <common:phoneNumber>0032123456789</common:phoneNumber>
       </tns:sender>
         <tns:internationalBox>
           <international:atIntlPugo>
               <international:product>bpack@bpost international</international:product>
               <international:options>
                    <common:keepMeInformed language="NL">
                        <common:emailAddress>sender@test.be</common:emailAddress>
                    </common:keepMeInformed>
                </international:options>
               <international:receiver>
                   <common:name>name_of_final_receiver</common:name>
                   <common:company>company_name</common:company>
                   <common:address>
                       <common:streetName>street_name_of_final_receiver</common:streetName>
                       <common:number>7</common:number>
                       <common:box>b</common:box>
                       <common:postalCode>4811 ZG</common:postalCode>
                       <common:locality>city_of_final_receiver</common:locality>
                       <common:countryCode>NL</common:countryCode>
                   </common:address>
                   <common:emailAddress>finalreceiver@test.be</common:emailAddress>
                   <common:phoneNumber>0033123456789</common:phoneNumber>
               </international:receiver>
               <international:parcelWeight>2000</international:parcelWeight>
               <international:customsInfo>
                 <international:parcelValue>1000</international:parcelValue>
                 <international:contentDescription>Test description</international:contentDescription>
                 <international:shipmentType>GOODS</international:shipmentType>
                 <international:parcelReturnInstructions>RTS</international:parcelReturnInstructions>
                 <international:privateAddress>false</international:privateAddress>
               </international:customsInfo>
               <international:pugoId>163372</international:pugoId>
               <international:pugoName>name_of_delivery_point</international:pugoName>
               <international:pugoAddress>
                   <common:streetName>street_of_delivery_point</common:streetName>
                   <common:number>89</common:number>
                   <common:box>a</common:box>
                   <common:postalCode>4811 ZG</common:postalCode>
                   <common:locality>city_of_delivery_point</common:locality>
                   <common:countryCode>NL</common:countryCode>
               </international:pugoAddress>
             </international:atIntlPugo>
       </tns:internationalBox>
       <tns:remark>remark xyz</tns:remark>
       <tns:additionalCustomerReference>Reference that can be used for cross-referencing</tns:additionalCustomerReference>
   </tns:box>
</tns:order>

Thanks!

zangra-dev commented 4 years ago

Hello, I start today to work on this problem. I can set the data required for the sender, international box product|options|receiver|parcel weight and customsInfo.

The problem come from the pugo data insertion, when I do a fetchOrder, there is no information dumped about the pugo. May be it can be come from there, or the Order->createFromXML

I will check further tomorrow and try to get pugo's information from bpost.

If I found something, I will place details here

jochensengier commented 4 years ago

Awesome, thanks a lot!

zangra-dev commented 4 years ago

Working on it since this morning and found some errors/missing files 1) The pugo international take a box with the class "AtIntlPugo" but no such class exist. But I think it will not be too complicated to create it from a Box/AtBpost duplication + modification.

2) The problem about the pugo data insertion still remains, I dump the function $this->getApiCaller()->getResponseBody() from the src/Bpost file and the xml I receive is like :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<orderInfo xmlns="http://schema.post.be/shm/deepintegration/v3/" xmlns:ns2="http://schema.post.be/shm/deepintegration/v3/common" xmlns:ns3="http://schema.post.be/shm/deepintegration/v3/national" xmlns:ns4="http://schema.post.be/shm/deepintegration/v3/international">
    <accountId>000000</accountId>
    <reference>shipment_ref</reference>
    <costCenter>Cost center</costCenter>
    <box>
        <sender>
            <ns2:name/>
            <ns2:company>sender</ns2:company>
            <ns2:address>
                <ns2:streetName>sender_street</ns2:streetName>
                <ns2:number>sender_street</ns2:number>
                <ns2:postalCode>sender_postalCode</ns2:postalCode>
                <ns2:locality>sender_locality</ns2:locality>
                <ns2:countryCode>BE</ns2:countryCode>
            </ns2:address>
            <ns2:emailAddress>sender_email</ns2:emailAddress>
            <ns2:phoneNumber>sender_phoneNumber</ns2:phoneNumber>
        </sender>
        <internationalBox>
            <ns4:international>
                <ns4:product>bpack@bpost international</ns4:product>
                <ns4:options>
                    <ns2:keepMeInformed language="FR">
                        <ns2:emailAddress>client_email</ns2:emailAddress>
                    </ns2:keepMeInformed>
                </ns4:options>
                <ns4:receiver>
                    <ns2:name>client_name</ns2:name>
                    <ns2:address>
                        <ns2:streetName>pugo_address</ns2:streetName>
                        <ns2:number>pugo_number</ns2:number>
                        <ns2:postalCode>pugo_postalCode</ns2:postalCode>
                        <ns2:locality>pugo_locality</ns2:locality>
                        <ns2:countryCode>FR</ns2:countryCode>
                    </ns2:address>
                    <ns2:emailAddress>client_email</ns2:emailAddress>
                    <ns2:phoneNumber>client_phoneNumber</ns2:phoneNumber>
                </ns4:receiver>
                <ns4:parcelWeight>800</ns4:parcelWeight>
            </ns4:international>
        </internationalBox>
        <status>OPEN</status>
    </box>
</orderInfo>

There is no pugo details present (for exemple the id and name)... So something is wrong with the doCall and don't get all data (but it's weird, it's work perfectly for the belgium pugo) or Bpost don't allow to get the pugo information from the shipping manager

jochensengier commented 4 years ago

Technical support of Bpost Shipping Manager can be reached at SMB_TXP_SHIPPINGMANAGER@bpost.be

I also had to ask them to activate the PUGO service for my customer's account.

Maybe this can help: http://taxipost.geo6.be/Locator?Service=search Got this partnerID 999010 once for testing from support

zangra-dev commented 4 years ago

The initial creation from the Bpost interface is ok, the label is correctly set and all the data are correct (for us)

The problem appear when we call a fetchOrder with the API to retrieve this datas. I will send them an email ;)

zangra-dev commented 4 years ago

I've contact them, the only way is to work with the pudo locator and parse the XML returned by the API Not very cool but ... have to work with that

jochensengier commented 4 years ago

Thanks for the update, here's some (simplified/reduced) code from one of my projects for reference...

use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'http://taxipost.geo6.be/',
    'verify'   => false,
]);

$query = http_build_query([
    'Function'  => 'search',
    'Partner'   => '',
    'Language'  => '',
    'Street'    => '',
    'Number'    => '',
    'Zone'      => '',
    'Country'   => '',
    'Type'      => '',
    'Limit'     => '',
    'DD'        => '',
    'CheckDate' => '0',
    'CheckList' => '0',
    'CheckOpen' => '0',
    'Info'      => '0',
]);

$response = $client->request('GET', 'Locator?' . $query);

if ($response->getStatusCode() === 200) {
    $points = json_decode(json_encode(simplexml_load_string($response->getBody(), 'SimpleXMLElement', LIBXML_NOCDATA)), true);
}
jochensengier commented 4 years ago

@zangra-dev did you manage to get this working? Thx!

zangra-dev commented 4 years ago

@jochensengier sorry for the long delay before the answer

Yes, we have a working solution with the locator http://pudo.bpost.be/Locator (you have to request the access to the shipping manager) you can see in our project in the international_pugo branch https://github.com/zangra-dev/bpost-api-library/tree/international_pugo But there is a huge problem in france... The pugo availability change every day : shop stop work with bpost or bpost stop referencing them, don't know and don't have an answer about it when I asked them. So the solution is totally disastrous and we stopped to work with international pugo at the start on the year