Carrier Service doesn't Take Rates from Private App

Haith1
Tourist
5 0 4

Hi, 

 

CONDITION: 

I have created a CarrierService using the Shopify carrier service API(https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/carrierservice) after satisfying all requirements. The carrier service was created successfully with ID : 33798553653. 

 

We have tested our rates calculation app through sending postman requests to the call back url (https://script.google.com/macros/s/AKfycbyMgR0FJjaBpX2Ga1YES0yoXaR3mljBzPanIwwFaRtMh-hdrfg/exec) and it was successful. A sample request and response is below: 

carrier request and response sample 1.JPG
sample response:
{
    "rates": [
        {
            "service_name""محمول للنقل المبرد",
            "service_code""MH",
            "total_price""29.00",
            "description""خلال 1 الى 3 ايام عمل",
            "currency""SAR"
        },
        {
            "service_name""سمسا للنقل السريع",
            "service_code""4k",
            "total_price""29.00",
            "description""خلال 1 الى 3 ايام عمل",
            "currency""SAR"
        }
    ]
}
 
ISSUE

When a user is checking out in our store, our web app receives requests from Shopify and the app creates responses similar to the above. However Shopify doesn't display the shipping options that are there in the response in the shipping section of the checkout. Not sure what the issue is. Would really appreciate having help with this. 

Thanks,

 

 
Replies 23 (23)

Haith1
Tourist
5 0 4

Does anyone know what the issue is. We did alot of trouble shooting and tried different things to find what can be the issue but have not had success until now. 

_JB
Shopify Staff
836 100 222

Hey @Haith1,

A couple things you can check:

- Make sure you enabled shipping rates from your app in the shop's shipping settings

- Make sure you're responding to rate requests in < 10s, otherwise we consider the request a timeout

If those don't explain the issue, try testing again but replace the Arabic characters with latin A-Z characters. I have a hunch the issue could be due to the non-UTF-8 characters in the response. If it works after you replace the characters, please let me know and provide the X-Request-ID value from the response headers of your call, and I'll raise this with our teams to find out next steps.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Haith1
Tourist
5 0 4

Hi @_JB , 

 

Thank you for the reply. We have checked the points you mentioned. We still have not been successful. Here is what we did: 

- Make sure you enabled shipping rates from your app in the shop's shipping settings

we have the following setting in our store: 

 

shipping setting.JPG

 

We also used (GET:   /admin/api/2020-10/carrier_services.json) and got the following response: 

{
    "carrier_services": [
        {
            "id"33798553653,
            "name""Shipping Rate Calculator",
            "active"true,
            "service_discovery"true,
            "carrier_service_type""api",
            "admin_graphql_api_id""gid://shopify/DeliveryCarrierService/33798553653",
            "format""json",
        }
    ]
}
 
Please let us know if we might have missed something there. 
 

- Make sure you're responding to rate requests in < 10s, otherwise we consider the request a timeout:

Requests are normally responded to within 1.5 seconds. See below: 

response duration.JPG

 -Try testing again but replace the Arabic characters with latin A-Z characters.

We replaced the app response to the following: 

{
    "rates": [
        {
            "service_name""canadapost-overnight",
            "service_code""ON",
            "total_price""1295",
            "description""This is the fastest option by far",
            "currency""CAD",
            "min_delivery_date""2020-12-17 14:48:45 -0400",
            "max_delivery_date""2020-12-19 14:48:45 -0400"
        }
    ]
}
 
That didn't solve the issue. Rates still don't show at checkout. We replaced CAD with SAR as well and it still didn't work.
 
I am still not sure what the issue is. We would highly appreciate your support. 
 
Thanks,
 
_JB
Shopify Staff
836 100 222

Hey @Haith1,

Please provide a few example URLs from checkouts where you've observed the issue, and I can investigate further.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Haith1
Tourist
5 0 4

Hi @_JB , 

Thank you for the reply. 

 

The issue happens in all checkouts. The app rates in the response  are not shown at the checkout. Only the store rates are shown. 

Here is a test order page: https://tamrahstore.com/14252146752/orders/f9d3fa839083ce974c893e9fe9e67e29/authenticate?key=a896c5a...

 

during the checkout, the shop was loading shipping rates and our app received a request as seen in the below screenshot: 

Haith1_0-1608287615829.png

 

 the app response is as follows: 

{
"rates": [
{
"service_name": "محمول للنقل المبرد",
"service_code": "MH",
"total_price": 2900,
"description": "خلال 1 الى 3 ايام عمل",
"currency": "SAR"
},
{
"service_name": "شركة برق للتوصيل السريع",
"service_code": "2D",
"total_price": 2900,
"description": "توصيل بنفس اليوم أو يوم العمل التالي",
"currency": "SAR"
}
]
}

 

Then, the shop selected to display a shipping rate from our store not from the url response: 

Haith1_1-1608287783172.png

 

Please let us know if there is any more info you might need to identify the source of this issue.  

 

Thanks,

 

 

 

_JB
Shopify Staff
836 100 222

Hey @Haith1,

I checked the logs and the issue is happening because your server is responding with a 302 status code. Shopify expects the carrier service to respond with a 2XX response, anything other than a 200-level response is considered an error. 

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

URLify-me
Excursionist
17 0 2

@_JB 

Hello, I have exactly the same problem, could you please check the logs regarding my endpoint/callback URL:

https://h20gl-prod.huck-sarl.com/__bootstrap_endpoint.php

 ?

_JB
Shopify Staff
836 100 222

Hey @URLify-me,

Kindly provide a checkout token/URL from a test shop where you're replicating the issue, and I'll use this to get details from our logs.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

URLify-me
Excursionist
17 0 2

@_JB https://onlineshop-h20gl.myshopify.com/48534519972/checkouts/4dd05239cc179cfc500e8ff9cf6a49a5

Is this what you need? I'd be so happy if you could help me.

_JB
Shopify Staff
836 100 222

Hey @URLify-me,

Make sure you're sending the required fields in the response. Here's an example of a valid rate response, note the separate fields for amount and currency:

 

 {
           "service_name": "canadapost-overnight",
           "service_code": "ON",
           "total_price": "1295",
           "description": "This is the fastest option by far",
           "currency": "CAD",
           "min_delivery_date": "2013-04-12 14:48:45 -0400",
           "max_delivery_date": "2013-04-12 14:48:45 -0400"
       }

 

 

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

URLify-me
Excursionist
17 0 2

@_JB 

My response is:

 

{
    "rates": [
        {
            "service_name": "canadapost-overnight",
            "service_code": "ON",
            "total_price": "100",
            "description": "CarrierService description",
            "currency": "EUR",
            "min_delivery_date": "2021-02-12 14:48:45 -0400",
            "max_delivery_date": "2021-03-12 14:48:45 -0400"
        }
    ]
}

 

 Still doesn't work, see: https://onlineshop-h20gl.myshopify.com/48534519972/checkouts/a78059add8fa11068e5fb1c5d297eb5c?previo...

The (incomplete) documentation (https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/carrierservice) says anyway, that min_delivery_date and max_delivery_date aren't required. Could you please check the logs?

_JB
Shopify Staff
836 100 222

Hey @URLify-me,

I checked the logs originally and thought you were sending the currency field incorrectly, but I was mistaken. I looked at your rate response again and it seems fine, I was able to copy/paste your response JSON into my test app and the rate was returned at checkout as expected. 

On your store the logs show we're receiving your rate, but the rate is being rejected for some reason. The logs don't show a reason, but this normally happens when some data in the response is invalid (for example, returning a currency that the store doesn't use).

In order to investigate further, I'd like to make a few calls to your endpoint from my own test store. Please confirm if the endpoint is still active, and if there's anything in particular I need to send in my request to get rates back.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

URLify-me
Excursionist
17 0 2

@_JBHey, thanks so much for your efforts, it would avoid a lot of trouble for me if we could fix the problem together.

The endpoint is still active and publicly accessible. Please tell me if you need to know the URL. It runs over HTTPS.

You don't need to authenticate nor send any header, but you should post raw JSON data in the body (like Shopify does), e.g.:

 

{
    "rate": {
        "origin": {
            "country": "FR",
            "postal_code": "12345",
            "province": "",
            "city": "test city",
            "name": null,
            "address1": "test address",
            "address2": null,
            "address3": null,
            "phone": "",
            "fax": null,
            "email": null,
            "address_type": null,
            "company_name": "Test company"
        },
        "destination": {
            "country": "FR",
            "postal_code": "12345",
            "province": null,
            "city": null,
            "name": null,
            "address1": null,
            "address2": null,
            "address3": null,
            "phone": null,
            "fax": null,
            "email": null,
            "address_type": null,
            "company_name": null
        },
        "items": [
            {
                "name": "Boîte à coin type SEL",
                "sku": "26301812",
                "quantity": 3,
                "grams": 1161,
                "price": 2600,
                "vendor": "test vendor",
                "requires_shipping": true,
                "taxable": true,
                "fulfillment_service": "manual",
                "properties": {},
                "product_id": 6087563772091,
                "variant_id": 37580786335931
            }
        ],
        "currency": "EUR",
        "locale": "fr"
    }
}

 

 

 

_JB
Shopify Staff
836 100 222

Hey @URLify-me,

It's working fine on my test store: 

15-23-q8brq-18jll

I'm racking my brain but can't think of what could cause a rate to be rejected on one store but not another. It's a holiday here today so most of us are out of the office, but I'll check with some colleagues tomorrow and let you know what we find. If you'd like to continue testing in the meantime, you can try opening a new development store or even a regular 14 day trial shop, and install your app there. 

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

_JB
Shopify Staff
836 100 222

Hey @URLify-me,

We figured out the missing rates are due to a shipping setting being used by your test shop. The shop currently has 1 active delivery profile, with rates setup for 1 country. In your admin navigate to Settings > Shipping > Manage rates, scroll to where your app is shown and click "Edit rate", and a modal will appear with the checkbox:

16-30-shx5m-mh4i3

With this unchecked, your app is unable to return rates at checkout. I tried creating multiple different carrier services in my test shop with different params, and in all cases they were created with this setting enabled by default, so I imagine this was manually disabled on your test shop at some point. Once it's re-enabled you will see your rates at checkout as expected.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

URLify-me
Excursionist
17 0 2

@_JB 

Thank you very much, this fixed the problem. Thanks for investing time in testing and posting the solution.

One tip for the future:

When I was reading all the old posts regarding the Carrier Service API here on the forums, many people get confused because your API documentation is lacking details like this option called "FUTURE SERVICES".  It seems that the doc hasn't been updated regarding their questions. For example it is often not clear which content types, formats of the data values, HTTP method, HTTP response codes, HTTP or HTTPS are used.

Keep up the good work.

daMask
Shopify Partner
15 0 6

Actual weeks, I've spent on this. From a third party developer, to Shopify Support chat, no one was able to tell me why I couldn't get this working. I'm so frustrated, as it makes no sense, but thankful to have uncovered your solution. Thankyou.

I don't believe it was manually disabled, I would like to know how to make sure its enabled, using the API, what is this setting?

Sanjay-Makwana
Shopify Partner
29 0 3

@daMask  I have same issue.

you able to resolves the issue ?

daMask
Shopify Partner
15 0 6

I was able to solve this, are you still stuck?

Sanjay-Makwana
Shopify Partner
29 0 3

@daMask I have fixed some levels but still have not gotten the complete solution.

https://community.shopify.com/c/shopify-apis-and-sdks/how-to-register-carrierservice-to-app/m-p/1543...

daMask
Shopify Partner
15 0 6

That linked issue looks different to the one I was having.

Sanjay-Makwana
Shopify Partner
29 0 3

@daMask   you can post your questions  with full detail so else can help you.  

Sanjay-Makwana
Shopify Partner
29 0 3

@_JB  

Thanks for the your details answer, but i have still same issue. i can see the the.  

GET
/admin/api/2022-01/carrier_services.json

 

I will get the correct carrier  services.

 

but still on the checkout page i am not able to see the shipping career. 
 

 

call back url get response within 3-4 seconds 

SanjayMakwana_0-1648812028631.png