Placing the order

How to authorize the payment and place the order

Problem

You have a pending order and you want to place it, authorizing the associated payment source.

Solution

To place an order, send a PATCH request to the /api/orders/:id endpoint, setting the _place attribute to true. If the order is valid — i.e. it has all the required information — the associated payment source is authorized and the order status changes to placed.

Example

The following request places the order identified by the "NgojhKoyYN" ID:

curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/orders/NgojhKoyYN' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
    "data": {
      "type": "orders",
      "id": "NgojhKoyYN",
      "attributes": {
        "_place": true
      }
    }
  }'

Additional notes

Asynchronous callbacks

After an order has been successfully placed, the following actions are performed asynchronously:

  • The customer orders count is increased

  • The order stock items are decremented

  • The status of any order shipment is set to upcoming

  • The status of any purchased gift cards is set to active

  • The usage count of any associated promotion is incremented

  • The usage count of any associated coupon is incremented

  • The usage count of any associated gift card is incremented

  • The status of any associated single-use gift card is set to redeemed

More to read

See our API reference if you need more information about the stock item, shipment, and gift card objects or on how to update an order.

Last updated