question

vadique avatar image
vadique asked David Marginian commented

Ecommerce API Discounts on Order Invalid JSON

Using ecomm API we create an order via scl.clover.com/v1/orders and then pay for it with source via scl.clover.com/v1/orders/{ID}/pay .

We need to apply a discount to the order. There is a "discount type" in SCL order create for item, however there is no explanation on using "type=discount" and trying to add a discount as Item to an order throws 400 "invalid JSON Format" error, even though JSON is definitely properly formatted -- this is both on sandbox AND live. We tried various combinations of properties for "discount" item - none of which worked.


Reference:

https://docs.clover.com/clover-platform/reference/orders#postorders


POST:

curl --request POST \

--url https://scl-sandbox.dev.clover.com/v1/orders \

--header 'accept: application/json' \

--header 'authorization: Bearer ************' \

--header 'content-type: application/json' \

--data '{"items":[{"type":"sku","amount":200,"currency":"usd","description":"test 2 buck","quantity":1},{"amount":100,"currency":"usd","quantity":1,"type":"discount"}],"metadata":{"metakey":"metaval"},"currency":"usd","email":"foo@foobar.com"}'

e-commerce apiDiscounts
3 comments
10 |2000 characters needed characters left characters exceeded

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

I am looking into this. In your initial post you mentioned you tried using the v3 endpoint but received a 500, is that still accurate? Can you provide more details?

0 Likes 0 ·
vadique avatar image vadique David Marginian ♦♦ ·

500 was on a sandbox scl/v1/orders/{id}/pay when trying to pay for an order ID created via sandbox.../v3/orders. v3 order create itself works fine.

we'd prefer to use scl/v1/orders to create, provided we can add a type=discount. so far it seems that only "type=sku" and "type=shipping" are working. trying to add item with "type=tax" throws a 400 that tax can not be added (is there a plan to allow that?) and trying to add an item with "type=discount" throws 400 invalid json.

0 Likes 0 ·

Can you provide me with the request details of the failing request (moderators only post), or re-execute the request and give me your merchant id (moderators only post) so I can check the logs?

0 Likes 0 ·

1 Answer

David Marginian avatar image
David Marginian answered David Marginian commented

"discount" type is not currently supported via the scl/v1/orders endpoint. Our documentation team made a fix so that this doesn't mislead anyone else. You will need to use the v3/orders endpoint to create the order. If you have a problem with that please post request details and I can look into it.

5 comments
10 |2000 characters needed characters left characters exceeded

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

So just to clarify:

1. ecommerce API currently only supports type=sku and type=shipping (type=tax also returns 400, albeit "unsupported" not "invalid"), which means we can create only very simple orders without an ability to add tax or discounts, unless we actually recalculate item pricing ourselves to include tax/discount before order create and stick it in meta possibly.

2. there seems to be a new ability to add "tip", can we expect tax/discount to be added (are they on the roadmap?) .

3. to create "proper" orders (i.e. with discounts, taxes, etc) we should use rest-api v3/orders and then use SCL to pay


Sorry for the edit - i could swear i saw an ability to add "app-charge/fee" to SCL order or payment - is that no longer available, or did I dream that? Just wondering if we are to charge merchants a % of transaction or flat transaction fee - would we do that through metered billing then as an option?

0 Likes 0 ·

1) I will look into this.

2) Not 100% sure if this is on the roadmap, I will ask the ecomm team.

3) Yes

0 Likes 0 ·

Discount is not on the current roadmap. However, supporting tax is.

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community