A question was asked on the Order Object, itβs use case and updating the status of an order. The Rapyd API includes the Order Object for certain products that are goods like coffee beans, electronics, or furniture. These are one time orders that are delivered to an address.
Follow the steps to create an order.
Create Product
Use "type": "goods"
, to create a product to retrieve your product ID
Product ID: product_7c637548e97489f9101a01ce17f452c2
Create SKU
Create a SKU (Stock Keeping Unit) using the Product ID.
Request
{
"id": "",
"active": true,
"attributes": {
"color": "green"
},
"currency": "USD",
"images": [
"64bit-encoded-image-1",
"64bit-encoded-image-2"
],
"inventory": {
"quantity": 1,
"type": "finite",
"value": 600
},
"metadata": {
"merchant_defined": "red_chair"
},
"package_dimensions": {
"height": 10,
"length": 20,
"weight": 30,
"width": 40
},
"price": 600,
"product": "product_c26a459a12ffb261ff00d4c860499a76"
}
Response
{
"status": {
"error_code": "",
"status": "SUCCESS",
"message": "",
"response_code": "",
"operation_id": "f3cb678a-01f3-4870-92de-9a7857fa38f8"
},
"data": {
"id": "sku_3fc5f0af4eba92f2a9ac18e36bd25927",
"active": true,
"attributes": {
"color": "green"
},
"created_at": 1652486232,
"currency": "USD",
"image": "",
"inventory": {
"type": "finite",
"quantity": 1,
"value": ""
},
"metadata": {
"merchant_defined": "red_chair"
},
"price": 600,
"product": "product_c26a459a12ffb261ff00d4c860499a76",
"package_dimensions": {
"length": 20,
"height": 10,
"weight": 30,
"width": 40
},
"updated_at": 1652486232
}
}
Create Order
Create Order using the Customer ID and SKU ID.
Request
{
"customer": "cus_11f7783b2c80f53400ab33095055f7cb",
"currency": "USD",
"external_coupon_code": "squeee",
"items": [
{
"type": "sku",
"currency": "USD",
"amount": 600,
"quantity": 1,
"parent": "sku_3fc5f0af4eba92f2a9ac18e36bd25927",
"description": "Deluxe Gamer's Chair"
},
{
"type": "shipping",
"amount": 1,
"currency": "USD",
"description": "Shipping"
}
],
"shipping_address": {
"name": "John Doe",
"line_1": "123 State Street",
"line_2": "Apt. 34",
"line_3": "",
"city": "Anytown",
"district": "",
"canton": "",
"state": "NY",
"country": "US",
"zip": "12345",
"phone_number": "12125559999",
"metadata": {
"merchant_defined": true
}
},
"tax_percent": 0,
"upstream_id": "GZC12345",
"email": "johndoe@rapyd.net",
"metadata": {
"merchant_defined": true
}
}
Response
{
"status": {
"error_code": "",
"status": "SUCCESS",
"message": "",
"response_code": "",
"operation_id": "2b852dee-c168-4121-910a-49d248743f24"
},
"data": {
"id": "order_ec0b8d6e8d76a3066356e553435bd96a",
"amount": 601,
"amount_returned": 0,
"payment": null,
"created": 1652486375,
"customer": "cus_11f7783b2c80f53400ab33095055f7cb",
"currency": "USD",
"email": "johndoe@rapyd.net",
"external_coupon_code": "",
"items": [
{
"amount": 600,
"currency": "USD",
"description": "Deluxe Gamer's Chair",
"parent": "sku_3fc5f0af4eba92f2a9ac18e36bd25927",
"quantity": 1,
"type": "sku"
},
{
"amount": 1,
"currency": "USD",
"description": "Shipping",
"parent": "",
"quantity": 1,
"type": "shipping"
}
],
"metadata": {
"merchant_defined": true
},
"returns": [],
"shipping_address": {
"id": "address_64011fe320db2f1b74b04ed96a4d2b55",
"name": "John Doe",
"line_1": "",
"line_2": "",
"line_3": "",
"city": "Anytown",
"state": "NY",
"country": "US",
"zip": "12345",
"phone_number": "12125559999",
"metadata": {
"merchant_defined": true
},
"canton": "",
"district": "",
"created_at": 1652486375
},
"status": "created",
"status_transitions": {
"canceled": 0,
"fulfilled": 0,
"paid": 0,
"returned": 0,
"pending": 0,
"partial": 0
},
"updated": 1652486375,
"upstream_id": "GZC12345",
"tax_percent": 0
}
}
Retreive Order
When Retrieving order, the status still shows as created.
Update Order
You can update status from created to pending , paid , or fulfilled
Request
Use the Order ID in the query paramers
Request Body
{
"metadata": {
"merchant_defined": true
},
"status":"fulfilled"
}
Response
{
"status": {
"error_code": "",
"status": "SUCCESS",
"message": "",
"response_code": "",
"operation_id": "1264e029-6247-4b30-b3a5-852f00b982dc"
},
"data": {
"id": "order_ec0b8d6e8d76a3066356e553435bd96a",
"amount": 601,
"amount_returned": 0,
"payment": null,
"created": 1652486375,
"customer": "cus_11f7783b2c80f53400ab33095055f7cb",
"currency": "USD",
"email": "johndoe@rapyd.net",
"external_coupon_code": "",
"items": [
{
"amount": 600,
"currency": "USD",
"description": "Deluxe Gamer's Chair",
"parent": "sku_3fc5f0af4eba92f2a9ac18e36bd25927",
"quantity": 1,
"type": "sku"
},
{
"amount": 1,
"currency": "USD",
"description": "Shipping",
"parent": "",
"quantity": 1,
"type": "shipping"
}
],
"metadata": {
"merchant_defined": true
},
"returns": [],
"shipping_address": {
"id": "address_64011fe320db2f1b74b04ed96a4d2b55",
"name": "John Doe",
"line_1": "",
"line_2": "",
"line_3": "",
"city": "Anytown",
"state": "NY",
"country": "US",
"zip": "12345",
"phone_number": "12125559999",
"metadata": {
"merchant_defined": true
},
"canton": "",
"district": "",
"created_at": 1652486375
},
"status": "fulfilled",
"status_transitions": {
"canceled": 0,
"fulfilled": 1652487222,
"paid": 1652487205,
"returned": 0,
"pending": 1652487170,
"partial": 0
},
"updated": 1652487222,
"upstream_id": "GZC12345",
"tax_percent": 0
}
}