New Shopify Certification now available: Liquid Storefronts for Theme Developers

shopify api refund and cancel

a120715
Visitor
1 0 0

i want to cancel and refund order using python when Im refunding iget this response 
POST https://xxxxxxxtest.myshopify.com/xxxx/api/2022-07/orders/xxxxxx/cancel.json
POST https://xxxxxxxtest...

rder is canceling succesful but Payment Status is paid and no refunded: its my code 

order = shopify.Order.find(order_id)
order.cancel()
order.save()
refund = shopify.Refund({
"note": "Refund for cancelled order",
"order_id": order.id,
"amount": order.total_price,
"shipping": {
"full_refund": True
},
"refund_line_items": [
{
"line_item_id": order.line_items[0].id,
"quantity": order.line_items[0].quantity,
"location_id": None,
"restock_type": "no_restock"
}
]
})
refund.save() 

Replies 0 (0)