Manage orders with the REST Admin API

You can use the REST Admin API to create orders and transactions to validate your app's behavior.

Tip

circle-info

You can create test orders without using the API by using Shopbase Test Gatewayarrow-up-right

Before you begin

To best understand this guide, you can familiarize yourself with the concepts of orders and transactions.

Transactions are associated to orders and occur each time there is an exchange of money. Transactions are processed by payment providers, and involve the transfer of money from the issuer account (the customer's credit card) to the acquirer (the merchant's bank account). For more information, see Getting paidarrow-up-right.

Access scopes

To use the Admin API to edit orders, your app needs to request the write_order_edits access scope for a ShopBase store. For more information on requesting access scopes when your app is installed, see OAutharrow-up-right. To make things easy for you, we have also included a guideline on sending request with Postmanarrow-up-right.

Create an order

To test orders, create an order with an authorization transaction by sending a POST request to the Orderarrow-up-right resource:

POST https://shop-name.onshopbase.com/admin/orders.json

{
   "order":{
      "email":" ",
      "financial_status":"pending",
      "line_items":[
         {
            "title":"Big Brown Bear Boots",
            "price":100,
            "grams":"1300",
            "quantity":2
         }
      ]
   }
}

SAMPLE RESPOND:

To be more specific, we can take a look at how we can use Postman to create this order

STEP 1: Create your Shopbase's API Credentials by following the tutorial herearrow-up-right.

STEP 2: Send the POST Request with Postman

STEP 3: Save this request into a collection and extract the Order ID as a variable

circle-info

After editing the collection's authorization property, you do not have to manually set your Shopbase's API Credentials anymore. By default, all newly created requests will be set to the "inherit auth from parent" option

Create the transaction for an order

After creating an order, the returned Order object includes an ID. You can use the order ID to create a transaction.

POST https://shop-name.onshopbase.com/admin/orders/{order_id}/transactions.json

After you create the transaction, you can then use the order ID to get its transactions and transaction IDs. To retrieve the transactions, send a GET request to the Order Transactionarrow-up-right.

GET https://shop-name.onshopbase.com/admin/orders/{order_id}/transactions.json

Let's also look at how this request is handled by using Postman:

STEP 1: Use the same API Credential from the above instruction to create a new POST Request. Set `{{order_id}}` parameter in the request url as below:

STEP 2: Save the request call into a collection for future's use.

Last updated