shusaura85 / fancourier-api

PHP library to work with the new Fan Courier API v2.0 (selfawb.ro / api.fancourier.ro)
MIT License
21 stars 9 forks source link

External AWB with cash on delivery #20

Closed kikasokolova closed 3 months ago

kikasokolova commented 3 months ago

Hi,

when generating external labels with the option of cash on delivery, it does not correctly write the cash on delivery amount. In the selfAWB system, it is written in declaredValue. According to the latest API documentation directly from Fan courier, the cash on delivery value should be entered in the cod() parameter, which is not defined in your last version, and the courier should be set to setService("Export"), they do not use other couriers.

If I had the courier set to setService("Export-Cont Collector"), I got this error "The selected info.service is invalid.".

shusaura85 commented 3 months ago

Looks like they changed the field name back to cod. At the time of implementation I ran in problems with the external awb's and contacted them. At the time, they replied that I should use the repayment field to specify the cash on delivery value.
I've updated the code to fix the cash on delivery option (use the setReimbursement() function to set it).

About the service returning that error. It's been like that since I first implemented the 2.0 API. Fan Courier's answer was to simply use "Export" even with cash on delivery. I tested it now and the awb is generated with "Export-Cont Collector".

I attached a screenshot of the generated awb for the "create_awb_external.php" example. I didn't change anything in the example
awb_extern

As you can see, it generated with the "Export-Cont Collector" even though the example sets the service as "Export".

Thanks for the notification

kikasokolova commented 3 months ago

I used setService("Export-Cont Collector") and I still have the error The selected info.service is invalid in the terminal. However, I tried to generate a label with setService("Export") and set the setReimbursement() parameter. I also have the setCurrency('BGN') menu set, but as you can see on the label, there is the LEI currency in the cash on delivery section. Is this an API error or should I contact Fan Courier?

Screenshot 2024-06-17 at 12 21 38

shusaura85 commented 3 months ago

Regarding the service, it's a Fan Courier problem. It doesn't work with "Export-Cont Collector". Use "Export" instead.
Make sure you also specify the bank and bank account (setBank() and setIban() functions) as they are required for cash on delivery.

Regarding the currency, although I added the field, Fan Courier ignores it. It looks like the currency depends on the contract you have with Fan courier.
When implementing it, I got this response from them when asked about the currency: Moneda colectata va fi cea din tara respectiva, insa daca contul dumneavoastra este in Lei se va face conversia..
The functions getCurrency() and setCurrency() are available only because the field "currency" appeared in the "Shipping Slip" but they don't do anything as the server doesn't accept it. The actual set value isn't sent at all.
So your best bet would be to contact them for clarification regarding the currency.

kikasokolova commented 3 months ago

Thank you for your help and removing the error when entering cash on delivery