[Checkout 4.0](https://api.fabric.inc/order/checkout-4.0)
To checkout using Stripe, the following APIs must be run sequentially.
- Add Items to Cart (https://fabric.inc/docs/openapi/oms/reference/#operation/addItemToCart)
`POST https://{baseurl}/api-cart/cart/item`
Request Body:
```js
{
"cartId":null,
"items": [
{
"itemId": 170,
"quantity": 1,
"group": [
"123123123123123213212222"
],
"price": {
"sale": 0,
"base": 0,
"discount": {
"price": 0,
"discountAmount": 0,
"promosApplied": []
},
"currency": "USD"
},
"extra": {}
}
]
}
```
- Create Shipping (https://fabric.inc/docs/openapi/oms/reference/#operation/shipToCreation)
`POST https://{baseurl}/api-cart/ship-to/cart/{cartId}`
Request Body:
```js
{
"shipToType": "SHIP_TO_ADDRESS",
"isPickup": true,
"taxCode": "FR1000",
"shipMethod": {
"shipMethodId": "1a2b3c4d5e6f7g8h9i0j",
"shipmentCarrier": "Fedex",
"shipmentMethod": "Next Day",
"cost": {
"currency": "USD",
"amount": 5.99
}
},
"address": {
"attention": "Leave at the back door.",
"street1": "123 Main Street",
"street2": "ABC Boulevard",
"city": "Seattle",
"state": "WA",
"country": "United States of America",
"zipCode": "10008-1234",
"kind": "TBD",
"name": {
"first": "John",
"last": "Smith"
},
"phone": {
"number": "123-456-7890",
"kind": "Mobile"
},
"email": "johnsmith@fabric.inc"
}
}
```
- Add Shipping to Line Items (https://fabric.inc/docs/openapi/oms/reference/#operation/addShipTo-v1)
`PATCH https://{baseurl}/api-cart/cart/{cartId}/ship-to/v1`
Request Body:
```js
[
{
"itemId": 123456,
"lineItemId": 3,
"shipTo": "5e5818a84d030c206b2ffb02"
}
]
```
- Create Payment Method
This step for getting the payment token, we can use the stripe API to get it or use the token from privice order
- Create And Confirm Payment Intent (https://fabric.inc/docs/openapi/oms/reference/#operation/createPaymentMethod)
`POST https://{baseurl}/ext-stripe/payment-method`
Request Body:
```js
{
amount: 10,
currency: 'USD',
confirm: true,
payment_method: paymentMethodId,
"metadata": {
"keyName": "key value"
},
}
```
- Add payment to cart (https://fabric.inc/docs/openapi/oms/reference/#operation/addPaymentToCart)
`POST https://{baseurl}/api-payment/payment`
Request Body:
```json=
{
"cartId": "60b90dd7308ded0008ee3c5d",
"paymentDetails": {
"transactionDetails": {
paymentType: 'CARD_STRIPE',
paymentToken: paymentIntentId,
},
"amount": 50.25,
"currency": "USD"
},
"billToAddress": {
"name": {},
"email": "ohnsmith@gmail.com",
"phone": {},
"street1": "600 Congress Ave",
"street2": "suite 219",
"city": "Austin",
"state": "Tx",
"country": "US",
"zipCode": "10033"
}
}
```
- Checkout (https://fabric.inc/docs/openapi/oms/reference/#operation/orderCheckoutV4)
`POST https://{baseurl}/api-order/checkout-v4)`
Request Body:
```json=
{
"cartId": "5e4876e10cfe1d8902005d33",
"customerEmail": "user@example.com",
"customerPhoneNumber": {
"number": "123-456-7890",
"kind": "Mobile"
},
"paymentDetails": [],
"estimatedTax": {
"itemsTaxes": [],
"shipToTaxes": []
}
}
```