Jump to content

Unable to Create Receipt


Adnan_Mughal

Recommended Posts

I am trying to create receipt by sending following data to this endpoint: https://api.loyverse.com/v1.0/receipts.

However, I am getting this error that I am not sending UUID in object.payments.

Error Message:

{"errors":[ {

         "code":"INVALID_VALUE_TYPE",

          "details":"The value must be an UUID",

          "field":"object.payments (line: 1, column: 369)"

}]}

My Request Data:

[
    'store_id' => '0de6be20-4008-4511-bfe5-d9b8854620e5',
    'order' => 250972528,
    'customer_id' => '62b73367-bcd8-49e7-ke8e-696947052c72',
    'source' => 'website',
    'receipt_date' => '2021-03-12T16:06:12.000Z',
    'note' => NULL,
    'total_discounts' => [],
    'line_items' => [
      0 => [
        'variant_id' => '62955a68-38fa-45ad-bd3e-68c9985fbe96',
        'quantity' => 1,
        'price' => 13,
        'cost' => 13,
        'line_note' => 'test order',
        'details' => '',
      ],
    ],
    'payments' => [
      'payment_type_id' => 'fc52f1b2-31cf-4f51-ba40-c165c1273282',
      'paid_at' => '2021-03-12T16:06:12.000Z',
    ],
]

I am sure that payment_type_id is in proper UUID format but I am completely stuck at this point coz there is no clue that what actually is with this request data.

Link to comment
Share on other sites

Looks like your json covered by square brackets, like array of receipts.

In loyverse API endpoint /receipts recognize only single receipt in curly brackets.

like:

{

"store_id": "bfbbde8a-ceb5-4494-8968-24b446aa8ac7",

"employee_id": null,

"source": null,

"name": null,

"order": "257",

"receipt_date": null,

"customer_id": null,

"line_items": [

{

"variant_id": "dc64eea9-f218-489b-a505-3d29ed770144",

"quantity": 2,

"line_note": null,

"price": 300.0,

"line_taxes": []

}

],

"note": null,

"payments": [

{

"payment_type_id": "fc52f1b2-31cf-4f51-ba40-c165c1273282222",

"paid_at": null

}

]

}

Edited by Jay Rock
Link to comment
Share on other sites

Really thanks for quick reply Sir!

I double checked my request and it seems that request data that I posted originally is correct. You are seeing wrong brackets because I took it from my logs and pasted here. However, following is the JSON encoded version of that request:

{"store_id":"bfbbde8a-ceb5-4494-8968-24b446aa8ac7","order":250972528,"customer_id":"62f73367-bbd8-49e7-ae8e-696947052c72","source":"website","receipt_date":"2021-03-12T16:06:12.000Z","note":null,"total_discounts":[],"line_items":[{"variant_id":"62955a68-38fa-45ad-bd3e-68c9985fbe96","quantity":1,"price":13,"cost":13,"line_note":"test order","details":null}],"payments":{"payment_type_id":"FC52F1B2-31CF-4F51-BA40-C165C1273282","paid_at":"2021-03-12T16:06:12.000Z"}}  

Also, if brackets were wrong then error should be some "syntax" related but not UUID error.  

Edited by Adnan_Mughal
Link to comment
Share on other sites

Since, I was stuck and desperately wants to solve it so I did that intentionally, the actual dump that I am sending in Postman as following:

{
  "store_id": "bfbbde88-cebb-4494-8968-24b446aa8ac7",
  "order": 250972528,
  "customer_id": "62f73367-bbd8-49e7-ae8e-696947052c72",
  "source": "website",
  "receipt_date": "2021-03-12T16:06:12.000Z",
  "note": null,
  "total_discounts": [
  ],
  "line_items": [
    {
      "variant_id": "62955a68-38fa-45ad-bd3e-68c9985fbe96",
      "quantity": 1,
      "price": 13,
      "cost": 13,
      "line_note": "test order",
      "details": null
    }
  ],
  "payments": {
    "payment_type_id": "fc52f1b2-31cf-4f51-ba40-c165c1273282",
    "paid_at": "2021-03-12T16:06:12.000Z"
  }
}  

Please check screen shot for payment-id and response from the API. I strongly believes that there is same issue on the API's side where they are validating the UUID string which is sending that false error.

image.thumb.png.845c54775fe8069f8e502e40fd046c66.png

 

Link to comment
Share on other sites

Wow, this actually resolved my problem. However, if error message pointed us to exact error like "REQUIRD PARAMETER SHOULD BE AN ARRAY" etc. Then it would be much better. Anyways, thank you.

Link to comment
Share on other sites

Loyverse Point of Sale

 

 

 

 

×
×
  • Create New...