Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Getting 422 Unacceptable Entity error (mentioned in Step 3 below) These are the steps to get the error: 1) Creating the checkout Object URL -> POST https://harry-potter.myshopify.com/admin/checkouts.json HEADERS -> X-Shopify-Access-Token(xxx) Content-Type(application/json) BODY -> { "checkout":{ "email": "asdf@asdf.org", "line_items": [{ "variant_id": 31134652389, "quantity": 1 }], "billing_address": { "first_name": "Harry", "last_name": "Potter", "address1": "4 Privet Drive", "city": "Little Whinging", "province_code": "SU", "country_code": "UK", "phone": "8444437443", "zip": "201301" }, "shipping_address": { "first_name": "Harry", "last_name": "Potter", "address1": "4 Privet Drive", "city": "Little Whinging", "province_code": "SU", "country_code": "UK", "phone": "8444437443", "zip": "201301" }, "requires_shipping": false } } We are getting 202 Accepted code 2) We process transactions on credit cards by relying on a separate card vaulting endpoint. Your app submits the credit card to the vault, and the vault returns a payment session_id that your app can use to create a payment for the credit card. URL-> POST https://elb.deposit.shopifycs.com/sessions HEADER-> Content-Type: application/json Accept: application/json BODY-> { "payment": { "amount": "10.0", "unique_token": "Harry1233", "credit_card": { "number": "4242424242424242", "month": "12", "year": "2023", "verification_value": "256", "first_name": "Harry", "last_name": "Potter" } } } We are getting 200 Ok status code and return the session_id 3) Completing the checkout URL-> POST https://harry-potter.myshopify.com/admin/checkouts/{checkout_token}/payments.json checkout_token-> received in first step HEADERS -> X-Shopify-Access-Token(xxx) Content-Type(application/json) Accept(application/json) BODY-> { "payment": { "request_details": { "ip_address": "111.93.122.70", "accept_language": "en-US", "user_agent": "Chrome/54.0.2840.98" }, "amount": "10.00", "session_id": {coming from 2nd step above}, "unique_token": "Harry1233" }, "requires_shipping": false } We are getting following 422 Unprocessable Entity every time { "errors": { "session_id": [ { "code": "invalid", "message": "is invalid", "options": {} } ] } } Why is this "unprocessable"?
Hi @Kevin107 ,
The 422 "Unacceptable/Unprocessable Entity" error could be thrown for many different reasons, such as having an incorrectly formatted input or trying to checkout products which are out of stock. In order for us to help narrow down what might be causing this, would it be possible for you to share the value of the "X-Request-ID" header from Shopify's 422 status response? With this value I can go through the Shopify platform logs and investigate why exactly this response was sent. If you can't provide this header value, providing your Shop ID and the approximate time frame when this error occurred will also help too!
To learn more visit the Shopify Help Center or the Community Blog.
Hey @Kevin107 ,
Thank you for providing the X-Request-ID! From looking through our platform logs, it appears to me that this 422 error is being thrown because when Shopify queries for the session_id provided from your payments.json POST request it is getting a "Resource Not Found" error.
One thing I have observed from our logs that may be causing this error to occur, is that I have noticed that the session_id you are passing through the POST request follows a format of "east-{hashcode}". Could you test and see what happens if you drop the "east-" component of this string and just pass along the hashcode as the session ID? This may possibly help resolve the issue.
Also if you could provide the value of the "X-Request-ID" header for the POST request to the https://elb.deposit.shopifycs.com/sessions endpoint, that would be helpful too. Thanks!
To learn more visit the Shopify Help Center or the Community Blog.
@hassain
I have tried by removing "east-" from session_id still getting 422 error and below is the response and "X-Request-Id " is "27d70811-68fd-44ce-9998-c183fa73a7cf"
{ "errors": { "session_id": [ { "code": "invalid", "message": "is invalid", "options": {} } ] } }
https://elb.deposit.shopifycs.com/sessions endpoint i am not getting "X-Request-ID" below are the headers we are getting
Server →nginx Date →Wed, 20 Nov 2019 05:28:56 GMT Content-Type →application/json Transfer-Encoding →chunked Connection →close Vary →Accept-Encoding Access-Control-Allow-Origin →* Strict-Transport-Security →max-age=31536000; includeSubDomains; preload P3P →CP="NOI DSP COR NID ADMa OPTa OUR NOR" Content-Encoding →gzip
Hi Jeff,
Today we have tried with the two options to complete the checkout flow
requires_shipping READ-ONLY | "requires_shipping": true Whether the checkout requires shipping. If true, then shipping_line must be set before creating a payment. |
@hassain
When we create order by checkout api while enabling shopify payment then order is displaying in orders tab of store admin but if we do same thing by enabling stripe payment then the order checkout api is completed but it doesn't show in the order's tab.
@hassain Also when payment is completed the how we will check that payment is processed successfully
Hi @Kevin107 ,
when payment is completed the how we will check that payment is processed successfully
One possible solution is make a GET request to the Shopify Admin API endpoint of "/admin/api/2019-10/orders/#{order_id_of_completed_payment}.json", and then check the field of "fin.... If the "financial_status" is set to `authorized` or `paid`, then you would that they payment has been processed successfully.
When we create order by checkout api while enabling shopify payment then order is displaying in orders tab of store admin but if we do same thing by enabling stripe payment then the order checkout api is completed but it doesn't show in the order's tab
That is very strange behaviour - all completed orders should appear in the orders tab regardless of which payment gateway was used. Can you provide specifics which might help us investigate why this is happening? (i.e. any relevant X-Request-IDs, Order IDs, approximate timeframes, etc). Also, can you verify if those orders that do not show up in the Order's tab appear under the "Abandoned Checkouts" tab?
can you please confirm if we set requires_shipping = false then why we need shipping line.
To learn more visit the Shopify Help Center or the Community Blog.
For require shipping false here is request id
X-Request-Id →71b5a173-f403-4ebc-8933-9848ca944f5a
Request Body
{ "checkout":{ "email": "akhtar.ali+22@kiwitech.com", "line_items": [{ "variant_id": 31447125590094, "quantity": 1 }], "billing_address": { "first_name": "Akhtar Test sdfs", "last_name": "Order", "address1": "B-9, Sector 3", "city": "Noida", "province_code": "UP", "country_code": "IN", "phone": "8447737843", "zip": "201301" } }, "requires_shipping": false }
Response we get
{ "checkout": { "completed_at": null, "created_at": "2019-12-04T05:49:01-05:00", "currency": "USD", "presentment_currency": "USD", "customer_id": 2785870577742, "customer_locale": "en", "device_id": null, "discount_code": null, "email": "akhtar.ali+22@kiwitech.com", "legal_notice_url": null, "location_id": null, "name": "#12114394251342", "note": "", "note_attributes": {}, "order_id": null, "order_status_url": null, "order": null, "payment_due": "10.00", "payment_url": "https://elb.deposit.shopifycs.com/sessions", "payments": [], "phone": null, "shopify_payments_account_id": "acct_1Ez0WbCNlo40OyHu", "privacy_policy_url": null, "refund_policy_url": null, "requires_shipping": true, "reservation_time_left": 0, "reservation_time": null, "source_identifier": null, "source_name": "3066999", "source_url": null, "subscription_policy_url": null, "subtotal_price": "10.00", "shipping_policy_url": null, "tax_exempt": false, "taxes_included": false, "terms_of_sale_url": null, "terms_of_service_url": null, "token": "3ca4bd51b8559115f360d96ec8d5d8fb", "total_price": "10.00", "total_tax": "0.00", "total_tip_received": "0.00", "total_line_items_price": "10.00", "updated_at": "2019-12-04T05:49:01-05:00", "user_id": null, "web_url": "https://topfantest.myshopify.com/25649152078/checkouts/3ca4bd51b8559115f360d96ec8d5d8fb", "line_items": [ { "id": "b7386f19f76952598fcb9c42ad4e9230", "key": "b7386f19f76952598fcb9c42ad4e9230", "product_id": 4421075664974, "variant_id": 31447125590094, "sku": "", "vendor": "topfantest", "title": "Polo T Shirt", "variant_title": "Medium / Blue", "image_url": "https://cdn.shopify.com/s/files/1/0256/4915/2078/products/download_3.jpg?v=1575438326", "taxable": false, "requires_shipping": true, "gift_card": false, "price": "10.00", "compare_at_price": null, "line_price": "10.00", "properties": {}, "quantity": 1, "grams": 0, "fulfillment_service": "manual", "applied_discounts": [] } ], "gift_cards": [], "tax_lines": [], "tax_manipulations": [], "shipping_line": null, "shipping_rate": null, "shipping_address": null, "credit_card": null, "billing_address": { "id": 5497545130062, "first_name": "Akhtar Test sdfs", "last_name": "Order", "phone": "8447737843", "company": null, "address1": "B-9, Sector 3", "address2": null, "city": "Noida", "province": "Uttar Pradesh", "province_code": "UP", "country": "India", "country_code": "IN", "zip": "201301" }, "applied_discount": null } }
still we are getting require "requires_shipping": true
Hey @akhtarkiwi ,
To learn more visit the Shopify Help Center or the Community Blog.
@hassain Ok, got it.
I have one question regarding calculation of shipping cost for draft order.
For draft order if we have to add shipping_line
"shipping_line": { "handle": "shopify-Standard%20Shipping-8.00", "price": 0.0, "title": "Free Shipping" }
I am unable how we find this handle, but i am able to get all carrier services of the stores by using below api
/admin/api/2019-10/carrier_services.json
Can you please help me in this
Hey @akhtarkiwi ,
I believe this endpoint should hopefully help you get what you are looking for:
https://help.shopify.com/en/api/reference/sales-channels/checkout#shipping_rates-2019-10
Let me know if this helps or not!
To learn more visit the Shopify Help Center or the Community Blog.
@hassain Yes we can find shipping rates, but we have to created a checkout for it. I want to know that is there an api to calculate these shipping rates for draft order? We don't want to create a checkout then fetch the shipping rates.
As in shop admin we can attach shipping rates to draft order. Please see the attached screenshots
@hassain
When i am creating checkout i am getting "Checkout System disabled" error and code is "403".
below are the info you might required
X-Request-ID -> 28a944d0-4132-48ca-bbea-3cb415bf02f3
Store is -> topfantest.myshopify.com
Its urgent can you please check what is the reason for it
Could you share the code you are using to make that second request? I am getting a 422 error on that one.