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

You can create test orders without using the API by using Shopbase Test Gateway

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 paid.

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 OAuth. To make things easy for you, we have also included a guideline on sending request with Postman.

Create an order

To test orders, create an order with an authorization transaction by sending a POST request to the Order resource:
POST https://shop-name.onshopbase.com/admin/orders.json
1
{
2
"order":{
3
"email":" ",
4
"financial_status":"pending",
5
"line_items":[
6
{
7
"title":"Big Brown Bear Boots",
8
"price":100,
9
"grams":"1300",
10
"quantity":2
11
}
12
]
13
}
14
}
Copied!

SAMPLE RESPOND:

1
{
2
"orders":[
3
{
4
"id": 5549662,
5
"currency":"USD",
6
"customer":{
7
"accepts_marketing":false,
8
"average_spent":0,
9
"default_address":null,
10
"email":" ",
11
"first_name":"",
12
"id":49231780,
13
"last_name":"",
14
"last_order_at":0,
15
"last_order_id":0,
16
"last_order_name":"",
17
"note":"",
18
"orders_count":0,
19
"phone":"",
20
"state":"disabled",
21
"tags":"",
22
"tax_exempt":false,
23
"total_spent":0,
24
"updated_at":"2020-12-15T05:09:48+00:00",
25
"verified_email":false
26
},
27
"customer_locale":"",
28
"discount_applications":null,
29
"discount_code":null,
30
"draft_order_number":0,
31
"email":" ",
32
"financial_status":"pending",
33
"fulfillment_status":"",
34
...
35
}
36
]
37
}
Copied!
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 here.
STEP 2: Send the POST Request with Postman
STEP 3: Save this request into a collection and extract the Order ID as a variable
1
let response = pm.response.json()
2
pm.globals.set("order_id", response.order.id)
Copied!
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
1
{
2
"transactions":[
3
{
4
"kind":"authorization",
5
"status":"success",
6
"amount":200
7
}
8
]
9
}
Copied!
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 Transaction.
GET https://shop-name.onshopbase.com/admin/orders/{order_id}/transactions.json
1
{
2
"transactions":[
3
{
4
"amount":0,
5
"application_fee":0,
6
"authorization":"",
7
"conversion_rate":0,
8
"created_at":"2020-12-16T10:45:05+00:00",
9
"currency":"USD",
10
"currency_exchange_adjustment":null,
11
"device_id":0,
12
"error_code":"",
13
"gateway":"",
14
"id":10624938,
15
"kind":"",
16
"location_id":0,
17
"message":"",
18
"order_id":5557905,
19
"origin_error_code":"",
20
"parent_id":0,
21
"payment_details":null,
22
"payment_method_id":0,
23
"processed_at":"",
24
"receipt":null,
25
"shop_id":10124799,
26
"source_name":"",
27
"staff_id":0,
28
"status":"",
29
"test":false,
30
"transaction_amount":0,
31
"transaction_currency":"",
32
"updated_at":"2020-12-16T10:45:05+00:00"
33
}
34
]
35
}
Copied!
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 modified 11mo ago