question

flevour avatar image
flevour asked flevour commented

Clarification on refunds

I'm having issues figuring out how to issue a full refund (including taxes and tips) for an order placed via ecommerce.


This is the order

{
  "href": "https://sandbox.dev.clover.com/v3/merchants/9J6KZT8WJY661/orders/YV9DSEWZ0AVVA",
  "id": "YV9DSEWZ0AVVA",
  "currency": "USD",
  "customers": {
    "elements": [
      {
        "href": "https://sandbox.dev.clover.com/v3/merchants/9J6KZT8WJY661/customers/X4C2BDPB0A95G",
        "id": "X4C2BDPB0A95G",
        "orderRef": {
          "id": "YV9DSEWZ0AVVA"
        },
        "firstName": "Francesco",
        "lastName": "Levorato",
        "marketingAllowed": false,
        "customerSince": 1611136751000
      }
    ]
  },
  "employee": {
    "id": "7TBFY37TSCNR6"
  },
  "total": 125,
  "paymentState": "PAID",
  "title": "Online Store - 10",
  "note": "Pickup, Online Store, Dash #10",
  "taxRemoved": false,
  "isVat": false,
  "state": "OPEN",
  "manualTransaction": false,
  "groupLineItems": true,
  "testMode": false,
  "createdTime": 1611138369000,
  "clientCreatedTime": 1611138369000,
  "modifiedTime": 1611138381000,
  "lineItems": {
    "elements": [
      {
        "id": "RE4YKDQCS5ZAP",
        "orderRef": {
          "id": "YV9DSEWZ0AVVA"
        },
        "item": {
          "id": "7K645N1Q583JY"
        },
        "name": "Basic Item",
        "price": 100,
        "note": "",
        "printed": false,
        "createdTime": 1611138381000,
        "orderClientCreatedTime": 1611138369000,
        "exchanged": false,
        "refunded": false,
        "isRevenue": true
      }
    ]
  },
  "payments": {
    "elements": [
      {
        "id": "44EE9RVZ1PZDR",
        "order": {
          "id": "YV9DSEWZ0AVVA"
        },
        "tender": {
          "href": "https://sandbox.dev.clover.com/v3/merchants/9J6KZT8WJY661/tenders/ESS67YW2XKDD2",
          "id": "ESS67YW2XKDD2"
        },
        "amount": 125,
        "tipAmount": 20,
        "taxAmount": 5,
        "cashbackAmount": 0,
        "employee": {
          "id": "7TBFY37TSCNR6"
        },
        "createdTime": 1611138374000,
        "clientCreatedTime": 1611138374000,
        "modifiedTime": 1611138374000,
        "offline": false,
        "result": "SUCCESS"
      }
    ]
  }
}


I can't refund the charge directly because it includes tips (in fact if I don't include a tip, I can refund it just fine.

POST https://scl-sandbox.dev.clover.com/v1/refunds HTTP/1.1
Authorization: Bearer ***REDACTED***
Content-Type: application/json
accept-encoding: gzip, deflate
content-length: 91

{
  "charge": "44EE9RVZ1PZDR",
  "amount": 125,
  "reason": "requested_by_customer"
}

HTTP/1.1 400 Bad Request
{
  "message": "400 Bad Request",
  "error": {
    "type": "invalid_request_error",
    "code": "processing_error",
    "message": "Partial refund for order with multiple line items/tip/convenience fee or tax amount is not supported by this api, Please use /v1/orders/{id}/returns api."
  }
}


API response gives instructions to use the endpoint, which I can call using the information listed in here https://community.clover.com/questions/26686/sandbox-ecommerce-partial-refunds-returns-http-500.html to return a single item

POST https://scl-sandbox.dev.clover.com/v1/orders/YV9DSEWZ0AVVA/returns HTTP/1.1
User-Agent: vscode-restclient
Authorization: Bearer ***REDACTED***
Content-Type: application/json
accept-encoding: gzip, deflate
content-length: 135

{
  "items": [
    {
      "parent": "RE4YKDQCS5ZAP",
      "type": "sku",
      "amount": 100
    }
  ]
}


HTTP/1.1 200 OK
{
  "id": "YV9DSEWZ0AVVA",
  "amount": 125,
  "amount_returned": 100,
  "currency": "USD",
  "items": [
    {
      "type": "sku",
      "parent": "RE4YKDQCS5ZAP",
      "amount": 100
    }
  ],
  "status": "returned",
  "status_transitions": {}
}


This is where I stop.


What I can't figure out is how do I refund taxes and tips?


Thanks!

Refund
10 |2000

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

1 Answer

David Marginian avatar image
David Marginian Deactivated answered flevour commented

Have you tried not passing in a total to the refunds endpoint?

1 comment
10 |2000

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

flevour avatar image flevour commented ·

It didn't occur to me to try that, it worked!

0 Likes 0 ·

Welcome to the
Clover Developer Community