question

a-leafiy avatar image
a-leafiy asked David Marginian Deactivated edited

Ecomm api dose not calculate discount amount.

I'm selling some special items which not available in my shop and clover post. So I don't have the item UUID for using atomic order api. So I've tried the ecomm api. It seems work fine for me.


But why not provide an Ecomm discount api? I'm using this api for apply discounts to orders

V3/merchants/${mid}/orders/${orderId}/discounts 

The order details includes the discounts but the price not correct!!

e-commerce apiDiscounts
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.

David Marginian avatar image David Marginian ♦♦ commented ·

Can you provide us with a Clover Order ID please. If in production, please provide the order id in a private/moderators only post (https://community.clover.com/articles/9119/welcome-to-the-clover-developer-community.html). Thank you.

0 Likes 0 ·
a-leafiy avatar image a-leafiy David Marginian ♦♦ commented ·

Hi David. Here is a sandbox order ID: 2BP1M06BHF5V0

0 Likes 0 ·

1 Answer

·
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

The EComm's order API is limited and does not allow you to set a discount when the order is created. You are using the EComm API to create the order and the order's total is properly set at that time. You are then modifying the order and applying a discount in a subsequent call. You are responsible for calculating and properly updating the total if you make any modifications to the order after it has been created (https://docs.clover.com/docs/calculating-order-totals).

As an alternative, you can us the v3/orders endpoints to create the order, add line items, discounts, etc. (https://docs.clover.com/docs/creating-custom-orders) and NOT set a total. You can then use the v1/orders/pay endpoint https://docs.clover.com/docs/ecommerce-accepting-payments#step-02-paying-for-the-created-order which will properly calculate the total. Note, the v1/orders/pay endpoint will ONLY calculate the total if a total has not already been set.


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.

a-leafiy avatar image a-leafiy commented ·

I'm using ecomm api because I'm selling items which I do not want my shop's employees to see them. So I do not have the item UUID to create orders using v3/orders. Is there any other options?

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ a-leafiy commented ·

I understand your situation, and the answer I provided is tailored to it. The two options I outlined are what is available now. Please read the documentation I provided. The v3/orders API works without Clover inventory - https://docs.clover.com/docs/creating-custom-orders#adding-a-custom-line-item.

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