4

I just wanted to test this API for understanding order flow

{  "addressInformation": {
      "shipping_address": {
       "region": "New York",
       "region_id": 43,
       "region_code": "NY",
       "country_id": "US",
       "street": [
      "123 Oak Ave"
    ],
    "postcode": "10577",
    "city": "Purchase",
    "firstname": "Jane",
    "lastname": "Doe",
    "email": "[email protected]",
    "telephone": "512-555-1111"
  },
  "billing_address": {
    "region": "New York",
    "region_id": 43,
    "region_code": "NY",
    "country_id": "US",
    "street": [
      "123 Oak Ave"
    ],
    "postcode": "10577",
    "city": "Purchase",
    "firstname": "Jane",
    "lastname": "Doe",
    "email": "[email protected]",
    "telephone": "512-555-1111"
  },
  "shipping_carrier_code": "tablerate",
  "shipping_method_code": "bestway"
  }
}

but with above payload given in devdocs it show error:

"message": "Carrier with such method not found: %1, %2",
"parameters": [ "tablerate", "bestway" ],

how can it be tested?

2

1 Answer 1

0

First of all, you have to check available shipping methods by making this call:

POST /rest/default/V1/carts/mine/estimate-shipping-methods

with the following body (example):

{
"address": {
    "country_id": "PL",
    "street": [
      "..."
    ],
    "postcode": "...",
    "city": "..."
  }    
}

Don't forget to add a header:

Authorization: Bearer [customer token]

And sample response:

[
  {
    "carrier_code": "flatrate",
    "method_code": "flatrate",
    "carrier_title": "Flat Rate",
    "method_title": "Fixed",
    "amount": 50,
    "base_amount": 50,
    "available": true,
    "error_message": "",
    "price_excl_tax": 50,
    "price_incl_tax": 50
  }
]

Then you have to just put method_code and carrier_code

Full flow:

  1. Get customer token POST /rest/default/V1/integration/customer/token
  2. Create shopping-cart POST /rest/default/V1/carts/mine
  3. Add item to shopping-cart POST /rest/default/V1/carts/mine/items
  4. Get shipping information
  5. Set up shipping
  6. Set up a payment method

PS. I've stuck on setting up payments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.