Create a Cart
Create preconfigured carts to expedite the checkout process. The response will include a url, the ‘as low as’ monthly rate and the legal disclosure text to be displayed with the rate.
POST api.getbread.com/carts
{
"expiration": "2017-03-31",
"options": {
"orderRef": "merchantProvidedId",
"callbackUrl": "https://www.sample.com/newBreadTransaction",
"completeUrl": "https://www.sample.com/successRedirectPage",
"errorUrl": "https://www.sample.com/fallbackPage",
"items": [
{
"imageUrl": "https://www.merchant.com/assets/picture.jpg",
"detailUrl": "https://www.merchant.com/product/0394j039jf",
"name": "Super Comfy Mattress",
"price": 50000,
"quantity": 1,
"sku": "0349j0394fj"
}
]
}
}
curl https://api.getbread.com/carts/ \
-u <api-key>:<secret-key> \
-X POST \
-H "Content-Type: application/json" \
-d '{"expiration": "2021-05-27","options": {"orderRef":"merchantProvidedId","callbackUrl": "https://www.sample.com/newBreadTransaction","completeUrl": "https://www.sample.com/successRedirectPage","errorUrl": "https://www.sample.com/fallbackPage","items": [{"imageUrl": "https://www.merchant.com/assets/picture.jpg","detailUrl": "https://www.merchant.com/product/0394j039jf","name": "Super Comfy Mattress","price": 50000,"quantity": 1,"sku": "0349j0394fj"}]}}'
{
"expiration": "2017-03-31",
"createdBy": "Merchant API",
"options": {
"orderRef": "merchantProvidedId",
"callbackUrl": "https://www.sample.com/newBreadTransaction",
"completeUrl": "https://www.sample.com/successRedirectPage",
"errorUrl": "https://www.sample.com/fallbackPage",
"shippingType": "Express",
"shippingTypeId": "merchantShippingId",
"shippingCost": 5000,
"shippingContact": {
"firstName": "Jennifer",
"lastName": "Reeves",
"email": "[email protected]",
"address": "39 West 14th Street",
"address2": "Suite 403",
"city": "New York",
"state": "NY",
"zip": "10011",
"phone": "9729899173"
},
"disableEditShipping": "false",
"billingContact": {
"fullName": "Jennifer Reeves",
"email": "[email protected]",
"address": "39 West 14th Street",
"address2": "Suite 403",
"city": "New York",
"state": "NY",
"zip": "10011",
"phone": "9729899173"
},
"items": [{
"imageUrl": "https://www.merchant.com/assets/picture.jpg",
"detailUrl": "https://www.merchant.com/product/0394j039jf",
"name": "Super Comfy Mattress",
"price": 50000,
"quantity": 1,
"sku": "0349j0394fj"
}],
"discounts": [{
"amount": 10000,
"description": "$10 Off"
}]
}
}
Arguments | Type | Required | Parent Attribute | Description |
---|---|---|---|
orderRef | string | optional | options | Unique identifier to match with the Bread transaction ID |
callbackUrl | string | optional | options | Where we’ll POST the transaction ID of the checkout and the orderRef following a successful checkout The POST body will be JSON in the format of: { “transactionId”: “addfa809-f4d5-4540-8902-0da4e3fd53c0”, “orderRef”: “ABCD1234” } |
completeUrl | string | optional | options | Where the customer is redirected following a successful checkout, e.g. a confirmation page. The completeUrl will be appended with query parameters of the transactionId and orderRef in the format of: https://www.merchant.com/orderConfirmation?orderRef=ABCD1234&transactionId=addfa809-f4d5-4540-8902-0da4e3fd53c0 |
createdBy | string | optional | options | The identifier of the creator of the cart. |
errorUrl | string | optional | options | Set to true for a flat cost Cart link, false for Cart link with line items. |
shippingOptions | array | optional | options | Array of shipping option(s) the customer can select from when checking out with the cart, this includes type, typeId, and cost (int representing cost in cents) |
type | string | required | shippingOptions | Description of the shipping option, which will be displayed to the customer |
typeId | string | required | shippingOptions | Identifier for the specific shipping option |
cost | integer | required | shippingOptions | Cost of the shipping option in cents |
shippingContact | object | optional | options | The customer’s shipping details. Includes firstName, lastName, email, address, address2, city, state, zip and phone |
firstName | string | required | shippingContact | Customer’s first name |
lastName | string | required | shippingContact | Customer’s last name |
string | required | shippingContact | Customer’s email | |
address | string | required | shippingContact | Customer’s address |
address2 | string | required | shippingContact | Any continuation of the customer’s address, including apartment number or suite |
city | string | required | shippingContact | Customer’s city of residence |
state | string | required | shippingContact | Customer’s state of residence. Must be the 2 character abbreviation for a valid US state or the District of Columbia. (ie. NY, DC) |
phone | string | required | shippingContact | Customer’s phone number. A 10 digit phone number with only numeric characters |
billingContact | object | optional | options | The customer’s billing details. Includes firstName, lastName, email, address, address2, city, state, zip and phone |
firstName | string | required | billingContact | Customer’s first name |
lastName | string | required | billingContact | Customer’s last name |
string | required | billingContact | Customer’s email | |
address | string | required | billingContact | Customer’s address |
address2 | string | required | billingContact | Any continuation of the customer’s address, including apartment number or suite |
city | string | required | billingContact | Customer’s city of residence |
state | string | required | billingContact | Customer’s state of residence. Must be the 2 character abbreviation for a valid US state or the District of Columbia. (ie. NY, DC) |
phone | string | required | billingContact | Customer’s phone number. A 10 digit phone number with only numeric characters |
items | array | conditional required if customTotal is not defined | options | List of items in cart. Each item object has an imageUrl, detailUrl, name, price, quantity, sku |
imageUrl | string | required | items | Image url for the item. This will be displayed to confirm the order on the cart summary page |
detailUrl | string | required | items | Product detail url for the item |
name | string | optional | items | Name of the item |
price | integer | required | items | Price in cents of the item. Unless customTotal is used, this will be used to calculate the total cost with discounts, tax and shipping cost |
quantity | integer | required | items | Number of items in the cart |
sku | string | required | items | Unique sku for the product. Shopify specific documentation available |
discounts | array | optional | options | List of objects of any discounts applied to the order. Factored into the cart total, unless a customTotal is provided. Each discount has an amount (in cents) and description |
amount | integer | required | discounts | Positive discount amount in cents |
description | string | required | discounts | Discount description |
customTotal | integer | conditional required if items are not defined | options | The total checkout price of the cart, in cents, including items, shipping cost, taxes and discounts. This value will override any other costs associated with the cart |
tax | integer | optional | options | Represents the amount of tax associated with the cart when customTotal is applied |
disableEditShipping | boolean | optional | options | Hide shipping address in cart to prevent customer from changing shipping address. By default, set to “false” |