question

quseapp avatar image
quseapp asked David Marginian Deactivated edited

Apply discount on the order using Rest API

Trying to apply a discount amount on the order and it doesn't work when I use update order API.

Discounts
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.

David Marginian avatar image David Marginian ♦♦ commented ·

What does "doesn't work" mean? Are you getting an error, if so what is it? What environment are you working in? What is the request you are making?

0 Likes 0 ·
David Marginian avatar image
David Marginian Deactivated answered

Please see the "Add Discounts" section in our working with orders documentation - https://docs.clover.com/clover-platform/docs/working-with-orders

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.

quseapp avatar image quseapp commented ·

Thanks that worked. In the API reference I see lineitemId as required so it was confusing. I am able to apply the discount on the order now.

0 Likes 0 ·
quseapp avatar image
quseapp answered David Marginian Deactivated edited

Using sandbox environment. Directly applying discount from api reference page. Getting 200 response but it is not updating the order. I am sending discount name and amount (-200)

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.

David Marginian avatar image David Marginian ♦♦ commented ·

It is not clear to me what "not updating the order" means. What are you expecting to see? Have you seen our working with orders documentation - https://docs.clover.com/clover-platform/docs/working-with-orders? You may want to take a look at the "calculating order totals" section. If reading this doesn't help send the complete request in a private comment/post (see the sticky).

0 Likes 0 ·
quseapp avatar image
quseapp answered David Marginian Deactivated edited

Order discount didn't get updated when I called the below API.

Below is the request

curl --request POST \
  --url 'https://sandbox.dev.clover.com/v3/merchants/VV5REWPA9BWE1/orders/K01J9CNJGNEH0?access_token=<scrubbed>' \
  --header 'content-type: application/json' \
  --data '{"discounts":[{"discount":{},"approver":{},"name":"QuSe","amount":-100}]}'

Below is the response 200 OK.

{"href":

"https://sandbox.dev.clover.com/v3/merchants/VV5REWPA9BWE1/orders/K01J9CNJGNEH0"

"id":

"K01J9CNJGNEH0"

"currency":

"USD"

"employee":{

...

}"total":

1409

"externalReferenceId":

"C7F5E0"

"title":

"QuSe Order"

"note":

"Takeout-ASAP 1111111111"

"taxRemoved":

false

"isVat":

false

"state":

"OPEN"

"manualTransaction":

false

"groupLineItems":

true

"testMode":

false

"createdTime":

1589057464000

"clientCreatedTime":

1589057464000

"modifiedTime":

1589057463000

}

10 |2000

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