I have a fully working Magento 2 website, now I want to use the API to create a mobile application so I am using rest api to checkout and place and order.
The problem in the shipping-information
api which does not return order items and order totals so i can show them in the mobile app checkout page.
The flow I am using is like this:
1- get customer token using this api POST {{base_url}}/integration/customer/token
2- create quote for customer using this api POST {{base_url}}/carts/mine
which return quote_id
3- add items to cart using this api POST {{base_url}}/carts/mine/items
and the request body is
{
"cartItem":{
"qty":1,
"quoteId":"87846",
"sku":"8681124614421"
}
}
and the response is
{
"item_id": 48508,
"sku": "8681124614421",
"qty": 2,
"name": "MUSK Eau De Parfum 100 ml",
"price": 644.07,
"product_type": "simple",
"quote_id": "87846"
}
4- calls estimate shipping method as follow POST {{base_url}}/carts/mine/estimate-shipping-methods
request body:
{
"address": {
"street": [
"dsfsdf"
],
"city": "aaasdd",
"region": "",
"country_id": "TR",
"postcode": "12345",
"firstname": "aaa",
"lastname": "bbb",
"telephone": "3213510",
"custom_attributes": [
{
"attribute_code": "student",
"value": "",
"label": " "
}
],
"save_in_address_book": 1
}
}
and response is:
[
{
"carrier_code": "dhl",
"method_code": null,
"carrier_title": "DHL",
"amount": 0,
"base_amount": null,
"available": false,
"error_message": "This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.",
"price_excl_tax": 0,
"price_incl_tax": 0
},
{
"carrier_code": "flatrate",
"method_code": "flatrate",
"carrier_title": "Flat Rate",
"method_title": "Fixed",
"amount": 10,
"base_amount": 10,
"available": true,
"error_message": "",
"price_excl_tax": 8.47,
"price_incl_tax": 10
}
]
5- finally where the problem is, i call POST {{base_url}}/carts/mine/shipping-information
with this request body:
{
"addressInformation": {
"shipping_address": {
"countryId": "TR",
"region": "",
"street": [
"dsfsdf"
],
"telephone": "3213510",
"postcode": "12345",
"city": "aaasdd",
"firstname": "owais",
"lastname": "hamouda",
"saveInAddressBook": 1,
"customAttributes": [
{
"attribute_code": "student",
"value": "",
"label": " "
}
]
},
"billing_address": {
"customerAddressId": "206",
"countryId": "TR",
"regionId": "43",
"regionCode": null,
"region": "Turkey",
"customerId": "492",
"street": [
"160 1st St."
],
"company": "Sawaftech",
"telephone": "516-555-1111",
"fax": null,
"postcode": "11501",
"city": "Mineola",
"firstname": "Jane",
"lastname": "Doe",
"middlename": null,
"prefix": null,
"suffix": null,
"vatId": null,
"customAttributes": []
},
"shipping_method_code": "flatrate",
"shipping_carrier_code": "flatrate",
"extension_attributes": {}
}
}
and the response is:
{
"payment_methods": [
{
"code": "iyzipay",
"title": "Kredi/Banka Kartı ile Ödeme"
},
{
"code": "banktransfer",
"title": "Banka Havalesi Ödeme"
},
{
"code": "cashondelivery",
"title": "Cash On Delivery"
},
{
"code": "stripe_payments",
"title": "Stripe"
}
],
"totals": {
"grand_total": 0,
"weee_tax_applied_amount": null,
"items": [],
"total_segments": [
{
"code": "subtotal",
"title": "Subtotal",
"value": 0
},
{
"code": "shipping",
"title": "Shipping & Handling",
"value": null
},
{
"code": "tax",
"title": "Tax",
"value": 0,
"extension_attributes": {
"tax_grandtotal_details": []
}
},
{
"code": "grand_total",
"title": "Grand Total",
"value": null,
"area": "footer"
}
]
}
}
Here as you see the totals and sub totals, grand totals, items not returned from the api.
I also tried calling the collect-totals api, and totals api and didn’t get any value.
I am stuck on this issue for two weeks now, please help and advice what could be the problem, or how can i trace it or debug it if it is from an installed plugin for example.
Please note all the api calls i called it with header Authorization Bearer <customer token>
And note that the flow from the website is working correctly.