Capture payment callback returns 422 Unprocessable Entity In Url_CallBack Response

Shopify Partner
4 0 0

While trying to capture a payment through a payment gateway we're getting http 422 (Unprocessable Entity) as a response from the post to the callback url. Currently all our payments are being created within a developer store (test).

The x_reference is set as the one we got from the redirection after completing the checkout.

x_gateway_reference is preserved as is from the value received in the post to the capture endpoint

Could anybody point us in the right direction to solve the issue?


Thanks in advance





Headers: {'Content-Length': '381', 'Content-Type': 'application/x-www-form-urlencoded'}

Body: x_account_id=2822a1be8bacff37d4925373eb3e3a1377e4b8ff&x_amount=228.64&x_currency=USD&x_gateway_reference=5c4a18e6cf72513121b65dad&x_message=Settle+ID%3A+5c4a18e6cf72513121b65dad&x_reference=7660277596257&




Headers: Server: nginx
Date: Thu, 24 Jan 2019 20:02:40 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
X-Sorting-Hat-Podid: 96
X-Sorting-Hat-Podid-Cached: 0
X-Sorting-Hat-Shopid: 7385972833
X-Sorting-Hat-Privacylevel: default
X-Sorting-Hat-Featureset: default
X-Sorting-Hat-Section: pod
X-Sorting-Hat-Shopid-Cached: 0
X-Frame-Options: DENY
X-Shopid: 7385972833
X-Shardid: 96
Strict-Transport-Security: max-age=315569520; includeSubdomains
X-Request-Id: ed0e0657-6151-4542-b8f4-2d653dc00fff
X-Shopify-Stage: production
Content-Security-Policy: frame-ancestors 'none'; report-uri /csp-report?source%5Baction%5D=notify_integration&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=services%2Fping&source%5Bsection%5D=services&source%5Buuid%5D=ed0e0657-6151-4542-b8f4-2d653dc00fff
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
X-Xss-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=notify_integration&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=services%2Fping&source%5Bsection%5D=services&source%5Buuid%5D=ed0e0657-6151-4542-b8f4-2d653dc00fff
X-Dc: ash,gcp-us-east1

Body: Unable to find pending transaction with id 7660277596257
Status: HTTP 422: Unprocessable Entity




Shopify Staff
Shopify Staff
1555 79 241

Hey @pablo_fr,


I believe you might want to be using the `capture` or `authorization` transaction_types instead for non-order management requests.


If the issue is specific to your async callback, first ensure it is occurring after you're sending the customer back to the checkout. If you're already doing this and still receiving the error, it's possible that instead of ignoring the async callback when the transaction was already successful, we're failing instead which isn't very pretty.


Let me know if I'm misunderstanding anything though!



Shopify Partner
4 0 0

Hey Alex,


Thank you for your prompt response.

Currently the flow goes as follows: after finishing the payment on our gateway, we

* update checkout billing address at Shopify

* execute callback

* get Shopify order details and update order's shipping details

* last, redirect to 'x_url_complete'


The process seems to be working fine in every occasion from checkout's perspective. Order is created properly and in the right status ('authorized').

Now the capture still fails on every attempt.


If I change the order of the requests, such as executing callback after redirecting the user back to checkout, get order details always returns empty.

I'm having troubles figuring out what's wrong in the call's order or even in their content that's causing the issue.

May be you can point me to a specific documentation that describes in detail the full checkout flow including redirection, call order execution and payload examples. The documentation I managed to access describes very lightly how the payment gateway should behave. 


Shopify Staff
Shopify Staff
1555 79 241

So unless I'm misunderstanding, this issue is occurring for you during the order management phase of the order's lifecycle. By that I mean you're trying to capture an already authorized transaction which was created via the checkout. What does your flow look like here? You should be:


  1. Receiving the POST request, performing whatever logic you need to before...
  2. Respond with a JSON body containing the response values necessary
  3. At the same time, scheduling an asynchronous callback with the same response values to give to Shopify in case the response did not work as intended
    1. The asynchronous callback at this time appears to 422 if your response was sent and parsed by Shopify successfully. I'm looking into this one.

Let me know how that sounds and if I'm missing any details. Feel free to give me an example order by ID I can reference to get a picture of the flow in our logs. Just make sure your example has occurred within the past 7 days.

Shopify Partner
4 0 0

The flow we implemented goes as follows:


After attempting to capture a payment on Shopify admin site, the request hits our payment gateway

on the capture handler.

We perform our internal logic and execute the callback BEFORE returning the response.

The response we're providing contains no payload and it's simply an HTTP 200 one. The strange thing

is it used to work with an older implementation that followed same steps.

And swapping the order (first returning a successful response and then executing the callback)

has no effect

Shopify Partner
4 0 0

and here you have some sample orders we created:



Order #: 1178 (Checkout id: #7667166707809)
Order #: 1178 (Checkout id: #7663622652001

Shopify Staff
Shopify Staff
1555 79 241

Thanks for that info Pablo, I've reported this to the applicable parties and will update here when I have more to share.