Convert order injection errors to charge errors

This guide outlines the steps needed to build an order injection charge error notification system to alleviate order injection errors and raise them as charge errors.

๐Ÿ“˜

Platform:

  • Custom

An order injection error is defined as an order with a charge that has been successfully processed in Recharge, but the accompanying order is not successfully created in the order management system (OMS). Order injection errors occur due to a gap in the architecture between Recharge and your OMS platform.

For example, your OMS may have different address validation requirements than Recharge, or there may be a lag in deprecating inventory in Recharge versus in your OMS.

If the OMS API returns an error, you can use the charge/refund endpoint to create the charge error for an order. You can then adjust the order by fixing the insufficient inventory from the Recharge merchant portal.

If the OMS API returns an error, you can use the charge/refund endpoint to create the charge error for an order. You can then adjust the order by fixing the insufficient inventory from the Recharge merchant portal.

The following table defines terms used throughout this article.

TermDefinition
Order injectionThe process of receiving an order/created webhook from Recharge and creating that order in your order management system. This is commonly done with recurring orders that process in Recharge, or orders that initially go through the Recharge checkout.
Order injection errorAn order with a charge that has been successfully processed in Recharge, but the accompanying order is not successfully created in the order management system
Missing orderAny Recharge order that does not have an external_order_id

Log and categorize errors

Log and categorize errors returned from your OMS API. During order injection, your order management system may return an error when trying to create an order. Youโ€™ll want to catch and categorize the errors based on error type so that you can accurately report those errors in the charge error.

These errors usually can be categorized into specific reason types:

  • Out of stock inventory errors
  • Exceeds quantity requirements errors
  • Invalid billing or shipping zipcode: Customers might have their billing or shipping address set to a really long string, something that is invalid and is rejected by BigCommerce.

๐Ÿšง

Note:

Not all errors may need to end up as charge errors. For example, if you encounter errors from rate limits, you may need to build retry logic instead of raising a charge error.


Leverage the charge refund endpoint to raise charge errors

Implement the charge refund endpoint for order injection error process. This process will pull order injection errors, then refund and change the charge status to error in one API call.

POST /charges/{id}/refund

Example request payload:

{
    "amount": "18.50",
    "full_refund": true,
    "retry": true,
    "error": "test error message",
    "error_type": "insufficient_inventory"
}

The response will be Recharge's existing charge API response schema. The error_type will be populated with what was passed in the request, and the charge status will be ERROR.

This process will refund the order in Recharge and create a charge error that you can see and manage from the Recharge merchant portal. Access this page by going to the Orders section and clicking the Charge errors tab.


Need Help? Contact Us