Can not to create transaction for order using API

I want to create a transaction after I create a previous order using the REST API.

The parameters I submitted are like this:

{
	"transaction": {
		"kind" : "authorization",
		"gateway": "cash", 
		"amount": 764, 
		"order_id" : xxx, 
		"status" : "success"
	}
}

And then I am getting this error:

{
    "errors": {
        "kind": "authorization is not a valid transaction"
    }
}

When I change the value of kind, I get the following error:

capture:

{
    "errors": {
        "base": "No capturable transaction was found""
    }
}

sale:

{
    "errors": {
        "kind": "sale is not a valid transaction"
    }
}

void:

{
    "errors": {
        "base": "An error occurred while processing your request"
    }
}

refund:

{
    "errors": {
        "base": "No refundable transaction was found"
    }
}

How can I create a transaction correctly?

1 Like

Try adding

    "source": "external"

It should work now
Yes, this is undocumented
And yes - Shopify (sometimes) sucks

19 Likes

Thank you so much @Itai-Koren
It worked for us, we were facing this issue from long time but we got the answer from you.
+1 Kudos

@Itai-Koren Thank you so match!

Can confirm this works!

My request to shopify team to document this. I did not expect this from shopify. I wasted a lot of time trying random solutions.

Thanks a lot for the solution!

Thanks! Resolve for me!

thank you this worked, you are a legend.

Confusing, agree…

https://shopify.dev/docs/api/admin-rest/2024-07/resources/transaction#post-orders-order-id-transactions

Is there any way to do the same with the GraphQL API as shopify is sunsetting the Rest API?