"Money can only be created with a numeric value!" error when creating a refund sale

stormearthfirestormearthfire Member Posts: 2
Hi all, we implemented integration of Lightspeed Retail and Magento via Lightspeed Retail API. Basically, we're pushing orders both ways, products from Lightspeed to Magento, customers and, of course, refunds (or creditmemos in Magento).

For almost past 2 years everything worked well, including refunds which we created as a regular Sale object with negative totals and SaleLines with negative quantity. 

Now, we are getting the mentioned error but we are not sure why are we getting it and where it originates.
The creditmemo parameters were the same as always, and also we made a test case - we created one refund in the Lightspeed system directly, and then used those same parameter values to make an API created refund and still getting the error.

I know that Refund call is included in the API now, but that doesn't do us much favor because Sales it creates are not completed, nor they include SaleLine quantites and do not put them back in stock.

Any info and clarification about this error would be highly helpful.

Thank you.

3 comments

  • messhiasmesshias Member Posts: 35
    Can you share your object? Because I have the same problem for payments and deposit in users account.

    For example my json was:


    {
       value: "10"
    }

    But the correct is:
    {
      value: 10 OR 10.00
    }

    I'm php developer too, and we have take care of with that because the php has auto casting, but the api endpoint doesn't have probably.
  • stormearthfirestormearthfire Member Posts: 2
    Sure, this is the json object that is being sent as request parameter

    {  
       "timeStamp":"2019-01-11 16:57:02",
       "completed":true,
       "archived":false,
       "voided":false,
       "enablePromotions":false,
       "isTaxInclusive":false,
       "referenceNumber":"",
       "referenceNumberSource":"",
       "receiptPreference":"printed",
       "customerID":"22881",
       "discountID":0,
       "employeeID":2,
       "quoteID":0,
       "registerID":1,
       "shopID":1,
       "taxCategoryID":0,
       "ticketNumber":"",
       "discountPercentage":0,
       "change":0,
       "displayableSubtotal":-275,
       "total":-291.89,
       "totalDue":-291.89,
       "displayableTotal":-291.89,
       "taxTotal":0,
       "balance":0,
       "Customer":{  
          "customerID":"22881",
          "firstName":"Test",
          "lastName":"Testest",
          "archived":false,
          "title":null,
          "company":null,
          "companyRegistrationNumber":"",
          "vatNumber":null,
          "Contact":{  
             "noEmail":false,
             "Addresses":{  
                "ContactAddress":{  
                   "address1":"Test Street",
                   "city":"New York",
                   "state":"New York",
                   "zip":"10009"
                }
             },
             "Phones":{  
                "ContactPhone":{  
                   "number":"123-123123",
                   "useType":"Home"
                }
             },
             "Emails":{  
                "ContactEmail":{  
                   "address":null,
                   "useType":"Primary"
                }
             }
          }
       },
       "ShipTo":{  
          "shipped":false,
          "shipNote":"Magento Creditmemo: 100000007l Magento Order: 100000041; Order Status:closed; Payment Method: checkmo; Shipping Method: fedex_FEDEX_2_DAY",
          "firstName":"Relja",
          "lastName":"Damnjanovic",
          "company":null
       },
       "SalePayments":{  
          "SalePayment":{  
             "amount":-291.89,
             "paymentTypeID":11,
             "registerID":1,
             "employeeID":2
          }
       },
       "SaleLines":{  
          "SaleLine":[  
             {  
                "unitQuantity":-1,
                "unitPrice":"16.8900",
                "normalUnitPrice":"16.8900",
                "tax":false,
                "tax1Rate":0,
                "tax2Rate":0,
                "isLayaway":false,
                "displayableSubtotal":-16.89,
                "displayableUnitPrice":-16.89,
                "calcLineDiscount":0,
                "calcTransactionDiscount":0,
                "calcTotal":-16.89,
                "calcSubtotal":-16.89,
                "calcTax1":0,
                "calcTax2":0,
                "customerID":"22881",
                "itemID":9267
             },
             {  
                "unitQuantity":-1,
                "unitPrice":"275.0000",
                "normalUnitPrice":"275.0000",
                "discountAmount":null,
                "tax":false,
                "tax1Rate":0,
                "tax2Rate":0,
                "isLayaway":false,
                "displayableSubtotal":-275,
                "displayableUnitPrice":-275,
                "calcLineDiscount":null,
                "calcTransactionDiscount":0,
                "calcTotal":-275,
                "calcSubtotal":-275,
                "calcTax1":0,
                "calcTax2":0,
                "customerID":"22881",
                "itemID":"39632"
             }
          ]
       }
    }


    I understand what you mean, though in my example we only have "unitPrice" and "normalUnitPrice" with quotes around the value. 
    I'll make some tests to see if that is the issue.

    I'm wondering if minus sign is making problems.
  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 569 moderator
    @stormearthfire This looks like a response and not a payload since there's a lot of information that doesn't seem necessary. Unless I'm mistaken, when referencing a refund all you need is the shop, register, and the SalePayments object. Could you perhaps do a manual test and show me the payload and the subsequent response, even if it is an error

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

Sign In or Register to comment.