SaleRefund results in 400 OutOfBalance Error -0.01

myroslavpomazanmyroslavpomazan Member Posts: 7

Hello,

We've been having strange issues refunding sales through Retail API, some of the refunds result in

{"httpCode":"400","httpMessage":"Bad Request","message":"Cannot complete an out of balance sale. Refunds are insufficient.","errorClass":"OutOfBalanceError","saleID":"******","balance":"-0.01"}

Url used: .../Account/{accountID}/Sale/1234/refund

Parameters passed in: paymentTypeID

Lightspeed Retail UI shows same balances on both sales, original and created refund sale. Any help would be appreciated. Thank you!

3 comments

  • gregaricangregarican Member Posts: 500 

    I would recommend querying the Sale API endpoint for Sale ID 1234, and reviewing the API response. Then look at your API request's body to ensure that the SaleRefund is defined correctly. Are you just defining the bare minimum? In other words, not specifying sale lines and whatnot?

  • myroslavpomazanmyroslavpomazan Member Posts: 7

    @graceann Yep, bare minimum. Just paymentType ID that needs to be refunded, no sale lines or anything else.

  • gregaricangregarican Member Posts: 500 

    I read up on the API documentation, and it seemed odd. Since most API requests are looking for JSON whereas this is looking for XML, as least based on the examples --> https://developers.lightspeedhq.com/retail/endpoints/Sale-refund/.

    I rang a dummy sale in the web UI and then processed a refund using the API. I had to specify an employeeID, a registerID, and a shopID. In addition to specifying the paymentTypeID.

    Here's a paste of the successful API request/response below. Hope this helps!

    POST https://api.merchantos.com/API/Account/{my_account_id}/Sale/11720/refund HTTP/1.1

    Content-Type: application/xml

    Authorization: Bearer {my_access_token}

    User-Agent: PostmanRuntime/7.26.1

    Accept: */*

    Host: api.merchantos.com

    Accept-Encoding: gzip, deflate, br

    Connection: keep-alive

    Content-Length: 265

    Cookie: __cfduid=d106feae401be185e07c6808602a804651592493887


    <?xml version="1.0"?>

    <Refund>  

     <employeeID>26</employeeID>  

     <registerID>2</registerID>  

     <shopID>2</shopID>  

     <SalePayments>   

      <SalePayment>    

       <paymentTypeID>1</paymentTypeID>   

      </SalePayment>  

     </SalePayments>

    </Refund>

    HTTP/1.1 200 OK

    Date: Thu, 25 Jun 2020 17:43:04 GMT

    Content-Type: application/vnd.merchantos.pos-v1+xml

    Content-Length: 3946

    Connection: keep-alive

    x-frame-options: SAMEORIGIN

    X-XSS-Protection: 1; mode=block

    X-Content-Type-Options: nosniff

    X-LS-Acct-Id: {my_account_id}

    X-LS-OAuth-Client-Id: 64577

    X-LS-API-Bucket-Level: 10/100

    X-LS-Shard-Id: 18

    X-LS-API-Drip-Rate: 5

    X-LS-Master-Account: true

    X-LS-Master-System: false

    X-LS-Master-Catalog: false

    Vary: Accept-Encoding

    CF-Cache-Status: DYNAMIC

    cf-request-id: 038e2c830900007fa0ba315200000001

    Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"

    Server: cloudflare

    CF-RAY: 5a907d1808807fa0-ORD


    <?xml version="1.0"?>

    <Sale><saleID>11722</saleID><timeStamp>2020-06-25T17:43:03+00:00</timeStamp><discountPercent>0</discountPercent><completed>true</completed><archived>false</archived><voided>false</voided><enablePromotions>true</enablePromotions><isTaxInclusive>false</isTaxInclusive><createTime readonly="true">2020-06-25T17:43:03+00:00</createTime><updateTime readonly="true">2020-06-25T17:43:03+00:00</updateTime><completeTime>2020-06-25T17:43:03+00:00</completeTime><referenceNumber/><referenceNumberSource/><tax1Rate>0.075</tax1Rate><tax2Rate>0</tax2Rate><change currency="USD">0</change><receiptPreference>printed</receiptPreference><displayableSubtotal currency="USD" readonly="true">-0.01</displayableSubtotal><ticketNumber readonly="true">220000011722</ticketNumber><calcDiscount currency="USD" readonly="true">0</calcDiscount><calcTotal currency="USD" readonly="true">-0.01</calcTotal><calcSubtotal currency="USD" readonly="true">-0.01</calcSubtotal><calcTaxable currency="USD" readonly="true">-0.01</calcTaxable><calcNonTaxable currency="USD" readonly="true">0</calcNonTaxable><calcAvgCost currency="USD" readonly="true">0</calcAvgCost><calcFIFOCost currency="USD" readonly="true">0</calcFIFOCost><calcTax1 currency="USD" readonly="true">0</calcTax1><calcTax2 currency="USD" readonly="true">0</calcTax2><calcPayments currency="USD" readonly="true">-0.01</calcPayments><total currency="USD" readonly="true">-0.01</total><totalDue currency="USD" readonly="true">-0.01</totalDue><displayableTotal currency="USD" readonly="true">-0.01</displayableTotal><balance currency="USD" readonly="true">0</balance><customerID>478</customerID><discountID>0</discountID><employeeID>26</employeeID><quoteID>0</quoteID><registerID>2</registerID><shipToID>0</shipToID><shopID>2</shopID><taxCategoryID>1</taxCategoryID><SaleLines><SaleLine><saleLineID>14572</saleLineID><createTime>2020-06-25T17:43:03+00:00</createTime><timeStamp>2020-06-25T17:43:03+00:00</timeStamp><unitQuantity>-1</unitQuantity><unitPrice currency="USD">0.01</unitPrice><normalUnitPrice currency="USD">0</normalUnitPrice><discountAmount currency="USD">0</discountAmount><discountPercent>0</discountPercent><avgCost currency="USD">0</avgCost><fifoCost currency="USD">0</fifoCost><tax>true</tax><tax1Rate>0.075</tax1Rate><tax2Rate>0</tax2Rate><isLayaway>false</isLayaway><isWorkorder>false</isWorkorder><isSpecialOrder>false</isSpecialOrder><displayableSubtotal currency="USD" readonly="true">-0.01</displayableSubtotal><displayableUnitPrice currency="USD" readonly="true">0.01</displayableUnitPrice><calcLineDiscount currency="USD" readonly="true">0</calcLineDiscount><calcTransactionDiscount currency="USD" readonly="true">0</calcTransactionDiscount><calcTotal currency="USD" readonly="true">-0.01075</calcTotal><calcSubtotal currency="USD" readonly="true">-0.01</calcSubtotal><calcTax1 currency="USD" readonly="true">-0.00075</calcTax1><calcTax2 currency="USD" readonly="true">0</calcTax2><taxClassID>1</taxClassID><customerID>0</customerID><discountID>0</discountID><employeeID>26</employeeID><itemID>0</itemID><noteID>0</noteID><parentSaleLineID>14571</parentSaleLineID><shopID>2</shopID><saleID>11722</saleID></SaleLine></SaleLines><SalePayments><SalePayment><salePaymentID>7462</salePaymentID><amount currency="USD">-0.01</amount><createTime>2020-06-25T17:43:04+00:00</createTime><archived>false</archived><remoteReference/><paymentID/><saleID>11722</saleID><paymentTypeID>1</paymentTypeID><ccChargeID>0</ccChargeID><refPaymentID>0</refPaymentID><registerID>2</registerID><employeeID>26</employeeID><creditAccountID>0</creditAccountID><PaymentType><paymentTypeID>1</paymentTypeID><code>Cash</code><name>Cash</name><requireCustomer>false</requireCustomer><archived>false</archived><internalReserved>true</internalReserved><type readonly="true">cash</type><refundAsPaymentTypeID>0</refundAsPaymentTypeID></PaymentType></SalePayment></SalePayments><taxTotal>0</taxTotal></Sale>

Sign In or Register to comment.