Set order as paid using Shopify Python API

1k views Asked by At

I have orders that were placed with Shopify, but were paid with an external payment system. I am trying to mark them as paid using the Python API, but am getting a 406 response when saving the transaction. The private app in the store has read and write set for Orders API

shop_url = "https://%s:%[email protected]/admin/api/%s" % (API_KEY, PASSWORD, API_VERSION) 
shopify.ShopifyResource.set_site(shop_url)

shop = shopify.Shop.current();

order = shopify.Order.find_first(name="#20204512"); 
trans = shopify.Transaction.find_first(order_id=order.id); 
new_transaction = shopify.Transaction(); 
#new_transaction.currency = "CAD";
new_transaction.kind = "capture" 
#new_transaction.status = "paid" 
#new_transaction.gateway = "manual" 
new_transaction.amount = "10.00"; 
new_transaction.parent_id = trans.id;
new_transaction.save();
1

There are 1 answers

0
Saurabh Sinha On

Python API has an issue.
Add the following line before saving:

new_transaction._prefix_options ={"order_id" : order.id}

This will resolve the 406 error.