question

ben-m avatar image
ben-m asked David Marginian Deactivated commented

Sandbox Ecommerce partial refunds returns HTTP 500

Hi, I'm using the docs from https://docs.clover.com/docs/ecommerce-refunding-payments to handle refunds.


I'm creating orders using the `/v1/orders/{orderId}/pay` endpoint. For the sake of this example, we are using custom items.


If I use the `/v1/refunds`, using the order's charge UUID I can only refund on orders that only have 1 line item, although it works really well.


if I use the `/v1/orders/{orderId}/returns` endpoint, I can do a full refund if I omit any data, however I need partial refund support. The platform we're integrating lets the merchant select the items to refund, lets them adjust any amount(IE: if they don't want to refund taxes).


Any time I do the request and it's not malformed ( It will do an http code 400 if it is ) it returns an HTTP 500 error.

{
  "message": "500 Internal Server Error",
  "error": {
    "type": "api_error",
    "code": "processing_error",
    "message": "Internal Server Error."
  }
} 


Moreso: The only thing I have access to for the refund, is the amount to be refunded. Is there no way to refund an amount like with charges?

know a refund and charge refund are not the same thing, but seeing as ECOM doesn't support multiple payment charges on a single order, it shouldn't matter if there's more than 1 line item on the order, we should still be allowed to refund the charge.

Will this work using Clover inventory items ecommerce orders or if there's anything I should know? Our endpoint for this is currently under maintenance so I can't currently test it.

I'll include the order creation response + requests payloads information in the moderated comment.

e-commerce apiRefund
3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

Hi Ben,

This is possible, but it is not immediately clear how to do it from looking at our documentation and our responses are not helpful either. I will create an issue to correct our documenation and an issue to return better responses (error codes, etc.).

You can do this with non-inventory (I have tested this) or inventory items (I haven't tested this but it should work). For non-inventory items when you are ready to refund the item you will need to retrieve the order via the v3 endpoint and expand lineItems:

/v3/merchants/{ {mid}}/orders/{ {orderId}}?expand=lineItems

You will need to grab the id of the line item that you want to refund. Then you will need to make a request to the returns endpoint (/v1/orders/{ {orderId}}/returns):

{
    "items": [
        {
            "parent": "{
                    {lineItemUUID}}",
            "type": "sku",
            "amount": {
                    {lineItemAmount}}
        }
    ]
}


1 Like 1 ·
ben-m avatar image ben-m David Marginian ♦♦ commented ·

Hi David,


Thank you very much for the fast and, honest and straight to the point answers!

Once the application goes live, with just with the merchants we already have that are interested in it, we will have to request an adjustment to the rate limits, so I'm trying to plan ahead to be as optimised as possible for API calls.

Could you tell me if I'm better off keeping a local copy of those item IDs ( IE: In the Ecommerce platform's order item metadata ) Or is it reasonable to do two API calls per refunds?

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ ben-m commented ·

Either is probably ok.

1 Like 1 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community