Syncing Refunds from Shopify to NetSuite without refund line items
Many times the refunds are created as mere order adjustments in Shopify. These refunds will not have any refund line items as none of the items are removed from line while creating the refund. When I try to sync these refunds into netsuite I get following error:
"Failed to save record because Please enter value(s) for: Tax Code"
I suspect it is expecting at least one refund line item for refund.
Is there any way we can refund the order even when the refund line items are not present in original refund in shopify.
The Sample data will look like this:
{
"id": 830234427469,
"admin_graphql_api_id": "gid://shopify/Refund/830234427469",
"created_at": "2022-02-08T20:54:07Z",
"note": "Customer forgot to apply buy 2 for 15% off ",
"order_id": 4086571040845,
"processed_at": "2022-02-08T20:54:07Z",
"restock": false,
"total_duties_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
},
"user_id": 71563444301,
"order_adjustments": [
{
"id": 189365878861,
"amount": "-12.70",
"amount_set": {
"shop_money": {
"amount": "-12.70",
"currency_code": "USD"
},
"presentment_money": {
"amount": "-12.70",
"currency_code": "USD"
}
},
"kind": "refund_discrepancy",
"order_id": 4086571040845,
"reason": "Refund discrepancy",
"refund_id": 830234427469,
"tax_amount": "0.00",
"tax_amount_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
}
}
],
"transactions": [
{
"id": 5125836111949,
"admin_graphql_api_id": "gid://shopify/OrderTransaction/5125836111949",
"amount": "12.70",
"authorization": "re_3KQK4rR0AGNaxj5N1wmDF6qo",
"created_at": "2022-02-08T20:54:05Z",
"currency": "USD",
"device_id": null,
"error_code": null,
"gateway": "shopify_payments",
"kind": "refund",
"location_id": null,
"message": "Transaction approved",
"order_id": 4086571040845,
"parent_id": 5124119560269,
"payments_refund_attributes": {
"status": "success",
"acquirer_reference_number": "24011342040000021598649"
},
"processed_at": "2022-02-08T20:54:05Z",
"receipt": {
"id": "re_3KQK4rR0AGNaxj5N1wmDF6qo",
"amount": 1270,
"balance_transaction": {
"id": "txn_3KQK4rR0AGNaxj5N1n0rPYrD",
"object": "balance_transaction",
"exchange_rate": null
},
"charge": {
"id": "ch_3KQK4rR0AGNaxj5N16oSqJXF",
"object": "charge",
"amount": 8468,
"application_fee": "fee_1KQK4sR0AGNaxj5NKamTRXDP",
"balance_transaction": "txn_3KQK4rR0AGNaxj5N1dZbGtox",
"captured": true,
"created": 1644189810,
"currency": "usd",
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"livemode": true,
"metadata": {
"shop_id": "27506769997",
"shop_name": "Everie Woman",
"transaction_fee_total_amount": "212",
"transaction_fee_tax_amount": "0",
"payments_charge_id": "1966995341389",
"order_transaction_id": "5124119560269",
"manual_entry": "false",
"order_id": "c30706037751885.2",
"email": "tdsummers58@gmail.com"
},
"outcome": {
"network_status": "approved_by_network",
"reason": null,
"risk_level": "normal",
"seller_message": "Payment complete.",
"type": "authorized"
},
"paid": true,
"payment_intent": "pi_3KQK4rR0AGNaxj5N1xRdzCWD",
"payment_method": "pm_1KQK4rR0AGNaxj5NCxXhISMj",
"payment_method_details": {
"card": {
"amount_authorized": 8468,
"brand": "visa",
"checks": {
"address_line1_check": "pass",
"address_postal_code_check": "pass",
"cvc_check": "pass"
},
"country": "US",
"description": "Visa Traditional",
"ds_transaction_id": null,
"exp_month": 7,
"exp_year": 2024,
"fingerprint": "aH7vhw43lnQcbAF7",
"funding": "credit",
"iin": "486895",
"installments": null,
"issuer": "Barclays Bank Delaware",
"last4": "3135",
"moto": null,
"network": "visa",
"network_token": null,
"network_transaction_id": "582037842109221",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"refunded": false,
"source": null,
"status": "succeeded",
"mit_params": {
"network_transaction_id": "582037842109221"
}
},
"object": "refund",
"reason": null,
"status": "succeeded",
"created": 1644353646,
"currency": "usd",
"metadata": {
"order_transaction_id": "5125836111949",
"payments_refund_id": "85398454349"
},
"payment_method_details": {
"card": {
"acquirer_reference_number": null,
"acquirer_reference_number_status": "pending"
},
"type": "card"
},
"mit_params": {}
},
"source_name": "1830279",
"status": "success",
"test": false,
"user_id": 71563444301,
"payment_details": {
"credit_card_bin": "486895",
"avs_result_code": "Y",
"cvv_result_code": "M",
"credit_card_number": "•••• •••• •••• 3135",
"credit_card_company": "Visa"
}
}
],
"refund_line_items": [],
"duties": [],
"order": {
"cancel_reason": null,
"cancelled_at": null,
"currency": "USD",
"financial_status": "partially_refunded",
"presentment_currency": "USD",
"processing_method": "direct",
"discount_applications": []
},
"calculatedRefundDiscount": 0,
"sourceTransactionIds": "re_3KQK4rR0AGNaxj5N1wmDF6qo"
}
Comments
Sujit Desai We also have this problem. Have you been able to solve this one on your own?
We see this frequently when a customer discount was missed, and then added in as an order-level refund, or even when doing a partial refund – say customer orders 2 and only 1 is in stock, then they cancel the backorder.
I was thinking there might be a handlebars expression that can be mapped with some if/then type of logic. Something along the lines of IF refund_line_items[*].line_item_id is null, THEN map a generic non-fulfillable item into the credit memo. My handlebars skills are a little limited so I'm hoping someone out there has already built a solution.
Please sign in to leave a comment.