Models
Store
Representation
Identifier | Type | Description | Restrections |
---|---|---|---|
countryCode | String | Country Code ISO 3166-1 format | $[A-Z]{2} |
languageCode | String | Language code ISO 639-1 format | [a-z]{2} |
currencyUnit | String | Currency unit ISO 4217 format | [A-Z]{2} |
taxPercentage | Integer | Tax Percentage for store | Min: 0. Max: 40 |
Create store
curl --request PUT \--url https://api.${env}.brinkcommerce.com/productv1/stores \--header 'content-type: application/json' \--header 'x-api-key: ${product api key}' \--data '{"countryCode": "SE","languageCode": "sv","currencyUnit": "SEK","tax": 0}'
Update
Product
Model Product has 4 diffrent type
- product
- productVariant
- shippingProvider
- shippingOption
Create product
curl --request POST \--url https://api.${env}.brinkcommerce.com/productv1/products \--header 'content-type: application/json' \--header 'x-api-key: ${product api key}' \--data '[{"id": "1","name": "Black socks","type": "product","category": "socks",}]'
Create product variant releated to the product
curl --request POST \--url https://api.${env}.brinkcommerce.com/productv1/products \--header 'content-type: application/json' \--header 'x-api-key: ${product api key}' \--data '[{"id": "2","name": "Black socks size 9","type": "productVariant","category": "socks","price": [{"currencyUnit": "SEK","amount": 20000}],"relatedProduct": "1"}]'
GET product
curl --request GET \--url https://api.${env}.brinkcommerce.com/productv1/products/1
GET products
curl --request GET \--url 'https://api.${env}.brinkcommerce.com/productv1/products?ids=1,2'
Update
curl --request PUT \--url https://api.${env}.brinkcommerce.com/productv1/products \--header 'content-type: application/json' \--header 'x-api-key: ${product api key}' \--data '[{"id": "1","slug": "/t-shirt"}]'
Search
All product are indexed in Elasticsearch. We support Elasticsearch query DSL
curl --request POST \--url https://api.${env}.brinkcommerce.com/productv1/products/search \--header 'content-type: application/json' \--header 'x-api-key: ${product api key}' \--data '{"query": {"match": {"name": "t-shirt"}}}'
Cart
Brink commerce handles the cart to provide cart with cartItems and prices.
Create
To create a cart a store and products is needed to populate the cart.
curl --request POST \--url https://api.${env}.brinkcommerce.com/orderv1/carts \--header 'content-type: application/json' \--data '{"products": [{"id": "2","quantity": 1}],"store": {"countryCode": "SE","currencyUnit": "SEK","languageCode": "sv","taxPercentage": 0}}'
Response
{"jwtToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiI4MDNjODlmZC03NDUzLTRmYzUtODFkYy04MzljM2VjZGIxYjEiLCJpYXQiOjE2MDA5NzE5NTEsImV4cCI6MTYwMTIzMTE1MX0.-RJL5EBHakOrZcZXGTLUTnYV0r1RVB-E1u8kDp2gXQ8","productsNotFound": [],"cart": {"cartItems": [{"id": "2","added": "2020-09-24T18:25:51.951Z","name": "t-shirt white","quantity": 1,"price": {"SEK": 20000},"type": "productVariant"}],"totalPriceWithDiscount": 20000,"totalDiscountAmount": 0,"totalPrice": 20000,"discounts": {"rules": [],"productDiscounts": [],"cartDiscount": {"SEK": 0}}}}
The jwtToken is needed for further communication with Brink commerce cart and order. Provide the jwtToken as a Authorization header.
Update
The quantity is updated with the provided quantity number, sedning 0 as quantity and the product is removed. Variants are overloaded between calls, shipping are not due to always force the user to get the best option. If new products added provide them in products array.
curl --request PUT \--url https://api.${env}.brinkcommerce.com/orderv1/carts \--header 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiI3M2U3NTY3MS00NTUzLTRlODctYTkyYS01NGUwMDk0N2E2ZWIiLCJpYXQiOjE2MDA5NzIwMzEsImV4cCI6MTYwMTIzMTIzMX0.KZwLePY_3qC5RtsUzSAbCv30raHM0lUtm0QnGKS_UA4' \--header 'content-type: application/json' \--data '{"products": [{"id": "2","quantity": 1}]}'
Response
{"jwtToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiI3M2U3NTY3MS00NTUzLTRlODctYTkyYS01NGUwMDk0N2E2ZWIiLCJpYXQiOjE2MDA5NzIwMzEsImV4cCI6MTYwMTIzMTIzMX0.KZwLePY_3qC5RtsUzSAbCv30raHM0lUtm0QnGKS_UA4","productsNotFound": [],"cart": {"cartItems": [{"id": "2","name": "t-shirt white","quantity": 2,"price": {"SEK": 20000},"type": "productVariant","added": "2020-09-24T18:27:11.417Z"}],"totalPriceWithDiscount": 40000,"totalDiscountAmount": 0,"totalPrice": 40000,"discounts": {"rules": [],"productDiscounts": [],"cartDiscount": {"SEK": 0}}}}
Discount
Use a discount code
Use a discount code for a cart, if applied the response will contain the code. Only one code per cart is allowed, sendig a new valid code will overwrite the any set code.
curl --request PUT \--url https://api.${env}.brinkcommerce.com/orderv1/carts \--header 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiI3M2U3NTY3MS00NTUzLTRlODctYTkyYS01NGUwMDk0N2E2ZWIiLCJpYXQiOjE2MDA5NzIwMzEsImV4cCI6MTYwMTIzMTIzMX0.KZwLePY_3qC5RtsUzSAbCv30raHM0lUtm0QnGKS_UA4' \--header 'content-type: application/json' \--data '{"code": "summer2020"}'
Response
{"jwtToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiI3M2U3NTY3MS00NTUzLTRlODctYTkyYS01NGUwMDk0N2E2ZWIiLCJpYXQiOjE2MDA5NzIwMzEsImV4cCI6MTYwMTIzMTIzMX0.KZwLePY_3qC5RtsUzSAbCv30raHM0lUtm0QnGKS_UA4","productsNotFound": [],"cart": {"cartItems": [{"id": "2","name": "t-shirt white","quantity": 2,"price": {"SEK": 20000},"type": "productVariant","added": "2020-09-24T18:27:11.417Z"}],"totalPriceWithDiscount": 40000,"totalDiscountAmount": 0,"totalPrice": 40000,"discounts": {"productDiscounts": [{"discountAmount": {"SEK": 7500},"id": "1"}],"rules": [{"id": "1","ruleData": {"discountCode": "summer2020"},"ruleType": "DISCOUNTCODE"}],"cartDiscount": {"SEK": 0}}}}
Remove a discount code
Remove any discount code that has been applied to the cart.
curl --request PUT \--url https://api.${env}.brinkcommerce.com/orderv1/carts \--header 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiI3M2U3NTY3MS00NTUzLTRlODctYTkyYS01NGUwMDk0N2E2ZWIiLCJpYXQiOjE2MDA5NzIwMzEsImV4cCI6MTYwMTIzMTIzMX0.KZwLePY_3qC5RtsUzSAbCv30raHM0lUtm0QnGKS_UA4' \--header 'content-type: application/json' \--data '{"deleteDiscount": "true"}'
Response
{"jwtToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiI3M2U3NTY3MS00NTUzLTRlODctYTkyYS01NGUwMDk0N2E2ZWIiLCJpYXQiOjE2MDA5NzIwMzEsImV4cCI6MTYwMTIzMTIzMX0.KZwLePY_3qC5RtsUzSAbCv30raHM0lUtm0QnGKS_UA4","productsNotFound": [],"cart": {"cartItems": [{"id": "2","name": "t-shirt white","quantity": 2,"price": {"SEK": 20000},"type": "productVariant","added": "2020-09-24T18:27:11.417Z"}],"totalPriceWithDiscount": 40000,"totalDiscountAmount": 0,"totalPrice": 40000,"discounts": {"rules": [],"productDiscounts": [],"cartDiscount": {"SEK": 0}}}}
Shipping
Create shippingProvider
curl --request POST \--url https://api.${env}.brinkcommerce.com/productv1/products \--header 'content-type: application/json' \--header 'x-api-key: ${product api key}' \--data '[{"id": "1000","name": "UPS","type": "shippingProvider","category": "shipping",}]'
Create shippingOption
curl --request POST \--url https://api.${env}.brinkcommerce.com/productv1/products \--header 'content-type: application/json' \--header 'x-api-key: ${product api key}' \--data '[{"id": "1001","name": "UPS Express","type": "shippingOption","category": "shipping","price": [{"currencyUnit": "SEK","amount": 5000}],"relatedProduct": "1"}]'
Order
Order requires a cart with items. One of the item needs to be a shippingOption.
Cart to Order
This will create a Order from the cart. The jwtToken must be provided.
curl --request POST \--url https://api.${env}.brinkcommerce.com/orderv1/carts/orders \--header 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiI3M2U3NTY3MS00NTUzLTRlODctYTkyYS01NGUwMDk0N2E2ZWIiLCJpYXQiOjE2MDA5NzIwMzEsImV4cCI6MTYwMTIzMTIzMX0.KZwLePY_3qC5RtsUzSAbCv30raHM0lUtm0QnGKS_UA4' \--header 'content-type: application/json' \--data '{"email": "test@example.com","shippingAddress": {"givenName": "Hello","familyName": "World","phone": "460000000","streetAddress": "Street 10","postalCode": "222222","city": "City","country": "SE"},"billingAddress": {"givenName": "Hello","familyName": "World","phone": "460000000","streetAddress": "Street 10","postalCode": "222222","city": "City","country": "SE"}}'
Response
{"id": "6b0d5ebc-78c1-4fa0-9008-af24cec7de39","reference": 10001,"status": "created","orderLines": [{"id": "6e75c839-c978-4eda-acec-cb0d42791399","productId": "1001","name": "UPS Express","quantity": 1,"taxRate": 0,"totalAmount": 5000,"totalAmountWithDiscount": 5000,"totalTaxAmount": 0,"type": "shipment","price": 5000},{"id": "af1a2544-31b5-4285-ad47-80cf54b456c0","productId": "2","name": "t-shirt white","quantity": 2,"taxRate": 0,"totalAmount": 20,"totalAmountWithDiscount": 20,"totalTaxAmount": 0,"type": "physical","price": 10}],"personId": "bbc2dc3b-ca8a-47d5-8eea-93cd2ab4c3ef","shippingAddress": {"givenName": "Hello","familyName": "World","phone": "460000000","streetAddress": "Street 10","postalCode": "222222","city": "City","country": "SE"},"orderTaxAmount": 0,"orderAmount": 5020,"orderAmountWithDiscount": 5020,"store": "SE","currencyUnit": "SEK","created": "2020-09-25T07:44:53.459Z","lastUpdated": "2020-09-25T07:44:53.459Z"}
Hooks can be configured for the diffrent status of the order.
Get order
curl --request GET \--url https://api.${env}.brinkcommerce.com/orderv1/orders/3a1c904d-a023-4238-a125-a0ae96bdfceb \--header 'x-api-key: ${api key}'
Response
{"lastUpdated": "2020-11-12T21:08:46.280Z","orderAmount": 156000,"paymentProvider": "testpaymentprovider","status": "success","created": "2020-11-12T21:08:36.719Z","paymentReference": "852605215325172D","reference": 10539,"orderAmountWithDiscount": 120800,"shippingAddress": {"country": "SE","phone": "02213213","streetAddress": "teststreet 12","city": "testcity","givenName": "Hello","familyName": "World","postalCode": "12345"},"orderTaxAmount": 24160,"currencyUnit": "SEK","paymentMethod": "CreditCard","orderLines": [{"taxRate": 25,"totalAmount": 0,"quantity": 1,"productId": "e805999e-9378-4511-bfd9-7770ea1788d0","price": 0,"name": "UPS Free Express","id": "5809205b-43fa-43bb-80f3-c168a86fd3dc","totalTaxAmount": 0,"type": "shipment","totalAmountWithDiscount": 0},{"taxRate": 25,"totalAmount": 26000,"quantity": 1,"productId": "21a1dec9-f95e-4f01-a67d-2590ccc422f7","price": 26000,"name": "Adidas Stan Smith Size 37","id": "6bc51507-8999-4f67-a7b3-2382f3bac105","totalTaxAmount": 5200,"type": "physical","totalAmountWithDiscount": 26000},{"taxRate": 25,"totalAmount": 130000,"quantity": 5,"productId": "098cff80-85e3-493a-af48-c692cff4ca86","price": 26000,"name": "Adidas Fun Run Size 37","id": "d47b0e3f-7f0b-4fb1-823f-0859f0692c38","totalTaxAmount": 25000,"type": "physical","totalAmountWithDiscount": 125000}],"previousStatus": "created","id": "3a1c904d-a023-4238-a125-a0ae96bdfceb","personId": "ef90ad0d-3099-4a92-9d41-5b760a062966", # Reference to Person"store": "SE"}
Get Person
Used to get that Person (Billing) conected to the order.
curl --request GET \--url https://api.${env}.brinkcommerce.com/orderv1/persons/ef90ad0d-3099-4a92-9d41-5b760a062966 \--header 'x-api-key: ${api key}'
Response
{"id": "ef90ad0d-3099-4a92-9d41-5b760a062966","givenName": "Hello","familyName": "World","phone": "460000000","streetAddress": "Street 10","postalCode": "12345","city": "City","country": "SE""lastUpdated": "2020-11-12T21:08:35.991Z","created": "2020-09-21T19:49:16.015Z","email": "test@example.com",}
Search order
All product are indexed in Elasticsearch. We support Elasticsearch query DSL
curl --request POST \--url https://api.${env}.brinkcommerce.com/orderv1/orders/search \--header 'content-type: application/json' \--header 'x-api-key: ${api key}' \--data '{"query": {"match": {"status": "created"}}}'
Cancel Order
Set order status to canceled
curl --request POST \--url https://api.${env}.brinkcommerce.com/orderv1/orders/3a1c904d-a023-4238-a125-a0ae96bdfceb/cancel \--header 'x-api-key: ${api key}'
Response
{"lastUpdated": "2020-11-12T21:08:46.280Z","orderAmount": 156000,"paymentProvider": "testpaymentprovider","status": "cancelRequested","created": "2020-11-12T21:08:36.719Z","paymentReference": "852605215325172D","reference": 10539,"orderAmountWithDiscount": 120800,"shippingAddress": {"country": "SE","phone": "02213213","streetAddress": "teststreet 12","city": "testcity","givenName": "Hello","familyName": "World","postalCode": "12345"},"orderTaxAmount": 24160,"currencyUnit": "SEK","paymentMethod": "CreditCard","orderLines": [{"taxRate": 25,"totalAmount": 0,"quantity": 1,"productId": "e805999e-9378-4511-bfd9-7770ea1788d0","price": 0,"name": "UPS Free Express","id": "5809205b-43fa-43bb-80f3-c168a86fd3dc","totalTaxAmount": 0,"type": "shipment","totalAmountWithDiscount": 0},{"taxRate": 25,"totalAmount": 26000,"quantity": 1,"productId": "21a1dec9-f95e-4f01-a67d-2590ccc422f7","price": 26000,"name": "Adidas Stan Smith Size 37","id": "6bc51507-8999-4f67-a7b3-2382f3bac105","totalTaxAmount": 5200,"type": "physical","totalAmountWithDiscount": 26000},{"taxRate": 25,"totalAmount": 130000,"quantity": 5,"productId": "098cff80-85e3-493a-af48-c692cff4ca86","price": 26000,"name": "Adidas Fun Run Size 37","id": "d47b0e3f-7f0b-4fb1-823f-0859f0692c38","totalTaxAmount": 25000,"type": "physical","totalAmountWithDiscount": 125000}],"previousStatus": "success","id": "3a1c904d-a023-4238-a125-a0ae96bdfceb","personId": "ef90ad0d-3099-4a92-9d41-5b760a062966", # Reference to Person"store": "SE"}
Refund order
Refund products on order. Provide id of the order and orderlines containing id for the product and quantity of how many products that should be refunded
curl --request POST \--url https://api.${env}.brinkcommerce.com/orderv1/orders/refund \--header 'content-type: application/json' \--header 'x-api-key: ${api key}' \--data '{"id": "3a1c904d-a023-4238-a125-a0ae96bdfceb","orderLinesToBeRefunded": [{"quantity": 1,"productId": "d47b0e3f-7f0b-4fb1-823f-0859f0692c38"}]}'
Response
{"lastUpdated": "2020-11-12T21:08:46.280Z","orderAmount": 156000,"paymentProvider": "testpaymentprovider","status": "refundRequested","created": "2020-11-12T21:08:36.719Z","paymentReference": "852605215325172D","reference": 10539,"orderAmountWithDiscount": 120800,"shippingAddress": {"country": "SE","phone": "02213213","streetAddress": "teststreet 12","city": "testcity","givenName": "Hello","familyName": "World","postalCode": "12345"},"orderTaxAmount": 24160,"currencyUnit": "SEK","paymentMethod": "CreditCard","orderLines": [{"taxRate": 25,"totalAmount": 0,"quantity": 3,"productId": "e805999e-9378-4511-bfd9-7770ea1788d0","price": 0,"name": "UPS Free Express","id": "5809205b-43fa-43bb-80f3-c168a86fd3dc","totalTaxAmount": 0,"type": "shipment","totalAmountWithDiscount": 0},{"taxRate": 25,"totalAmount": 26000,"quantity": 1,"productId": "21a1dec9-f95e-4f01-a67d-2590ccc422f7","price": 26000,"name": "Adidas Stan Smith Size 37","id": "6bc51507-8999-4f67-a7b3-2382f3bac105","totalTaxAmount": 5200,"type": "physical","totalAmountWithDiscount": 26000},{"taxRate": 25,"totalAmount": 130000,"quantity": 5,"productId": "098cff80-85e3-493a-af48-c692cff4ca86","price": 26000,"name": "Adidas Fun Run Size 37","id": "d47b0e3f-7f0b-4fb1-823f-0859f0692c38","totalTaxAmount": 25000,"type": "physical","totalAmountWithDiscount": 125000},{"taxRate": 25,"totalAmount": -130000,"quantity": 1,"productId": "098cff80-85e3-493a-af48-c692cff4ca86","price": 26000,"name": "Adidas Fun Run Size 37","id": "d47b0e3f-7f0b-4fb1-823f-0859f0698843v","totalTaxAmount": -5000,"type": "refund","totalAmountWithDiscount": -125000}],"previousStatus": "success","id": "3a1c904d-a023-4238-a125-a0ae96bdfceb","personId": "ef90ad0d-3099-4a92-9d41-5b760a062966", # Reference to Person"store": "SE"}