6

3.Create medusa transaction step by step

 2 years ago
source link: https://willzhuang.github.io/2022/04/26/3.Create%20medusa%20transaction%20step%20by%20step/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

3.Create medusa transaction step by step

Posted on

2022-04-26 Edited on 2022-04-27

This is a collection of medusa-postman, from the name sequence, we can see the business steps one by one.

It is based on @medusajs/[email protected], @medusajs/[email protected].

Please import this json as a file into postman, you can call the API step by step.

![](3.Create medusa transaction step by step/1.png)

{
"info": {
"_postman_id": "d0447766-3c8d-4b70-bf6c-ca66061249f8",
"name": "medusa",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "1.Authenticate a User",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"[email protected]\",\n \"password\": \"zaq12wsx\"\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/admin/auth",
"host": [
"localhost"
],
"port": "9000",
"path": [
"admin",
"auth"
]
}
},
"response": []
},
{
"name": "2.Create product",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n\t\"title\": \"nft-04-26-test-01\",\n\t\"subtitle\": \"\",\n\t\"description\": \"this is a test\",\n\t\"is_giftcard\": false,\n\t\"discountable\": false,\n\t\"images\": [],\n\t\"thumbnail\": \"\",\n\t\"handle\": \"test-nft-product-04-27\",\n\t\"weight\": 10,\n\t\"length\": 20,\n\t\"height\": 5,\n\t\"width\": 10,\n\t\"origin_country\": \"\",\n\t\"mid_code\": \"\",\n\t\"material\": \"\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/admin/products",
"host": [
"localhost"
],
"port": "9000",
"path": [
"admin",
"products"
]
}
},
"response": []
},
{
"name": "3.Create a Customer-admin",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"[email protected]\",\n \"password\": \"test1\",\n \"first_name\": \"firstname\",\n \"last_name\": \"lastname\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/admin/customers",
"host": [
"localhost"
],
"port": "9000",
"path": [
"admin",
"customers"
]
}
},
"response": []
},
{
"name": "3.Create a Customer-store",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"[email protected]\",\n \"password\": \"test2\",\n \"first_name\": \"firstname2\",\n \"last_name\": \"lastname2\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/store/customers",
"host": [
"localhost"
],
"port": "9000",
"path": [
"store",
"customers"
]
}
},
"response": []
},
{
"name": "4.Auth a customer",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"[email protected]\",\n \"password\": \"test1\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/store/auth",
"host": [
"localhost"
],
"port": "9000",
"path": [
"store",
"auth"
]
}
},
"response": []
},
{
"name": "4.1 get regions",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "localhost:9000/store/regions",
"host": [
"localhost"
],
"port": "9000",
"path": [
"store",
"regions"
]
}
},
"response": []
},
{
"name": "5.Create a cart",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"region_id\": \"reg_01G1FPXMTTD926PVCYW9WT9QSN\",\n \"country_code\": \"cn\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/store/carts",
"host": [
"localhost"
],
"port": "9000",
"path": [
"store",
"carts"
]
}
},
"response": []
},
{
"name": "5.1 Add a item",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"variant_id\": \"variant_01G1G2029D4ASNYWGEX9TCSVTY\",\n \"quantity\": 1\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/store/carts/cart_01G1G1R5D2JCA2CP0HV55JHEMJ/line-items",
"host": [
"localhost"
],
"port": "9000",
"path": [
"store",
"carts",
"cart_01G1G1R5D2JCA2CP0HV55JHEMJ",
"line-items"
]
}
},
"response": []
},
{
"name": "5.2Add a Shipping Method",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"option_id\": \"so_01G1FZ76DY5XVRT64639856AR0\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": ""
}
},
"response": []
},
{
"name": "5.3Calculate Cart Taxes",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/store/carts/cart_01G1G1R5D2JCA2CP0HV55JHEMJ/taxes",
"host": [
"localhost"
],
"port": "9000",
"path": [
"store",
"carts",
"cart_01G1G1R5D2JCA2CP0HV55JHEMJ",
"taxes"
]
}
},
"response": []
},
{
"name": "5.4Initialize Payment Sessions",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/store/carts/cart_01G1G1R5D2JCA2CP0HV55JHEMJ/payment-sessions",
"host": [
"localhost"
],
"port": "9000",
"path": [
"store",
"carts",
"cart_01G1G1R5D2JCA2CP0HV55JHEMJ",
"payment-sessions"
]
}
},
"response": []
},
{
"name": "5.5Complete a Cart - create an order",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/store/carts/cart_01G1G1R5D2JCA2CP0HV55JHEMJ/complete",
"host": [
"localhost"
],
"port": "9000",
"path": [
"store",
"carts",
"cart_01G1G1R5D2JCA2CP0HV55JHEMJ",
"complete"
]
}
},
"response": []
},
{
"name": "6.Capture an Order - payment finished",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/admin/orders/order_01G1G6DRGQQX5QBF7RQY1JYWWQ/capture",
"host": [
"localhost"
],
"port": "9000",
"path": [
"admin",
"orders",
"order_01G1G6DRGQQX5QBF7RQY1JYWWQ",
"capture"
]
}
},
"response": []
},
{
"name": "7.Create a Fulfillment - order fulfilled",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"items\": [\n {\n \"item_id\": \"item_01G1G21Z2G7VDXYZ51AZM53YNN\",\n \"quantity\": 1\n }\n ],\n \"metadata\": {},\n \"no_notification\": false\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/admin/orders/order_01G1G6DRGQQX5QBF7RQY1JYWWQ/fulfillment",
"host": [
"localhost"
],
"port": "9000",
"path": [
"admin",
"orders",
"order_01G1G6DRGQQX5QBF7RQY1JYWWQ",
"fulfillment"
]
}
},
"response": []
},
{
"name": "8.Create a Shipment - order shipped",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"fulfillment_id\": \"ful_01G1JKV7Y3V25GDBE8T30EH0GB\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:9000/admin/orders/order_01G1G6DRGQQX5QBF7RQY1JYWWQ/shipment",
"host": [
"localhost"
],
"port": "9000",
"path": [
"admin",
"orders",
"order_01G1G6DRGQQX5QBF7RQY1JYWWQ",
"shipment"
]
}
},
"response": []
}
]
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK