question

tmly2006 avatar image
tmly2006 asked David Marginian Deactivated edited

Rest api: Applied discounts on a order doesn't affect total payment.

xnip2021-03-17-03-45-45.jpg

3 items is $15

tax: $1.39

discounts: $-1

but the total payment is: $16.39

Discounts
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 David Marginian Deactivated edited

Update:

I had a minute so I looked into this. It appears you are using the ecomm api to create an order and then immediately after creation you use the v3 api to add a discount to it. You then pay for the order later (v1/order/{orderId}/pay). Is that correct? I pinged the EComm team about this, but I am not certain it is a bug. The order/pay endpoint only calculates a total if a total has not already been set. And, in this case the total is set when the order is created. I would recommend creating the order in one shot using https://docs.clover.com/reference#ordercreateatomicorder and then using the v1/order/{orderId}/pay endpoint, which should work and result in a properly calculated order total. Let me know.

Original:

Please take a look at our guidelines - https://community.clover.com/page/community-guidelines. You are leaving out a lot of critical details here such as how is the order being created, how is it being paid for, are you setting the total or are you relying on us to? What environment are you working in, etc. etc.


2 comments
10 |2000

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

Thanks for the reply.

In this case I used ecomm api (NODEJS) to create the order items like this

order.items = {
  items:[{
    tax_rates = [{
          "id": merchant.taxId,
          "name": merchant.taxLabel,
          "rate": merchant.taxRate
    }]
    quantity = item.quantity
    currency = 'usd'
    type = 'sku'
    description = 'item despcription'
    amount = item.unitPrice * 100

  }]
}

After the order is created, I can't find a way to apply my discounts with Ecomm api, so I used '/v3/merchants/${mid}/orders/${orderId}/discounts' to add discounts. Then I used '/v1/orders/${cloverOrder.cloverId}/pay' Ecomm api to pay.


0 Likes 0 ·

Right, so follow the advice I gave you in my answer above and let me know how that works for you.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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