joshbmarshall / auspost

Australia Post API for PHP
MIT License
5 stars 2 forks source link

result is not array on getAccountDetails using eparcel account number #4

Open tashantukin opened 1 year ago

tashantukin commented 1 year ago

Hi, i tried to use an eparcel account number and it seems to add an 220F on the response. am I missing something?

Thanks,

joshbmarshall commented 1 year ago

are you using the api from the Auspost Business account?

tashantukin commented 1 year ago

Hi @joshbmarshall thanks for replying. I am not really sure. how can I check that? ive tried to use the endpoint from postman and it works fine.

joshbmarshall commented 1 year ago

This library uses the endpoints at digitalapi.auspost.com.au - does that match what you're using?

tashantukin commented 1 year ago

this is the response from Postman, I think you are right about the austpost

{
    "account_number": "2001191933",
    "name": "DEMO - AusPost",
    "valid_from": "2017-11-01",
    "valid_to": "2999-01-01",
    "expired": false,
    "addresses": [
        {
            "type": "MERCHANT_LOCATION",
            "lines": [
                "1 Main Street"
            ],
            "suburb": "MELBOURNE",
            "postcode": "3000",
            "state": "VIC",
            "country": "AU"
        }
    ],
tashantukin commented 1 year ago

image

joshbmarshall commented 1 year ago

Have you set the test mode correctly?

tashantukin commented 1 year ago

yes, I have set it totrue, this is where is it giving a non array response, with 220F, image image

joshbmarshall commented 1 year ago

can you debug up the chain, ie what is $this->getResponse() , what is coming back from Auspost? see if you can find where the 220f comes in

tashantukin commented 1 year ago

hi @joshbmarshall i think it is coming from here, sorry I am not familiar with sockets image

tashantukin commented 1 year ago

hi @joshbmarshall in any case, do you have any idea why that 220f is showing up on the response? thanks.

joshbmarshall commented 1 year ago

The only way I can see it in the response is if the api was sending it to you. Have you tried a different php version or platform?

jp135i commented 1 year ago

Hi Josh,

Thanks for all your hard work on this library.

I am seeing the same sort of behaviour but with different prefix characters - I have seen both "2001" and "399d" and then what looks like a correct response, however not the full response as it seems to be cut off.

Here is my response in php (some specific details edited) => "399d {"account_number":"2010000000","name":"DEMO - AusPost","valid_from":"2017-11-01","valid_to":"2999-12-31","expired":false,"addresses":[{"type":"MERCHANT_LOCATION","lines":["1 Main Street"],"suburb":"MELBOURNE","postcode":"3000","state":"VIC","country":"AU"}],"details":{"is_sscc_non_standard_barcode_enabled_international":"false","email_address":"emailaddress@company","is_location":"false","is_sscc_non_standard_barcode_enabled":"false","is_on_demand":"false","is_sender_distribution_state_override":"false","contact_number":"","account_source":"AUSPOST"},"postage_products":[{"type":"EXPRESS EPARCEL ID&V 2","group":"Express Post","product_id":"XID2","contract":{"valid_from":"2017-11-01","valid_to":"2999-12-31","expired":false,"volumetric_pricing":false,"max_item_count":0,"cubing_factor":250},"authority_to_leave_threshold":500.0,"features":{"TRANSIT_COVER":{"type":"TRANSIT_COVER","attributes":{"rate":1,"included_cover":0,"maximum_cover":5000},"price":{"calculated_gst":0.00,"calculated_price":0.00,"calcula"

If I use ThunderClient in vscode if don't receive the prefix characters and get a full correct response.

I am using PHP Version 7.4.3-4ubuntu2.19

Can I provide you any further information to help resolve this?

Cheers,

joshbmarshall commented 1 year ago

Hi folks, the code was working for me on all the versions of PHP I tested on 7.2 through to 8.2

The original code using sockets is what AusPost recommended when I wrote the library. But it's not very nice.

So I just rewrote these parts to use curl and added a unit test to help with testing.

Can you confirm whether this gets the library working for you? If so I'll create a new release.

joshbmarshall commented 1 year ago

Actually have just release 1.2.0 - the code is much nicer. I'd like your feedback if it gets your issue resolved