mijora / omniva-woocommerce

11 stars 8 forks source link

Invalid mobile phone number #228

Closed JanisE closed 7 months ago

JanisE commented 9 months ago

After updating Omniva plugin (1.12.3 => 1.15.5), the label generation ends with an error "ITEMNR1 - - shipment.senderAddressee.contactMobile - Invalid mobile phone number"

I tried entering the same phone number that had a label successfully generated for – a few days ago with the old plugin version, and I tried to paste it as the shipping phone number and as the billing phone number and regenerate. I also tried prepending "+371" onto the number. But I'm still getting the same error.

This is a request example by Mijora\Omniva\Request\call to https://edixml.post.ee/epmx/services/messagesService.wsdl (specific data obscured):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://service.core.epmx.application.eestipost.ee/xsd">
    <soapenv:Header/>
    <soapenv:Body>
        <xsd:businessToClientMsgRequest>
            <partner>7.....5</partner>
<interchange msg_type="elsinfov1"><header sender_cd="7.....5" file_id="20240304150308"/><item_list><item service="PA"><add_service><option code="ST"/><option code="SF"/></add_service><measures weight="0.53" length="0.146" width="1.2" height="0.2"/><show_return_code_sms>true</show_return_code_sms><show_return_code_email>true</show_return_code_email><receiverAddressee><person_name>J.......s</person_name><mobile>+3712......0</mobile><email>j.......@......lv</email><address postcode="LV-1010" offloadPostcode="9137" deliverypoint="Kekava" street="S.......... iela 1" country="LV"/></receiverAddressee><returnAddressee><person_name>A.......s</person_name><mobile>+3716......3</mobile><email>a......@......lv</email><address postcode="LV-1010" deliverypoint="R&#x12B;ga" street="R.......2" country="LV"/></returnAddressee></item></item_list></interchange>

        </xsd:businessToClientMsgRequest>
    </soapenv:Body>
</soapenv:Envelope>

This is the response: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns3:businessToClientMsgResponse xmlns:ns3="http://service.core.epmx.application.eestipost.ee/xsd"><partner>7.....5</partner><prompt>ERROR</prompt><savedPacketInfo/><faultyPacketInfo><barcodeInfo><clientItemId>ITEMNR1</clientItemId><message>shipment.senderAddressee.contactMobile - Invalid mobile phone number</message></barcodeInfo></faultyPacketInfo></ns3:businessToClientMsgResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

JanisE commented 8 months ago

I found the bug. You need to setPhone, not setMobile on this line: https://github.com/mijora/omniva-woocommerce/blob/25f8c0d5bcebd8b777c1da1bb77fbf56824aa2da/omniva-woocommerce/core/class-api-xml.php#L140

markakk commented 8 months ago

Hello,

Omniva allows to register shipments only by specifying mobile phone numbers, as the SMS message with shipment informations must be sent. As we know, the format of Latvian mobile phones is +3712xхxxxxx, so only this phone number format is allowed. The mobile phone number must be specified for both the recipient and the sender. Also, the error message is returned by the Omniva server, not the plugin, so there's nothing you can do about it from the plugin side.

JanisE commented 8 months ago

The mobile phone number must be specified for both the recipient and the sender.

This may be true for the regular, individual clients, but we are a company (as probably most of the users of this plugin) with an agreement with Omniva (which is required to use the API at all), and the phone number for a company is what it is.

We were sending out Omniva shipments fine with our phone number until this new plugin upgrade. Previously, the plugin set it as a regular phone, and everything worked.

The Omniva configuration page has a note at the shop phone field:

Required mobile phone number if want use service "Delivery confirmation SMS to sender".

We do not want to receive the confirmation SMS about the delivery, but that is not a reason for the actual shipment to not work. I couldn't find such "Delivery confirmation SMS to sender" option though, so I'm not sure if it's enabled or disabled for our shop.


You can see that in version 1.14, the plugin set the mobile phone only if additional services were used and required the mobile phone: https://github.com/mijora/omniva-woocommerce/blob/0b3baa498db8aac64bbadca6fab2a44254644e77/omniva-woocommerce/core/class-api.php#L82

And the shop's phone was always added just as a regular phone: https://github.com/mijora/omniva-woocommerce/blob/0b3baa498db8aac64bbadca6fab2a44254644e77/omniva-woocommerce/core/class-api.php#L133

In version 1.15 you're trying to send shop's phone as a mobile phone for all cases.

markakk commented 8 months ago

Hello,

After thinking about the situation you described, it would actually be possible to make 2 phone fields, one of which would be for receiving SMS messages (added as an element "mobile"), and the other for a contact (added as an element "phone"). Please contact Omniva regarding this issue.

JanisE commented 7 months ago

Thank you, the sender's phone works all right now. And the receiver's phone number is checked during the checkout if "Check phone format" is enabled.