Documentation ¶
Index ¶
- type Auth
- func (m *Auth) CreateSession(context fiber.Ctx) error
- func (m *Auth) DeleteSession(context fiber.Ctx) error
- func (m *Auth) Exist(context fiber.Ctx) error
- func (m *Auth) GetSession(context fiber.Ctx) error
- func (m *Auth) GetTocken(context fiber.Ctx) error
- func (m *Auth) SetRoutes(router fiber.Router)
- type Cart
- func (m *Cart) AddShippingMethod(context fiber.Ctx) error
- func (m *Cart) CalculateTaxes(context fiber.Ctx) error
- func (m *Cart) Complete(context fiber.Ctx) error
- func (m *Cart) Create(context fiber.Ctx) error
- func (m *Cart) CreateLineItem(context fiber.Ctx) error
- func (m *Cart) CreatePaymentSession(context fiber.Ctx) error
- func (m *Cart) DeleteDiscount(context fiber.Ctx) error
- func (m *Cart) DeleteLineItem(context fiber.Ctx) error
- func (m *Cart) DeletePaymentSession(context fiber.Ctx) error
- func (m *Cart) Get(context fiber.Ctx) error
- func (m *Cart) RefreshPaymentSession(context fiber.Ctx) error
- func (m *Cart) SetPaymentSession(context fiber.Ctx) error
- func (m *Cart) SetRoutes(router fiber.Router)
- func (m *Cart) Update(context fiber.Ctx) error
- func (m *Cart) UpdateLineItem(context fiber.Ctx) error
- func (m *Cart) UpdatePaymentSession(context fiber.Ctx) error
- type Collection
- type Customer
- func (m *Customer) Create(context fiber.Ctx) error
- func (m *Customer) CreateAddress(context fiber.Ctx) error
- func (m *Customer) DeleteAdress(context fiber.Ctx) error
- func (m *Customer) Get(context fiber.Ctx) error
- func (m *Customer) GetPaymnetMethods(context fiber.Ctx) error
- func (m *Customer) ListOrders(context fiber.Ctx) error
- func (m *Customer) ResetPassword(context fiber.Ctx) error
- func (m *Customer) ResetPasswordTocken(context fiber.Ctx) error
- func (m *Customer) SetRoutes(router fiber.Router)
- func (m *Customer) Update(context fiber.Ctx) error
- func (m *Customer) UpdateAddress(context fiber.Ctx) error
- type GiftCard
- type Order
- type OrderEdit
- type PaymentCollection
- func (m *PaymentCollection) Get(context fiber.Ctx) error
- func (m *PaymentCollection) PaymentSessionAuthorize(context fiber.Ctx) error
- func (m *PaymentCollection) PaymentSessionAuthorizeBatch(context fiber.Ctx) error
- func (m *PaymentCollection) PaymentSessionManage(context fiber.Ctx) error
- func (m *PaymentCollection) PaymentSessionManageBatch(context fiber.Ctx) error
- func (m *PaymentCollection) PaymentSessionRefresh(context fiber.Ctx) error
- func (m *PaymentCollection) SetRoutes(router fiber.Router)
- type Product
- type ProductCategory
- type ProductTag
- type ProductType
- type Region
- type Registry
- type Return
- type ReturnReason
- type ShippingOption
- type Swap
- type Variant
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func (*Auth) CreateSession ¶
@oas:path [post] /store/auth operationId: "PostAuth" summary: "Customer Login" description: "Log a customer in and includes the Cookie session in the response header. The cookie session can be used in subsequent requests to authenticate the customer. When using Medusa's JS or Medusa React clients, the cookie is automatically attached to subsequent requests." requestBody:
content: application/json: schema: $ref: "#/components/schemas/PostAuthReq"
x-codegen:
method: authenticate
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.auth.authenticate({ email: "user@example.com", password: "user@example.com" }) .then(({ customer }) => { console.log(customer.id); })
- lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/auth' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "user@example.com", "password": "supersecret" }'
tags:
- Auth
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreAuthRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/incorrect_credentials" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Auth) DeleteSession ¶
@oas:path [delete] /store/auth operationId: "DeleteAuth" summary: "Customer Log out" description: "Delete the current session for the logged in customer." x-authenticated: true x-codegen:
method: deleteSession
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.auth.deleteSession() .then(() => { // customer logged out successfully })
- lang: Shell label: cURL source: | curl -X DELETE '{backend_url}/store/auth' \ -H 'Authorization: Bearer {access_token}'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Auth
responses:
"200": description: OK "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Auth) Exist ¶
@oas:path [get] /store/auth/{email} operationId: "GetAuthEmail" summary: "Check if Email Exists" description: "Check if there's a customer already registered with the provided email." parameters:
- in: path name: email schema: type: string format: email required: true description: The email to check.
x-codegen:
method: exists
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.auth.exists("user@example.com")
- lang: Shell label: cURL source: | curl '{backend_url}/store/auth/user@example.com'
tags:
- Auth
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreGetAuthEmailRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Auth) GetSession ¶
@oas:path [get] /store/auth operationId: "GetAuth" summary: "Get Current Customer" description: "Retrieve the currently logged in Customer's details." x-authenticated: true x-codegen:
method: getSession
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.auth.getSession() .then(({ customer }) => { console.log(customer.id); })
- lang: Shell label: cURL source: | curl '{backend_url}/store/auth' \ -H 'Authorization: Bearer {access_token}'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Auth
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreAuthRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Auth) GetTocken ¶
@oas:path [post] /store/auth/token operationId: "PostToken" summary: "Customer Login (JWT)" x-authenticated: false description: "After a successful login, a JWT token is returned, which can be used to send authenticated requests." requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostAuthReq"
x-codegen:
method: getToken
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.auth.getToken({ email: 'user@example.com', password: 'supersecret' }) .then(({ access_token }) => { console.log(access_token); })
- lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/auth/token' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "user@example.com", "password": "supersecret" }'
tags:
- Auth
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreBearerAuthRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/incorrect_credentials" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type Cart ¶
type Cart struct {
// contains filtered or unexported fields
}
func (*Cart) AddShippingMethod ¶
@oas:path [post] /store/carts/{id}/shipping-methods operationId: "PostCartsCartShippingMethod" summary: "Add Shipping Method" description: "Add a Shipping Method to the Cart. The validation of the `data` field is handled by the fulfillment provider of the chosen shipping option." parameters:
- (path) id=* {string} The cart ID.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCartsCartShippingMethodReq"
x-codegen:
method: addShippingMethod
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.addShippingMethod(cartId, { option_id }) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useAddShippingMethodToCart } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const addShippingMethod = useAddShippingMethodToCart(cartId)
const handleAddShippingMethod = ( optionId: string ) => { addShippingMethod.mutate({ option_id: optionId, }, { onSuccess: ({ cart }) => { console.log(cart.shipping_methods) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}/shipping-methods' \ -H 'Content-Type: application/json' \ --data-raw '{ "option_id": "{option_id}", }'
tags:
- Carts
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) CalculateTaxes ¶
@oas:path [post] /store/carts/{id}/taxes operationId: "PostCartsCartTaxes" summary: "Calculate Cart Taxes" description: "Calculate the taxes for a cart. This is useful if the `automatic_taxes` field of the cart's region is set to `false`. If the cart's region uses a tax provider other than
Medusa's system provider, this may lead to sending requests to third-party services."
externalDocs:
description: "How to calculate taxes manually during checkout" url: "https://docs.medusajs.com/modules/taxes/storefront/manual-calculation"
parameters:
- (path) id=* {String} The Cart ID.
x-codegen:
method: calculateTaxes
x-codeSamples:
- lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}/taxes'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) Complete ¶
@oas:path [post] /store/carts/{id}/complete summary: "Complete a Cart" operationId: "PostCartsCartComplete" description: |
Complete a cart and place an order or create a swap, based on the cart's type. This includes attempting to authorize the cart's payment. If authorizing the payment requires more action, the cart will not be completed and the order will not be placed or the swap will not be created. An idempotency key will be generated if none is provided in the header `Idempotency-Key` and added to the response. If an error occurs during cart completion or the request is interrupted for any reason, the cart completion can be retried by passing the idempotency key in the `Idempotency-Key` header.
externalDocs:
description: "Cart completion overview" url: "https://docs.medusajs.com/modules/carts-and-checkout/cart#cart-completion"
parameters:
- (path) id=* {String} The Cart ID.
x-codegen:
method: complete
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.complete(cartId) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCompleteCart } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const completeCart = useCompleteCart(cartId)
const handleComplete = () => { completeCart.mutate(void 0, { onSuccess: ({ data, type }) => { console.log(data.id, type) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}/complete'
tags:
- Carts
responses:
200: description: "If the payment of the cart was successfully authorized, but requires further action from the customer, the response body will contain the cart with an updated payment session. Otherwise, if the payment was authorized and the cart was successfully completed, the response body will contain either the newly created order or swap, depending on what the cart was created for." content: application/json: schema: $ref: "#/components/schemas/StoreCompleteCartRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) Create ¶
@oas:path [post] /store/carts operationId: "PostCart" summary: "Create a Cart" description: |
Create a Cart. Although optional, specifying the cart's region and sales channel can affect the cart's pricing and the products that can be added to the cart respectively. So, make sure to set those early on and change them if necessary, such as when the customer changes their region. If a customer is logged in, make sure to pass its ID or email within the cart's details so that the cart is attached to the customer.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCartReq"
x-codegen:
method: create
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.create() .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCreateCart } from "medusa-react"
type Props = { regionId: string }
const Cart = ({ regionId }: Props) => { const createCart = useCreateCart()
const handleCreate = () => { createCart.mutate({ region_id: regionId // creates an empty cart }, { onSuccess: ({ cart }) => { console.log(cart.items) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts'
tags:
- Carts
responses:
200: description: "Successfully created a new Cart" content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) CreateLineItem ¶
func (*Cart) CreatePaymentSession ¶
@oas:path [post] /store/carts/{id}/payment-sessions operationId: "PostCartsCartPaymentSessions" summary: "Create Payment Sessions" description: "Create Payment Sessions for each of the available Payment Providers in the Cart's Region. If there's only one payment session created,
it will be selected by default. The creation of the payment session uses the payment provider and may require sending requests to third-party services."
parameters:
- (path) id=* {string} The ID of the Cart.
x-codegen:
method: createPaymentSessions
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.createPaymentSessions(cartId) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCreatePaymentSession } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const createPaymentSession = useCreatePaymentSession(cartId)
const handleComplete = () => { createPaymentSession.mutate(void 0, { onSuccess: ({ cart }) => { console.log(cart.payment_sessions) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}/payment-sessions'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) DeleteDiscount ¶
@oas:path [delete] /store/carts/{id}/discounts/{code} operationId: DeleteCartsCartDiscountsDiscount summary: "Remove Discount" description: "Remove a Discount from a Cart. This only removes the application of the discount, and not completely deletes it. The totals will be re-calculated and the payment sessions
will be refreshed after the removal."
parameters:
- (path) id=* {string} The ID of the Cart.
- (path) code=* {string} The unique discount code.
x-codegen:
method: deleteDiscount
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.deleteDiscount(cartId, code) .then(({ cart }) => { console.log(cart.id); })
- lang: Shell label: cURL source: | curl -X DELETE '{backend_url}/store/carts/{id}/discounts/{code}'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) DeleteLineItem ¶
@oas:path [delete] /store/carts/{id}/line-items/{line_id} operationId: DeleteCartsCartLineItemsItem summary: Delete a Line Item description: "Delete a Line Item from a Cart. The payment sessions will be updated and the totals will be recalculated." parameters:
- (path) id=* {string} The ID of the Cart.
- (path) line_id=* {string} The ID of the Line Item.
x-codegen:
method: deleteLineItem
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.lineItems.delete(cartId, lineId) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useDeleteLineItem } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const deleteLineItem = useDeleteLineItem(cartId)
const handleDeleteItem = ( lineItemId: string ) => { deleteLineItem.mutate({ lineId: lineItemId, }, { onSuccess: ({ cart }) => { console.log(cart.items) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X DELETE '{backend_url}/store/carts/{id}/line-items/{line_id}'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) DeletePaymentSession ¶
@oas:path [delete] /store/carts/{id}/payment-sessions/{provider_id} operationId: DeleteCartsCartPaymentSessionsSession summary: "Delete a Payment Session" description: "Delete a Payment Session in a Cart. May be useful if a payment has failed. The totals will be recalculated." parameters:
- (path) id=* {string} The ID of the Cart.
- (path) provider_id=* {string} The ID of the Payment Provider used to create the Payment Session to be deleted.
x-codegen:
method: deletePaymentSession
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.deletePaymentSession(cartId, "manual") .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useDeletePaymentSession } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const deletePaymentSession = useDeletePaymentSession(cartId)
const handleDeletePaymentSession = ( providerId: string ) => { deletePaymentSession.mutate({ provider_id: providerId, }, { onSuccess: ({ cart }) => { console.log(cart.payment_sessions) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X DELETE '{backend_url}/store/carts/{id}/payment-sessions/{provider_id}'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) Get ¶
@oas:path [get] /store/carts/{id} operationId: "GetCartsCart" summary: "Get a Cart" description: "Retrieve a Cart's details. This includes recalculating its totals." parameters:
- (path) id=* {string} The ID of the Cart.
x-codegen:
method: retrieve
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.retrieve(cartId) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useGetCart } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const { cart, isLoading } = useGetCart(cartId)
return ( <div> {isLoading && <span>Loading...</span>} {cart && cart.items.length === 0 && ( <span>Cart is empty</span> )} {cart && cart.items.length > 0 && ( <ul> {cart.items.map((item) => ( <li key={item.id}>{item.title}</li> ))} </ul> )} </div> ) }
export default Cart
lang: Shell label: cURL source: | curl '{backend_url}/store/carts/{id}'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) RefreshPaymentSession ¶
@oas:path [post] /store/carts/{id}/payment-sessions/{provider_id}/refresh operationId: PostCartsCartPaymentSessionsSession summary: Refresh a Payment Session description: "Refresh a Payment Session to ensure that it is in sync with the Cart. This is usually not necessary, but is provided for edge cases." parameters:
- (path) id=* {string} The ID of the Cart.
- (path) provider_id=* {string} The ID of the Payment Provider that created the Payment Session to be refreshed.
x-codegen:
method: refreshPaymentSession
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.refreshPaymentSession(cartId, "manual") .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useRefreshPaymentSession } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const refreshPaymentSession = useRefreshPaymentSession(cartId)
const handleRefresh = ( providerId: string ) => { refreshPaymentSession.mutate({ provider_id: providerId, }, { onSuccess: ({ cart }) => { console.log(cart.payment_sessions) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}/payment-sessions/{provider_id}/refresh'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) SetPaymentSession ¶
@oas:path [post] /store/carts/{id}/payment-session operationId: PostCartsCartPaymentSession summary: Select a Payment Session description: "Select the Payment Session that will be used to complete the cart. This is typically used when the customer chooses their preferred payment method during checkout.
The totals of the cart will be recalculated."
parameters:
- (path) id=* {string} The ID of the Cart.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCartsCartPaymentSessionReq"
x-codegen:
method: setPaymentSession
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.setPaymentSession(cartId, { provider_id: "manual" }) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useSetPaymentSession } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const setPaymentSession = useSetPaymentSession(cartId)
const handleSetPaymentSession = ( providerId: string ) => { setPaymentSession.mutate({ provider_id: providerId, }, { onSuccess: ({ cart }) => { console.log(cart.payment_session) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}/payment-sessions' \ -H 'Content-Type: application/json' \ --data-raw '{ "provider_id": "manual" }'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) Update ¶
@oas:path [post] /store/carts/{id} operationId: PostCartsCart summary: Update a Cart description: "Update a Cart's details. If the cart has payment sessions and the region was not changed, the payment sessions are updated. The cart's totals are also recalculated." parameters:
- (path) id=* {string} The ID of the Cart.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCartsCartReq"
x-codegen:
method: update
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.update(cartId, { email: "user@example.com" }) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useUpdateCart } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const updateCart = useUpdateCart(cartId)
const handleUpdate = ( email: string ) => { updateCart.mutate({ email }, { onSuccess: ({ cart }) => { console.log(cart.email) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "user@example.com" }'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) UpdateLineItem ¶
@oas:path [post] /store/carts/{id}/line-items/{line_id} operationId: PostCartsCartLineItemsItem summary: Update a Line Item description: "Update a line item's quantity." parameters:
- (path) id=* {string} The ID of the Cart.
- (path) line_id=* {string} The ID of the Line Item.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCartsCartLineItemsItemReq"
x-codegen:
method: updateLineItem
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.lineItems.update(cartId, lineId, { quantity: 1 }) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useUpdateLineItem } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const updateLineItem = useUpdateLineItem(cartId)
const handleUpdateItem = ( lineItemId: string, quantity: number ) => { updateLineItem.mutate({ lineId: lineItemId, quantity, }, { onSuccess: ({ cart }) => { console.log(cart.items) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}/line-items/{line_id}' \ -H 'Content-Type: application/json' \ --data-raw '{ "quantity": 1 }'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Cart) UpdatePaymentSession ¶
@oas:path [post] /store/carts/{id}/payment-sessions/{provider_id} operationId: PostCartsCartPaymentSessionUpdate summary: Update a Payment Session description: "Update a Payment Session with additional data. This can be useful depending on the payment provider used.
All payment sessions are updated and cart totals are recalculated afterwards."
parameters:
- (path) id=* {string} The ID of the Cart.
- (path) provider_id=* {string} The ID of the payment provider.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCartsCartPaymentSessionUpdateReq"
x-codegen:
method: updatePaymentSession
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.carts.updatePaymentSession(cartId, "manual", { data: {
} }) .then(({ cart }) => { console.log(cart.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useUpdatePaymentSession } from "medusa-react"
type Props = { cartId: string }
const Cart = ({ cartId }: Props) => { const updatePaymentSession = useUpdatePaymentSession(cartId)
const handleUpdate = ( providerId: string, data: Record<string, unknown> ) => { updatePaymentSession.mutate({ provider_id: providerId, data }, { onSuccess: ({ cart }) => { console.log(cart.payment_session) } }) }
// ... }
export default Cart
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/carts/{id}/payment-sessions/manual' \ -H 'Content-Type: application/json' \ --data-raw '{ "data": {} }'
tags:
- Carts
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func NewCollection ¶
func NewCollection(r Registry) *Collection
func (*Collection) Get ¶
func (m *Collection) Get(context fiber.Ctx) error
@oas:path [get] /store/collections/{id} operationId: "GetCollectionsCollection" summary: "Get a Collection" description: "Retrieve a Product Collection's details." parameters:
- (path) id=* {string} The id of the Product Collection
x-codegen:
method: retrieve
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.collections.retrieve(collectionId) .then(({ collection }) => { console.log(collection.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCollection } from "medusa-react"
type Props = { collectionId: string }
const ProductCollection = ({ collectionId }: Props) => { const { collection, isLoading } = useCollection(collectionId)
return ( <div> {isLoading && <span>Loading...</span>} {collection && <span>{collection.title}</span>} </div> ) }
export default ProductCollection
lang: Shell label: cURL source: | curl '{backend_url}/store/collections/{id}'
tags:
- Product Collections
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCollectionsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Collection) List ¶
func (m *Collection) List(context fiber.Ctx) error
@oas:path [get] /store/collections operationId: "GetCollections" summary: "List Collections" description: "Retrieve a list of product collections. The product collections can be filtered by fields such as `handle` or `created_at`. The product collections can also be paginated." parameters:
- (query) offset=0 {integer} The number of product collections to skip when retrieving the product collections.
- (query) limit=10 {integer} Limit the number of product collections returned.
- in: query name: handle style: form explode: false description: Filter by handles schema: type: array items: type: string
- in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
x-codegen:
method: list queryParams: StoreGetCollectionsParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.collections.list() .then(({ collections, limit, offset, count }) => { console.log(collections.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useCollections } from "medusa-react"
const ProductCollections = () => { const { collections, isLoading } = useCollections()
return ( <div> {isLoading && <span>Loading...</span>} {collections && collections.length === 0 && ( <span>No Product Collections</span> )} {collections && collections.length > 0 && ( <ul> {collections.map((collection) => ( <li key={collection.id}>{collection.title}</li> ))} </ul> )} </div> ) }
export default ProductCollections
lang: Shell label: cURL source: | curl '{backend_url}/store/collections'
tags:
- Product Collections
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCollectionsListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Collection) SetRoutes ¶
func (m *Collection) SetRoutes(router fiber.Router)
type Customer ¶
type Customer struct {
// contains filtered or unexported fields
}
func NewCustomer ¶
func (*Customer) Create ¶
@oas:path [post] /store/customers operationId: PostCustomers summary: Create a Customer description: "Register a new customer. This will also automatically authenticate the customer and set their login session in the response Cookie header.
The cookie session can be used in subsequent requests to authenticate the customer. When using Medusa's JS or Medusa React clients, the cookie is automatically attached to subsequent requests."
requestBody:
content: application/json: schema: $ref: "#/components/schemas/PostCustomersReq"
x-codegen:
method: create
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.customers.create({ first_name: "Alec", last_name: "Reynolds", email: "user@example.com", password: "supersecret" }) .then(({ customer }) => { console.log(customer.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCreateCustomer } from "medusa-react"
const RegisterCustomer = () => { const createCustomer = useCreateCustomer() // ...
const handleCreate = ( customerData: { first_name: string last_name: string email: string password: string } ) => { // ... createCustomer.mutate(customerData, { onSuccess: ({ customer }) => { console.log(customer.id) } }) }
// ... }
export default RegisterCustomer
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/customers' \ -H 'Content-Type: application/json' \ --data-raw '{ "first_name": "Alec", "last_name": "Reynolds", "email": "user@example.com", "password": "supersecret" }'
tags:
- Customers
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCustomersRes" 422: description: A customer with the same email exists content: application/json: schema: type: object properties: code: type: string description: The error code type: type: string description: The type of error message: type: string description: Human-readable message with details about the error example: code: "invalid_request_error" type: "duplicate_error" message: "A customer with the given email already has an account. Log in instead" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) CreateAddress ¶
@oas:path [post] /store/customers/me/addresses operationId: PostCustomersCustomerAddresses summary: "Add a Shipping Address" description: "Add a Shipping Address to a Customer's saved addresses." x-authenticated: true requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCustomersCustomerAddressesReq"
x-codegen:
method: addAddress
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.addresses.addAddress({ address: { first_name: "Celia", last_name: "Schumm", address_1: "225 Bednar Curve", city: "Danielville", country_code: "US", postal_code: "85137", phone: "981-596-6748 x90188", company: "Wyman LLC", province: "Georgia", } }) .then(({ customer }) => { console.log(customer.id); })
- lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/customers/me/addresses' \ -H 'Authorization: Bearer {access_token}' \ -H 'Content-Type: application/json' \ --data-raw '{ "address": { "first_name": "Celia", "last_name": "Schumm", "address_1": "225 Bednar Curve", "city": "Danielville", "country_code": "US", "postal_code": "85137" } }'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Customers
responses:
"200": description: "A successful response" content: application/json: schema: $ref: "#/components/schemas/StoreCustomersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) DeleteAdress ¶
@oas:path [delete] /store/customers/me/addresses/{address_id} operationId: DeleteCustomersCustomerAddressesAddress summary: Delete an Address description: "Delete an Address from the Customer's saved addresses." x-authenticated: true parameters:
- (path) address_id=* {string} The id of the Address to remove.
x-codegen:
method: deleteAddress
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.addresses.deleteAddress(addressId) .then(({ customer }) => { console.log(customer.id); })
- lang: Shell label: cURL source: | curl -X DELETE '{backend_url}/store/customers/me/addresses/{address_id}' \ -H 'Authorization: Bearer {access_token}'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Customers
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCustomersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) Get ¶
@oas:path [get] /store/customers/me operationId: GetCustomersCustomer summary: Get a Customer description: "Retrieve the logged-in Customer's details." x-authenticated: true x-codegen:
method: retrieve
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.retrieve() .then(({ customer }) => { console.log(customer.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useMeCustomer } from "medusa-react"
const Customer = () => { const { customer, isLoading } = useMeCustomer()
return ( <div> {isLoading && <span>Loading...</span>} {customer && ( <span>{customer.first_name} {customer.last_name}</span> )} </div> ) }
export default Customer
lang: Shell label: cURL source: | curl '{backend_url}/store/customers/me' \ -H 'Authorization: Bearer {access_token}'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Customers
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCustomersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) GetPaymnetMethods ¶
@oas:path [get] /store/customers/me/payment-methods operationId: GetCustomersCustomerPaymentMethods summary: Get Saved Payment Methods description: "Retrieve the logged-in customer's saved payment methods. This API Route only works with payment providers created with the deprecated Payment Service interface.
The payment methods are saved using the Payment Service's third-party service, and not on the Medusa backend. So, they're retrieved from the third-party service."
x-authenticated: true deprecated: true x-codegen:
method: listPaymentMethods
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.paymentMethods.list() .then(({ payment_methods }) => { console.log(payment_methods.length); })
- lang: Shell label: cURL source: | curl '{backend_url}/store/customers/me/payment-methods' \ -H 'Authorization: Bearer {access_token}'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Customers
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCustomersListPaymentMethodsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) ListOrders ¶
@oas:path [get] /store/customers/me/orders operationId: GetCustomersCustomerOrders summary: List Orders description: "Retrieve a list of the logged-in Customer's Orders. The orders can be filtered by fields such as `status` or `fulfillment_status`. The orders can also be paginated." x-authenticated: true parameters:
- (query) q {string} term to search orders' display ID, email, shipping address's first name, customer's first name, customer's last name, and customer's phone number.
- (query) id {string} Filter by ID.
- in: query name: status style: form explode: false description: Filter by status. schema: type: array items: type: string enum: [pending, completed, archived, canceled, requires_action]
- in: query name: fulfillment_status style: form explode: false description: Fulfillment status to search for. schema: type: array items: type: string enum: [not_fulfilled, partially_fulfilled, fulfilled, partially_shipped, shipped, partially_returned, returned, canceled, requires_action]
- in: query name: payment_status style: form explode: false description: Payment status to search for. schema: type: array items: type: string enum: [not_paid, awaiting, captured, partially_refunded, refunded, canceled, requires_action]
- (query) display_id {string} Filter by display ID.
- (query) cart_id {string} Filter by cart ID.
- (query) email {string} Filter by email.
- (query) region_id {string} Filter by region ID.
- in: query name: currency_code style: form explode: false description: Filter by the 3 character ISO currency code of the order. schema: type: string externalDocs: url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes description: See a list of codes.
- (query) tax_rate {string} Filter by tax rate.
- in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- in: query name: canceled_at description: Filter by a cancelation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- (query) limit=10 {integer} Limit the number of orders returned.
- (query) offset=0 {integer} The number of orders to skip when retrieving the orders.
- (query) expand {string} Comma-separated relations that should be expanded in the returned orders.
- (query) fields {string} Comma-separated fields that should be included in the returned orders.
x-codegen:
method: listOrders queryParams: StoreGetCustomersCustomerOrdersParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.listOrders() .then(({ orders, limit, offset, count }) => { console.log(orders); })
lang: tsx label: Medusa React source: | import React from "react" import { useCustomerOrders } from "medusa-react"
const Orders = () => { // refetch a function that can be used to // re-retrieve orders after the customer logs in const { orders, isLoading } = useCustomerOrders()
return ( <div> {isLoading && <span>Loading orders...</span>} {orders?.length && ( <ul> {orders.map((order) => ( <li key={order.id}>{order.display_id}</li> ))} </ul> )} </div> ) }
export default Orders
lang: Shell label: cURL source: | curl '{backend_url}/store/customers/me/orders' \ -H 'Authorization: Bearer {access_token}'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Customers
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCustomersListOrdersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) ResetPassword ¶
@oas:path [post] /store/customers/password-reset operationId: PostCustomersResetPassword summary: Reset Password description: "Reset a Customer's password using a password token created by a previous request to the Request Password Reset API Route. If the password token expired,
you must create a new one."
externalDocs:
description: "How to reset password" url: "https://docs.medusajs.com/modules/customers/storefront/implement-customer-profiles#reset-password"
requestBody:
content: application/json: schema: $ref: "#/components/schemas/ResetPasswordRequest"
x-codegen:
method: resetPassword
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.customers.resetPassword({ email: "user@example.com", password: "supersecret", token: "supersecrettoken" }) .then(({ customer }) => { console.log(customer.id); })
- lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/customers/password-reset' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "user@example.com", "password": "supersecret", "token": "supersecrettoken" }'
tags:
- Customers
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCustomersResetPasswordRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) ResetPasswordTocken ¶
@oas:path [post] /store/customers/password-token operationId: PostCustomersCustomerPasswordToken summary: Request Password Reset description: "Create a reset password token to be used in a subsequent Reset Password API Route. This emits the event `customer.password_reset`. If a notification provider is
installed in the Medusa backend and is configured to handle this event, a notification to the customer, such as an email, may be sent with reset instructions."
externalDocs:
description: "How to reset password" url: "https://docs.medusajs.com/modules/customers/storefront/implement-customer-profiles#reset-password"
requestBody:
content: application/json: schema: $ref: "#/components/schemas/ResetPasswordTokenRequest"
x-codegen:
method: generatePasswordToken
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.customers.generatePasswordToken({ email: "user@example.com" }) .then(() => { // successful }) .catch(() => { // failed })
- lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/customers/password-token' \ -H 'Content-Type: application/json' \ --data-raw '{ "email": "user@example.com" }'
tags:
- Customers
responses:
204: description: OK "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) Update ¶
@oas:path [post] /store/customers/me operationId: PostCustomersCustomer summary: Update Customer description: "Update the logged-in customer's details." x-authenticated: true requestBody:
content: application/json: schema: $ref: "#/components/schemas/PostCustomersCustomerReq"
x-codegen:
method: update
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.update({ first_name: "Laury" }) .then(({ customer }) => { console.log(customer.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useUpdateMe } from "medusa-react"
type Props = { customerId: string }
const Customer = ({ customerId }: Props) => { const updateCustomer = useUpdateMe() // ...
const handleUpdate = ( firstName: string ) => { // ... updateCustomer.mutate({ id: customerId, first_name: firstName, }, { onSuccess: ({ customer }) => { console.log(customer.first_name) } }) }
// ... }
export default Customer
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/customers/me' \ -H 'Authorization: Bearer {access_token}' \ -H 'Content-Type: application/json' \ --data-raw '{ "first_name": "Laury" }'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Customers
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCustomersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Customer) UpdateAddress ¶
@oas:path [post] /store/customers/me/addresses/{address_id} operationId: PostCustomersCustomerAddressesAddress summary: "Update a Shipping Address" description: "Update the logged-in customer's saved Shipping Address's details." x-authenticated: true parameters:
- (path) address_id=* {String} The ID of the Address.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCustomersCustomerAddressesAddressReq"
x-codegen:
method: updateAddress
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.addresses.updateAddress(addressId, { first_name: "Gina" }) .then(({ customer }) => { console.log(customer.id); })
- lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/customers/me/addresses/{address_id}' \ -H 'Authorization: Bearer {access_token}' \ -H 'Content-Type: application/json' \ --data-raw '{ "first_name": "Gina" }'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Customers
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCustomersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type GiftCard ¶
type GiftCard struct {
// contains filtered or unexported fields
}
func NewGiftCard ¶
func (*GiftCard) Get ¶
@oas:path [get] /store/gift-cards/{code} operationId: "GetGiftCardsCode" summary: "Get Gift Card by Code" description: "Retrieve a Gift Card's details by its associated unique code." parameters:
- (path) code=* {string} The unique Gift Card code.
x-codegen:
method: retrieve
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.giftCards.retrieve(code) .then(({ gift_card }) => { console.log(gift_card.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useGiftCard } from "medusa-react"
type Props = { giftCardCode: string }
const GiftCard = ({ giftCardCode }: Props) => { const { gift_card, isLoading, isError } = useGiftCard( giftCardCode )
return ( <div> {isLoading && <span>Loading...</span>} {gift_card && <span>{gift_card.value}</span>} {isError && <span>Gift Card does not exist</span>} </div> ) }
export default GiftCard
lang: Shell label: cURL source: | curl '{backend_url}/store/gift-cards/{code}'
tags:
- Gift Cards
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreGiftCardsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type Order ¶
type Order struct {
// contains filtered or unexported fields
}
func (*Order) ConfirmRequest ¶
@oas:path [post] /store/orders/customer/confirm operationId: "PostOrdersCustomerOrderClaimsCustomerOrderClaimAccept" summary: "Verify Order Claim" description: "Verify the claim order token provided to the customer when they request ownership of an order." externalDocs:
description: "How to implement claim-order flow in a storefront" url: "https://docs.medusajs.com/modules/orders/storefront/implement-claim-order"
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCustomersCustomerAcceptClaimReq"
x-codegen:
method: confirmRequest
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.orders.confirmRequest( token, ) .then(() => { // successful }) .catch(() => { // an error occurred })
lang: tsx label: Medusa React source: | import React from "react" import { useGrantOrderAccess } from "medusa-react"
const ClaimOrder = () => { const confirmOrderRequest = useGrantOrderAccess()
const handleOrderRequestConfirmation = ( token: string ) => { confirmOrderRequest.mutate({ token }, { onSuccess: () => { // successful }, onError: () => { // an error occurred. } }) }
// ... }
export default ClaimOrder
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/orders/customer/confirm' \ -H 'Content-Type: application/json' \ --data-raw '{ "token": "{token}", }'
security:
- api_token: []
- cookie_auth: []
- jwt_token: []
tags:
- Orders
responses:
200: description: OK "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Order) Get ¶
@oas:path [get] /store/orders/{id} operationId: GetOrdersOrder summary: Get an Order description: "Retrieve an Order's details." parameters:
- (path) id=* {string} The ID of the Order.
- (query) fields {string} Comma-separated fields that should be expanded in the returned order.
- (query) expand {string} Comma-separated relations that should be included in the returned order.
x-codegen:
method: retrieve
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.orders.retrieve(orderId) .then(({ order }) => { console.log(order.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useOrder } from "medusa-react"
type Props = { orderId: string }
const Order = ({ orderId }: Props) => { const { order, isLoading, } = useOrder(orderId)
return ( <div> {isLoading && <span>Loading...</span>} {order && <span>{order.display_id}</span>}
</div> ) }
export default Order
lang: Shell label: cURL source: | curl '{backend_url}/store/orders/{id}'
tags:
- Orders
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreOrdersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Order) GetByCart ¶
@oas:path [get] /store/orders/cart/{cart_id} operationId: GetOrdersOrderCartId summary: Get by Cart ID description: "Retrieve an Order's details by the ID of the Cart that was used to create the Order." parameters:
- (path) cart_id=* {string} The ID of Cart.
x-codegen:
method: retrieveByCartId
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.orders.retrieveByCartId(cartId) .then(({ order }) => { console.log(order.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCartOrder } from "medusa-react"
type Props = { cartId: string }
const Order = ({ cartId }: Props) => { const { order, isLoading, } = useCartOrder(cartId)
return ( <div> {isLoading && <span>Loading...</span>} {order && <span>{order.display_id}</span>}
</div> ) }
export default Order
lang: Shell label: cURL source: | curl '{backend_url}/store/orders/cart/{cart_id}'
tags:
- Orders
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreOrdersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Order) Lookup ¶
@oas:path [get] /store/orders operationId: "GetOrders" summary: "Look Up an Order" description: "Look up an order using filters. If the filters don't narrow down the results to a single order, a 404 response is returned with no orders." parameters:
- (query) display_id=* {number} Filter by ID.
- (query) fields {string} Comma-separated fields that should be expanded in the returned order.
- (query) expand {string} Comma-separated relations that should be expanded in the returned order.
- in: query name: email style: form explode: false description: Filter by email. required: true schema: type: string format: email
- in: query name: shipping_address style: form explode: false description: Filter by the shipping address's postal code. schema: type: object properties: postal_code: type: string description: The postal code of the shipping address
x-codegen:
method: lookupOrder queryParams: StoreGetOrdersParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.orders.lookupOrder({ display_id: 1, email: "user@example.com" }) .then(({ order }) => { console.log(order.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useOrders } from "medusa-react"
type Props = { displayId: number email: string }
const Order = ({ displayId, email }: Props) => { const { order, isLoading, } = useOrders({ display_id: displayId, email, })
return ( <div> {isLoading && <span>Loading...</span>} {order && <span>{order.display_id}</span>}
</div> ) }
export default Order
lang: Shell label: cURL source: | curl '{backend_url}/store/orders?display_id=1&email=user@example.com'
tags:
- Orders
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreOrdersRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Order) Request ¶
@oas:path [post] /store/orders/batch/customer/token operationId: "PostOrdersCustomerOrderClaim" summary: "Claim Order" description: "Allow the logged-in customer to claim ownership of one or more orders. This generates a token that can be used later on to verify the claim using the Verify Order Claim API Route.
This also emits the event `order-update-token.created`. So, if you have a notification provider installed that handles this event and sends the customer a notification, such as an email, the customer should receive instructions on how to finalize their claim ownership."
externalDocs:
description: "How to implement claim-order flow in a storefront" url: "https://docs.medusajs.com/modules/orders/storefront/implement-claim-order"
x-authenticated: true requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCustomersCustomerOrderClaimReq"
x-codegen:
method: requestCustomerOrders
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.orders.requestCustomerOrders({ order_ids, }) .then(() => { // successful }) .catch(() => { // an error occurred })
lang: tsx label: Medusa React source: | import React from "react" import { useRequestOrderAccess } from "medusa-react"
const ClaimOrder = () => { const claimOrder = useRequestOrderAccess()
const handleClaimOrder = ( orderIds: string[] ) => { claimOrder.mutate({ order_ids: orderIds }, { onSuccess: () => { // successful }, onError: () => { // an error occurred. } }) }
// ... }
export default ClaimOrder
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/batch/customer/token' \ -H 'Content-Type: application/json' \ --data-raw '{ "order_ids": ["id"], }'
security:
- api_token: []
- cookie_auth: []
- jwt_token: []
tags:
- Orders
responses:
200: description: OK "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type OrderEdit ¶
type OrderEdit struct {
// contains filtered or unexported fields
}
func NewOrderEdit ¶
func (*OrderEdit) Complete ¶
@oas:path [post] /store/order-edits/{id}/complete operationId: "PostOrderEditsOrderEditComplete" summary: "Complete an Order Edit" description: "Complete an Order Edit and reflect its changes on the original order. Any additional payment required must be authorized first using the Payment Collection API Routes." externalDocs:
description: "How to handle order edits in a storefront" url: "https://docs.medusajs.com/modules/orders/storefront/handle-order-edits"
parameters:
- (path) id=* {string} The ID of the Order Edit.
x-codegen:
method: complete
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.orderEdits.complete(orderEditId) .then(({ order_edit }) => { console.log(order_edit.id) })
lang: tsx label: Medusa React source: | import React from "react" import { useCompleteOrderEdit } from "medusa-react"
type Props = { orderEditId: string }
const OrderEdit = ({ orderEditId }: Props) => { const completeOrderEdit = useCompleteOrderEdit( orderEditId ) // ...
const handleCompleteOrderEdit = () => { completeOrderEdit.mutate(void 0, { onSuccess: ({ order_edit }) => { console.log(order_edit.confirmed_at) } }) }
// ... }
export default OrderEdit
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/order-edits/{id}/complete'
tags:
- Order Edits
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreOrderEditsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*OrderEdit) Decline ¶
@oas:path [post] /store/order-edits/{id}/decline operationId: "PostOrderEditsOrderEditDecline" summary: "Decline an Order Edit" description: "Decline an Order Edit. The changes are not reflected on the original order." parameters:
- (path) id=* {string} The ID of the OrderEdit.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostOrderEditsOrderEditDecline"
x-codegen:
method: decline
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.orderEdits.decline(orderEditId) .then(({ order_edit }) => { console.log(order_edit.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useDeclineOrderEdit } from "medusa-react"
type Props = { orderEditId: string }
const OrderEdit = ({ orderEditId }: Props) => { const declineOrderEdit = useDeclineOrderEdit(orderEditId) // ...
const handleDeclineOrderEdit = ( declinedReason: string ) => { declineOrderEdit.mutate({ declined_reason: declinedReason, }, { onSuccess: ({ order_edit }) => { console.log(order_edit.declined_at) } }) }
// ... }
export default OrderEdit
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/order-edits/{id}/decline'
tags:
- Order Edits
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreOrderEditsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*OrderEdit) Get ¶
@oas:path [get] /store/order-edits/{id} operationId: "GetOrderEditsOrderEdit" summary: "Retrieve an Order Edit" description: "Retrieve an Order Edit's details." parameters:
- (path) id=* {string} The ID of the OrderEdit.
x-codegen:
method: retrieve
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.orderEdits.retrieve(orderEditId) .then(({ order_edit }) => { console.log(order_edit.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useOrderEdit } from "medusa-react"
type Props = { orderEditId: string }
const OrderEdit = ({ orderEditId }: Props) => { const { order_edit, isLoading } = useOrderEdit(orderEditId)
return ( <div> {isLoading && <span>Loading...</span>} {order_edit && ( <ul> {order_edit.changes.map((change) => ( <li key={change.id}>{change.type}</li> ))} </ul> )} </div> ) }
export default OrderEdit
lang: Shell label: cURL source: | curl '{backend_url}/store/order-edits/{id}'
tags:
- Order Edits
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreOrderEditsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type PaymentCollection ¶
type PaymentCollection struct {
// contains filtered or unexported fields
}
func NewPaymentCollection ¶
func NewPaymentCollection(r Registry) *PaymentCollection
func (*PaymentCollection) Get ¶
func (m *PaymentCollection) Get(context fiber.Ctx) error
@oas:path [get] /store/payment-collections/{id} operationId: "GetPaymentCollectionsPaymentCollection" summary: "Get a PaymentCollection" description: "Retrieve a Payment Collection's details." x-authenticated: false parameters:
- (path) id=* {string} The ID of the PaymentCollection.
- (query) fields {string} Comma-separated fields that should be expanded in the returned payment collection.
- (query) expand {string} Comma-separated relations that should be expanded in the returned payment collection.
x-codegen:
method: retrieve queryParams: StoreGetPaymentCollectionsParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.paymentCollections.retrieve(paymentCollectionId) .then(({ payment_collection }) => { console.log(payment_collection.id) })
lang: tsx label: Medusa React source: | import React from "react" import { usePaymentCollection } from "medusa-react"
type Props = { paymentCollectionId: string }
const PaymentCollection = ({ paymentCollectionId }: Props) => { const { payment_collection, isLoading } = usePaymentCollection( paymentCollectionId )
return ( <div> {isLoading && <span>Loading...</span>} {payment_collection && ( <span>{payment_collection.status}</span> )} </div> ) }
export default PaymentCollection
lang: Shell label: cURL source: | curl '{backend_url}/store/payment-collections/{id}'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Payment Collections
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StorePaymentCollectionsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*PaymentCollection) PaymentSessionAuthorize ¶
func (m *PaymentCollection) PaymentSessionAuthorize(context fiber.Ctx) error
@oas:path [post] /store/payment-collections/{id}/sessions/{session_id}/authorize operationId: "PostPaymentCollectionsSessionsSessionAuthorize" summary: "Authorize Payment Session" description: "Authorize a Payment Session of a Payment Collection." x-authenticated: false parameters:
- (path) id=* {string} The ID of the Payment Collection.
- (path) session_id=* {string} The ID of the Payment Session.
x-codegen:
method: authorizePaymentSession
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.paymentCollections.authorize(paymentId, sessionId) .then(({ payment_collection }) => { console.log(payment_collection.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useAuthorizePaymentSession } from "medusa-react"
type Props = { paymentCollectionId: string }
const PaymentCollection = ({ paymentCollectionId }: Props) => { const authorizePaymentSession = useAuthorizePaymentSession( paymentCollectionId ) // ...
const handleAuthorizePayment = (paymentSessionId: string) => { authorizePaymentSession.mutate(paymentSessionId, { onSuccess: ({ payment_collection }) => { console.log(payment_collection.payment_sessions) } }) }
// ... }
export default PaymentCollection
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/payment-collections/{id}/sessions/{session_id}/authorize'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Payment Collections
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StorePaymentCollectionsSessionRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*PaymentCollection) PaymentSessionAuthorizeBatch ¶
func (m *PaymentCollection) PaymentSessionAuthorizeBatch(context fiber.Ctx) error
@oas:path [post] /store/payment-collections/{id}/sessions/batch/authorize operationId: "PostPaymentCollectionsSessionsBatchAuthorize" summary: "Authorize Payment Sessions" description: "Authorize the Payment Sessions of a Payment Collection." x-authenticated: false parameters:
- (path) id=* {string} The ID of the Payment Collections.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostPaymentCollectionsBatchSessionsAuthorizeReq"
x-codegen:
method: authorizePaymentSessionsBatch
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.paymentCollections.authorize(paymentId) .then(({ payment_collection }) => { console.log(payment_collection.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useAuthorizePaymentSessionsBatch } from "medusa-react"
type Props = { paymentCollectionId: string }
const PaymentCollection = ({ paymentCollectionId }: Props) => { const authorizePaymentSessions = useAuthorizePaymentSessionsBatch( paymentCollectionId ) // ...
const handleAuthorizePayments = (paymentSessionIds: string[]) => { authorizePaymentSessions.mutate({ session_ids: paymentSessionIds }, { onSuccess: ({ payment_collection }) => { console.log(payment_collection.payment_sessions) } }) }
// ... }
export default PaymentCollection
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/payment-collections/{id}/sessions/batch/authorize'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Payment Collections
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StorePaymentCollectionsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*PaymentCollection) PaymentSessionManage ¶
func (m *PaymentCollection) PaymentSessionManage(context fiber.Ctx) error
@oas:path [post] /store/payment-collections/{id}/sessions operationId: "PostPaymentCollectionsSessions" summary: "Create a Payment Session" description: "Create a Payment Session for a payment provider in a Payment Collection." x-authenticated: false parameters:
- (path) id=* {string} The ID of the Payment Collection.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostCartsCartPaymentSessionReq"
x-codegen:
method: managePaymentSession
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.paymentCollections.managePaymentSession(payment_id, { provider_id: "stripe" }) .then(({ payment_collection }) => { console.log(payment_collection.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useManagePaymentSession } from "medusa-react"
type Props = { paymentCollectionId: string }
const PaymentCollection = ({ paymentCollectionId }: Props) => { const managePaymentSession = useManagePaymentSession( paymentCollectionId )
const handleManagePaymentSession = ( providerId: string ) => { managePaymentSession.mutate({ provider_id: providerId }, { onSuccess: ({ payment_collection }) => { console.log(payment_collection.payment_sessions) } }) }
// ... }
export default PaymentCollection
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/payment-collections/{id}/sessions' \ -H 'Content-Type: application/json' \ --data-raw '{ "provider_id": "stripe" }'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Payment Collections
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StorePaymentCollectionsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*PaymentCollection) PaymentSessionManageBatch ¶
func (m *PaymentCollection) PaymentSessionManageBatch(context fiber.Ctx) error
@oas:path [post] /store/payment-collections/{id}/sessions/batch operationId: "PostPaymentCollectionsPaymentCollectionSessionsBatch" summary: "Manage Payment Sessions" description: "Create, update, or delete a list of payment sessions of a Payment Collections. If a payment session is not provided in the `sessions` array, it's deleted." x-authenticated: false parameters:
- (path) id=* {string} The ID of the Payment Collection.
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostPaymentCollectionsBatchSessionsReq"
x-codegen:
method: managePaymentSessionsBatch
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token
// Total amount = 10000
// Example 1: Adding two new sessions medusa.paymentCollections.managePaymentSessionsBatch(paymentId, { sessions: [ { provider_id: "stripe", amount: 5000, }, { provider_id: "manual", amount: 5000, }, ] }) .then(({ payment_collection }) => { console.log(payment_collection.id); })
// Example 2: Updating one session and removing the other medusa.paymentCollections.managePaymentSessionsBatch(paymentId, { sessions: [ { provider_id: "stripe", amount: 10000, session_id: "ps_123456" }, ] }) .then(({ payment_collection }) => { console.log(payment_collection.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useManageMultiplePaymentSessions } from "medusa-react"
type Props = { paymentCollectionId: string }
const PaymentCollection = ({ paymentCollectionId }: Props) => { const managePaymentSessions = useManageMultiplePaymentSessions( paymentCollectionId )
const handleManagePaymentSessions = () => { // Total amount = 10000
// Example 1: Adding two new sessions managePaymentSessions.mutate({ sessions: [ { provider_id: "stripe", amount: 5000, }, { provider_id: "manual", amount: 5000, }, ] }, { onSuccess: ({ payment_collection }) => { console.log(payment_collection.payment_sessions) } })
// Example 2: Updating one session and removing the other managePaymentSessions.mutate({ sessions: [ { provider_id: "stripe", amount: 10000, session_id: "ps_123456" }, ] }, { onSuccess: ({ payment_collection }) => { console.log(payment_collection.payment_sessions) } }) }
// ... }
export default PaymentCollection
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/payment-collections/{id}/sessions/batch' \ -H 'Content-Type: application/json' \ --data-raw '{ "sessions": [ { "provider_id": "stripe", "amount": 5000 }, { "provider_id": "manual", "amount": 5000 } ] }'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Payment Collections
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StorePaymentCollectionsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*PaymentCollection) PaymentSessionRefresh ¶
func (m *PaymentCollection) PaymentSessionRefresh(context fiber.Ctx) error
@oas:path [post] /store/payment-collections/{id}/sessions/{session_id} operationId: PostPaymentCollectionsPaymentCollectionPaymentSessionsSession summary: "Refresh a Payment Session" description: "Refresh a Payment Session's data to ensure that it is in sync with the Payment Collection." x-authenticated: false parameters:
- (path) id=* {string} The id of the PaymentCollection.
- (path) session_id=* {string} The id of the Payment Session to be refreshed.
x-codegen:
method: refreshPaymentSession
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.paymentCollections.refreshPaymentSession(paymentCollectionId, sessionId) .then(({ payment_session }) => { console.log(payment_session.id); })
lang: tsx label: Medusa React source: | import React from "react" import { usePaymentCollectionRefreshPaymentSession } from "medusa-react"
type Props = { paymentCollectionId: string }
const PaymentCollection = ({ paymentCollectionId }: Props) => { const refreshPaymentSession = usePaymentCollectionRefreshPaymentSession( paymentCollectionId ) // ...
const handleRefreshPaymentSession = (paymentSessionId: string) => { refreshPaymentSession.mutate(paymentSessionId, { onSuccess: ({ payment_session }) => { console.log(payment_session.status) } }) }
// ... }
export default PaymentCollection
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/payment-collections/{id}/sessions/{session_id}'
security:
- cookie_auth: []
- jwt_token: []
tags:
- Payment Collections
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StorePaymentCollectionsSessionRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*PaymentCollection) SetRoutes ¶
func (m *PaymentCollection) SetRoutes(router fiber.Router)
type Product ¶
type Product struct {
// contains filtered or unexported fields
}
func NewProduct ¶
func (*Product) Get ¶
@oas:path [get] /store/products/{id} operationId: GetProductsProduct summary: Get a Product description: |
Retrieve a Product's details. For accurate and correct pricing of the product based on the customer's context, it's highly recommended to pass fields such as `region_id`, `currency_code`, and `cart_id` when available. Passing `sales_channel_id` ensures retrieving only products available in the current sales channel. You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
externalDocs:
description: "How to pass product pricing parameters" url: "https://docs.medusajs.com/modules/products/storefront/show-products#product-pricing-parameters"
parameters:
- (path) id=* {string} The ID of the Product.
- (query) sales_channel_id {string} The ID of the sales channel the customer is viewing the product from.
- (query) cart_id {string} The ID of the cart. This is useful for accurate pricing based on the cart's context.
- (query) region_id {string} The ID of the region. This is useful for accurate pricing based on the selected region.
- (query) expand {string} Comma-separated relations that should be expanded in the returned product.
- (query) fields {string} Comma-separated fields that should be included in the returned product.
- in: query name: currency_code style: form explode: false description: A 3 character ISO currency code. This is useful for accurate pricing based on the selected currency. schema: type: string externalDocs: url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes description: See a list of codes.
x-codegen:
method: retrieve queryParams: StoreGetProductsProductParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.products.retrieve(productId) .then(({ product }) => { console.log(product.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useProduct } from "medusa-react"
type Props = { productId: string }
const Product = ({ productId }: Props) => { const { product, isLoading } = useProduct(productId)
return ( <div> {isLoading && <span>Loading...</span>} {product && <span>{product.title}</span>} </div> ) }
export default Product
lang: Shell label: cURL source: | curl '{backend_url}/store/products/{id}'
tags:
- Products
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreProductsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Product) List ¶
@oas:path [get] /store/products operationId: GetProducts summary: List Products description: |
Retrieves a list of products. The products can be filtered by fields such as `id` or `q`. The products can also be sorted or paginated. This API Route can also be used to retrieve a product by its handle. For accurate and correct pricing of the products based on the customer's context, it's highly recommended to pass fields such as `region_id`, `currency_code`, and `cart_id` when available. Passing `sales_channel_id` ensures retrieving only products available in the specified sales channel. You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
externalDocs:
description: "How to retrieve a product by its handle" url: "https://docs.medusajs.com/modules/products/storefront/show-products#retrieve-product-by-handle"
parameters:
- (query) q {string} term used to search products' title, description, variant's title, variant's sku, and collection's title.
- in: query name: id style: form explode: false description: Filter by IDs. schema: oneOf:
- type: string
- type: array items: type: string
- in: query name: sales_channel_id style: form explode: false description: "Filter by sales channel IDs. When provided, only products available in the selected sales channels are retrieved. Alternatively, you can pass a publishable API key in the request header and this will have the same effect." schema: type: array items: type: string
- in: query name: collection_id style: form explode: false description: Filter by product collection IDs. When provided, only products that belong to the specified product collections are retrieved. schema: type: array items: type: string
- in: query name: type_id style: form explode: false description: Filter by product type IDs. When provided, only products that belong to the specified product types are retrieved. schema: type: array items: type: string
- in: query name: tags style: form explode: false description: Filter by product tag IDs. When provided, only products that belong to the specified product tags are retrieved. schema: type: array items: type: string
- (query) title {string} Filter by title.
- (query) description {string} Filter by description
- (query) handle {string} Filter by handle.
- (query) is_giftcard {boolean} Whether to retrieve regular products or gift-card products.
- in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- in: query name: category_id style: form explode: false description: Filter by product category IDs. When provided, only products that belong to the specified product categories are retrieved. schema: type: array x-featureFlag: "product_categories" items: type: string
- in: query name: include_category_children style: form explode: false description: Whether to include child product categories when filtering using the `category_id` field. schema: type: boolean x-featureFlag: "product_categories"
- (query) offset=0 {integer} The number of products to skip when retrieving the products.
- (query) limit=100 {integer} Limit the number of products returned.
- (query) expand {string} Comma-separated relations that should be expanded in the returned products.
- (query) fields {string} Comma-separated fields that should be included in the returned products.
- (query) order {string} A product field to sort-order the retrieved products by.
- (query) cart_id {string} The ID of the cart. This is useful for accurate pricing based on the cart's context.
- (query) region_id {string} The ID of the region. This is useful for accurate pricing based on the selected region.
- in: query name: currency_code style: form explode: false description: A 3 character ISO currency code. This is useful for accurate pricing based on the selected currency. schema: type: string externalDocs: url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes description: See a list of codes.
x-codegen:
method: list queryParams: StoreGetProductsParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.products.list() .then(({ products, limit, offset, count }) => { console.log(products.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useProducts } from "medusa-react"
const Products = () => { const { products, isLoading } = useProducts()
return ( <div> {isLoading && <span>Loading...</span>} {products && !products.length && <span>No Products</span>} {products && products.length > 0 && ( <ul> {products.map((product) => ( <li key={product.id}>{product.title}</li> ))} </ul> )} </div> ) }
export default Products
lang: Shell label: cURL source: | curl '{backend_url}/store/products'
tags:
- Products
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreProductsListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Product) Search ¶
@oas:path [post] /store/products/search operationId: PostProductsSearch summary: Search Products description: "Run a search query on products using the search service installed on the Medusa backend. The searching is handled through the search service, so the returned data's
format depends on the search service you're using."
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostSearchReq"
x-codegen:
method: search
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.products.search({ q: "Shirt" }) .then(({ hits }) => { console.log(hits.length); })
- lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/products/search' \ -H 'Content-Type: application/json' \ --data-raw '{ "q": "Shirt" }'
tags:
- Products
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StorePostSearchRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type ProductCategory ¶
type ProductCategory struct {
// contains filtered or unexported fields
}
func NewProductCategory ¶
func NewProductCategory(r Registry) *ProductCategory
func (*ProductCategory) Get ¶
func (m *ProductCategory) Get(context fiber.Ctx) error
@oas:path [get] /store/product-categories/{id} operationId: "GetProductCategoriesCategory" summary: "Get a Product Category" description: "Retrieve a Product Category's details." x-featureFlag: "product_categories" parameters:
- (path) id=* {string} The ID of the Product Category
- (query) fields {string} Comma-separated fields that should be expanded in the returned product category.
- (query) expand {string} Comma-separated relations that should be expanded in the returned product category.
x-codegen:
method: retrieve queryParams: StoreGetProductCategoriesCategoryParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.productCategories.retrieve(productCategoryId) .then(({ product_category }) => { console.log(product_category.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useProductCategory } from "medusa-react"
type Props = { categoryId: string }
const Category = ({ categoryId }: Props) => { const { product_category, isLoading } = useProductCategory( categoryId )
return ( <div> {isLoading && <span>Loading...</span>} {product_category && <span>{product_category.name}</span>} </div> ) }
export default Category
lang: Shell label: cURL source: | curl '{backend_url}/store/product-categories/{id}' \ -H 'x-medusa-access-token: {api_token}'
security:
- api_token: []
- cookie_auth: []
- jwt_token: []
tags:
- Product Categories
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreGetProductCategoriesCategoryRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*ProductCategory) List ¶
func (m *ProductCategory) List(context fiber.Ctx) error
@oas:path [get] /store/product-categories operationId: "GetProductCategories" summary: "List Product Categories" description: "Retrieve a list of product categories. The product categories can be filtered by fields such as `handle` or `q`. The product categories can also be paginated.
This API Route can also be used to retrieve a product category by its handle."
x-featureFlag: "product_categories" externalDocs:
description: "How to retrieve a product category by its handle" url: "https://docs.medusajs.com/modules/products/storefront/use-categories#get-a-category-by-its-handle"
parameters:
- (query) q {string} term used to search product category's names and handles.
- (query) handle {string} Filter by handle.
- (query) parent_category_id {string} Filter by the ID of a parent category. Only children of the provided parent category are retrieved.
- (query) include_descendants_tree {boolean} Whether all nested categories inside a category should be retrieved.
- (query) offset=0 {integer} The number of product categories to skip when retrieving the product categories.
- (query) limit=100 {integer} Limit the number of product categories returned.
- (query) expand {string} Comma-separated relations that should be expanded in the returned product categories.
- (query) fields {string} Comma-separated fields that should be included in the returned product categories.
x-codegen:
method: list queryParams: StoreGetProductCategoriesParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.productCategories.list() .then(({ product_categories, limit, offset, count }) => { console.log(product_categories.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useProductCategories } from "medusa-react"
function Categories() { const { product_categories, isLoading, } = useProductCategories()
return ( <div> {isLoading && <span>Loading...</span>} {product_categories && !product_categories.length && ( <span>No Categories</span> )} {product_categories && product_categories.length > 0 && ( <ul> {product_categories.map( (category) => ( <li key={category.id}>{category.name}</li> ) )} </ul> )} </div> ) }
export default Categories
lang: Shell label: cURL source: | curl '{backend_url}/store/product-categories' \ -H 'x-medusa-access-token: {api_token}'
security:
- api_token: []
- cookie_auth: []
- jwt_token: []
tags:
- Product Categories
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreGetProductCategoriesRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*ProductCategory) SetRoutes ¶
func (m *ProductCategory) SetRoutes(router fiber.Router)
type ProductTag ¶
type ProductTag struct {
// contains filtered or unexported fields
}
func NewProductTag ¶
func NewProductTag(r Registry) *ProductTag
func (*ProductTag) List ¶
func (m *ProductTag) List(context fiber.Ctx) error
@oas:path [get] /store/product-tags operationId: "GetProductTags" summary: "List Product Tags" description: "Retrieve a list of product tags. The product tags can be filtered by fields such as `id` or `q`. The product tags can also be sorted or paginated." x-authenticated: true x-codegen:
method: list queryParams: StoreGetProductTagsParams
parameters:
- (query) limit=20 {integer} Limit the number of product tags returned.
- (query) offset=0 {integer} The number of product tags to skip when retrieving the product tags.
- (query) order {string} A product-tag field to sort-order the retrieved product tags by.
- (query) discount_condition_id {string} Filter by the ID of a discount condition. When provided, only tags that the discount condition applies for will be retrieved.
- in: query name: value style: form explode: false description: Filter by tag values. schema: type: array items: type: string
- in: query name: id style: form explode: false description: Filter by IDs. schema: type: array items: type: string
- (query) q {string} term to search product tag's value.
- in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.productTags.list() .then(({ product_tags }) => { console.log(product_tags.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useProductTags } from "medusa-react"
function Tags() { const { product_tags, isLoading, } = useProductTags()
return ( <div> {isLoading && <span>Loading...</span>} {product_tags && !product_tags.length && ( <span>No Product Tags</span> )} {product_tags && product_tags.length > 0 && ( <ul> {product_tags.map( (tag) => ( <li key={tag.id}>{tag.value}</li> ) )} </ul> )} </div> ) }
export default Tags
lang: Shell label: cURL source: | curl '{backend_url}/store/product-tags'
tags:
- Product Tags
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreProductTagsListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*ProductTag) SetRoutes ¶
func (m *ProductTag) SetRoutes(router fiber.Router)
type ProductType ¶
type ProductType struct {
// contains filtered or unexported fields
}
func NewProductType ¶
func NewProductType(r Registry) *ProductType
func (*ProductType) List ¶
func (m *ProductType) List(context fiber.Ctx) error
@oas:path [get] /store/product-types operationId: "GetProductTypes" summary: "List Product Types" description: "Retrieve a list of product types. The product types can be filtered by fields such as `value` or `q`. The product types can also be sorted or paginated." x-authenticated: true parameters:
- (query) limit=20 {integer} Limit the number of product types returned.
- (query) offset=0 {integer} The number of product types to skip when retrieving the product types.
- (query) order {string} A product-type field to sort-order the retrieved product types by.
- (query) discount_condition_id {string} Filter by the ID of a discount condition. When provided, only types that the discount condition applies for will be retrieved.
- in: query name: value style: form explode: false description: Filter by type values. schema: type: array items: type: string
- in: query name: id style: form explode: false description: Filter by IDs. schema: type: array items: type: string
- (query) q {string} term to search product type's value.
- in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
x-codegen:
method: list queryParams: StoreGetProductTypesParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.productTypes.list() .then(({ product_types }) => { console.log(product_types.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useProductTypes } from "medusa-react"
function Types() { const { product_types, isLoading, } = useProductTypes()
return ( <div> {isLoading && <span>Loading...</span>} {product_types && !product_types.length && ( <span>No Product Types</span> )} {product_types && product_types.length > 0 && ( <ul> {product_types.map( (type) => ( <li key={type.id}>{type.value}</li> ) )} </ul> )} </div> ) }
export default Types
lang: Shell label: cURL source: | curl '{backend_url}/store/product-types'
security:
- api_token: []
- cookie_auth: []
- jwt_token: []
tags:
- Product Types
responses:
"200": description: OK content: application/json: schema: $ref: "#/components/schemas/StoreProductTypesListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "401": $ref: "#/components/responses/unauthorized" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*ProductType) SetRoutes ¶
func (m *ProductType) SetRoutes(router fiber.Router)
type Region ¶
type Region struct {
// contains filtered or unexported fields
}
func (*Region) Get ¶
@oas:path [get] /store/regions/{id} operationId: GetRegionsRegion summary: Get a Region description: "Retrieve a Region's details." parameters:
- (path) id=* {string} The ID of the Region.
x-codegen:
method: retrieve
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.regions.retrieve(regionId) .then(({ region }) => { console.log(region.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useRegion } from "medusa-react"
type Props = { regionId: string }
const Region = ({ regionId }: Props) => { const { region, isLoading } = useRegion( regionId )
return ( <div> {isLoading && <span>Loading...</span>} {region && <span>{region.name}</span>} </div> ) }
export default Region
lang: Shell label: cURL source: | curl '{backend_url}/store/regions/{id}'
tags:
- Regions
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreRegionsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Region) List ¶
@oas:path [get] /store/regions operationId: GetRegions summary: List Regions description: "Retrieve a list of regions. The regions can be filtered by fields such as `created_at`. The regions can also be paginated. This API Route is useful to
show the customer all available regions to choose from."
externalDocs:
description: "How to use regions in a storefront" url: "https://docs.medusajs.com/modules/regions-and-currencies/storefront/use-regions"
parameters:
- (query) offset=0 {integer} The number of regions to skip when retrieving the regions.
- (query) limit=100 {integer} Limit the number of regions returned.
- in: query name: created_at description: Filter by a creation date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
- in: query name: updated_at description: Filter by an update date range. schema: type: object properties: lt: type: string description: filter by dates less than this date format: date gt: type: string description: filter by dates greater than this date format: date lte: type: string description: filter by dates less than or equal to this date format: date gte: type: string description: filter by dates greater than or equal to this date format: date
x-codegen:
method: list queryParams: StoreGetRegionsParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.regions.list() .then(({ regions, count, limit, offset }) => { console.log(regions.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useRegions } from "medusa-react"
const Regions = () => { const { regions, isLoading } = useRegions()
return ( <div> {isLoading && <span>Loading...</span>} {regions?.length && ( <ul> {regions.map((region) => ( <li key={region.id}> {region.name} </li> ))} </ul> )} </div> ) }
export default Regions
lang: Shell label: cURL source: | curl '{backend_url}/store/regions'
tags:
- Regions
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreRegionsListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type Registry ¶
type Registry interface { Session() *session.Store Middleware() *middlewares.Handler Validator() *validator.Validate //Services AnalyticsConfigService() *services.AnalyticsConfigService AuthService() *services.AuthService BatchJobService() *services.BatchJobService CartService() *services.CartService ClaimItemService() *services.ClaimItemService ClaimService() *services.ClaimService CsvParserService() *services.CsvParserService CurrencyService() *services.CurrencyService CustomShippingOptionService() *services.CustomShippingOptionService CustomerGroupService() *services.CustomerGroupService CustomerService() *services.CustomerService DiscountConditionService() *services.DiscountConditionService DiscountService() *services.DiscountService DraftOrderService() *services.DraftOrderService EventBus() *services.Bus DefaultFileService() *services.DefaultFileService FulfillmentProviderService() *services.FulfillmentProviderService FulfillmentService() *services.FulfillmentService GiftCardService() *services.GiftCardService IdempotencyKeyService() *services.IdempotencyKeyService InviteService() *services.InviteService LineItemAdjustmentService() *services.LineItemAdjustmentService LineItemService() *services.LineItemService NewTotalsService() *services.NewTotalsService NoteService() *services.NoteService NotificationService() *services.NotificationService OAuthService() *services.OAuthService OrderItemChangeService() *services.OrderItemChangeService OrderEditService() *services.OrderEditService OrderService() *services.OrderService PaymentCollectionService() *services.PaymentCollectionService PaymentProviderService() *services.PaymentProviderService PaymentService() *services.PaymentService PriceListService() *services.PriceListService PricingService() *services.PricingService ProductCategoryService() *services.ProductCategoryService ProductCollectionService() *services.ProductCollectionService ProductTagService() *services.ProductTagService ProductTaxRateService() *services.ProductTaxRateService ProductTypeService() *services.ProductTypeService ProductVariantInventoryService() *services.ProductVariantInventoryService ProductVariantService() *services.ProductVariantService ProductService() *services.ProductService PublishableApiKeyService() *services.PublishableApiKeyService RegionService() *services.RegionService ReturnReasonService() *services.ReturnReasonService ReturnService() *services.ReturnService SalesChannelInventoryService() *services.SalesChannelInventoryService SalesChannelLocationService() *services.SalesChannelLocationService SalesChannelService() *services.SalesChannelService DefaultSearchService() *services.DefaultSearchService ShippingOptionService() *services.ShippingOptionService ShippingProfileService() *services.ShippingProfileService ShippingTaxRateService() *services.ShippingTaxRateService StagedJobService() *services.StagedJobService StoreService() *services.StoreService StrategyResolverService() *services.StrategyResolverService SwapService() *services.SwapService SystemProviderService() *services.SystemProviderService SystemTaxService() *services.SystemTaxService TaxProviderService() *services.TaxProviderService TaxRateService() *services.TaxRateService TockenService() *services.TockenService TotalsService() *services.TotalsService UserService() *services.UserService //Interfaces PriceSelectionStrategy() interfaces.IPriceSelectionStrategy TaxCalculationStrategy() interfaces.ITaxCalculationStrategy InventoryService() interfaces.IInventoryService StockLocationService() interfaces.IStockLocationService CacheService() interfaces.ICacheService PricingModuleService() interfaces.IPricingModuleService FileService() interfaces.IFileService CartCompletionStrategy() interfaces.ICartCompletionStrategy }
type Return ¶
type Return struct {
// contains filtered or unexported fields
}
func (*Return) Create ¶
@oas:path [post] /store/returns operationId: "PostReturns" summary: "Create Return" description: "Create a Return for an Order. If a return shipping method is specified, the return is automatically fulfilled." externalDocs:
description: "How to create a return in a storefront" url: "https://docs.medusajs.com/modules/orders/storefront/create-return"
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostReturnsReq"
x-codegen:
method: create
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.returns.create({ order_id, items: [ { item_id, quantity: 1 } ] }) .then((data) => { console.log(data.return.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCreateReturn } from "medusa-react"
type CreateReturnData = { items: { item_id: string, quantity: number }[] return_shipping: { option_id: string } }
type Props = { orderId: string }
const CreateReturn = ({ orderId }: Props) => { const createReturn = useCreateReturn() // ...
const handleCreate = (data: CreateReturnData) => { createReturn.mutate({ ...data, order_id: orderId }, { onSuccess: ({ return: returnData }) => { console.log(returnData.id) } }) }
// ... }
export default CreateReturn
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/returns' \ -H 'Content-Type: application/json' \ --data-raw '{ "order_id": "asfasf", "items": [ { "item_id": "assfasf", "quantity": 1 } ] }'
tags:
- Returns
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreReturnsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type ReturnReason ¶
type ReturnReason struct {
// contains filtered or unexported fields
}
func NewReturnReason ¶
func NewReturnReason(r Registry) *ReturnReason
func (*ReturnReason) Get ¶
func (m *ReturnReason) Get(context fiber.Ctx) error
@oas:path [get] /store/return-reasons/{id} operationId: "GetReturnReasonsReason" summary: "Get a Return Reason" description: "Retrieve a Return Reason's details." parameters:
- (path) id=* {string} The id of the Return Reason.
x-codegen:
method: retrieve
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.returnReasons.retrieve(reasonId) .then(({ return_reason }) => { console.log(return_reason.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useReturnReason } from "medusa-react"
type Props = { returnReasonId: string }
const ReturnReason = ({ returnReasonId }: Props) => { const { return_reason, isLoading } = useReturnReason( returnReasonId )
return ( <div> {isLoading && <span>Loading...</span>} {return_reason && <span>{return_reason.label}</span>} </div> ) }
export default ReturnReason
lang: Shell label: cURL source: | curl '{backend_url}/store/return-reasons/{id}'
tags:
- Return Reasons
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreReturnReasonsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*ReturnReason) List ¶
func (m *ReturnReason) List(context fiber.Ctx) error
@oas:path [get] /store/return-reasons operationId: "GetReturnReasons" summary: "List Return Reasons" description: "Retrieve a list of Return Reasons. This is useful when implementing a Create Return flow in the storefront." x-codegen:
method: list
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.returnReasons.list() .then(({ return_reasons }) => { console.log(return_reasons.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useReturnReasons } from "medusa-react"
const ReturnReasons = () => { const { return_reasons, isLoading } = useReturnReasons()
return ( <div> {isLoading && <span>Loading...</span>} {return_reasons?.length && ( <ul> {return_reasons.map((returnReason) => ( <li key={returnReason.id}> {returnReason.label} </li> ))} </ul> )} </div> ) }
export default ReturnReasons
lang: Shell label: cURL source: | curl '{backend_url}/store/return-reasons'
tags:
- Return Reasons
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreReturnReasonsListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*ReturnReason) SetRoutes ¶
func (m *ReturnReason) SetRoutes(router fiber.Router)
type ShippingOption ¶
type ShippingOption struct {
// contains filtered or unexported fields
}
func NewShippingOption ¶
func NewShippingOption(r Registry) *ShippingOption
func (*ShippingOption) List ¶
func (m *ShippingOption) List(context fiber.Ctx) error
@oas:path [get] /store/shipping-options/{cart_id} operationId: GetShippingOptionsCartId summary: List for Cart description: "Retrieve a list of Shipping Options available for a cart." externalDocs:
description: "How to implement shipping step in checkout" url: "https://docs.medusajs.com/modules/carts-and-checkout/storefront/implement-checkout-flow#shipping-step"
parameters:
- (path) cart_id {string} The ID of the Cart.
x-codegen:
method: listCartOptions
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.shippingOptions.listCartOptions(cartId) .then(({ shipping_options }) => { console.log(shipping_options.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useCartShippingOptions } from "medusa-react"
type Props = { cartId: string }
const ShippingOptions = ({ cartId }: Props) => { const { shipping_options, isLoading } = useCartShippingOptions(cartId)
return ( <div> {isLoading && <span>Loading...</span>} {shipping_options && !shipping_options.length && ( <span>No shipping options</span> )} {shipping_options && ( <ul> {shipping_options.map( (shipping_option) => ( <li key={shipping_option.id}> {shipping_option.name} </li> ) )} </ul> )} </div> ) }
export default ShippingOptions
lang: Shell label: cURL source: | curl '{backend_url}/store/shipping-options/{cart_id}'
tags:
- Shipping Options
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreCartShippingOptionsListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*ShippingOption) ListOptions ¶
func (m *ShippingOption) ListOptions(context fiber.Ctx) error
@oas:path [get] /store/shipping-options operationId: GetShippingOptions summary: Get Shipping Options description: "Retrieve a list of Shipping Options." parameters:
- (query) is_return {boolean} Whether return shipping options should be included. By default, all shipping options are returned.
- (query) product_ids {string} "Comma-separated list of Product IDs to filter Shipping Options by. If provided, only shipping options that can be used with the provided products are retrieved."
- (query) region_id {string} "The ID of the region that the shipping options belong to. If not provided, all shipping options are retrieved."
x-codegen:
method: list queryParams: StoreGetShippingOptionsParams
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.shippingOptions.list() .then(({ shipping_options }) => { console.log(shipping_options.length); })
lang: tsx label: Medusa React source: | import React from "react" import { useShippingOptions } from "medusa-react"
const ShippingOptions = () => { const { shipping_options, isLoading, } = useShippingOptions()
return ( <div> {isLoading && <span>Loading...</span>} {shipping_options?.length && shipping_options?.length > 0 && ( <ul> {shipping_options?.map((shipping_option) => ( <li key={shipping_option.id}> {shipping_option.id} </li> ))} </ul> )} </div> ) }
export default ShippingOptions
lang: Shell label: cURL source: | curl '{backend_url}/store/shipping-options'
tags:
- Shipping Options
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreShippingOptionsListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*ShippingOption) SetRoutes ¶
func (m *ShippingOption) SetRoutes(router fiber.Router)
type Swap ¶
type Swap struct {
// contains filtered or unexported fields
}
func (*Swap) Create ¶
@oas:path [post] /store/swaps operationId: PostSwaps summary: Create a Swap description: |
Create a Swap for an Order. This will also create a return and associate it with the swap. If a return shipping option is specified, the return will automatically be fulfilled. To complete the swap, you must use the Complete Cart API Route passing it the ID of the swap's cart. An idempotency key will be generated if none is provided in the header `Idempotency-Key` and added to the response. If an error occurs during swap creation or the request is interrupted for any reason, the swap creation can be retried by passing the idempotency key in the `Idempotency-Key` header.
externalDocs:
description: "How to create a swap" url: "https://docs.medusajs.com/modules/orders/storefront/create-swap"
requestBody:
content: application/json: schema: $ref: "#/components/schemas/StorePostSwapsReq"
x-codegen:
method: create
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.swaps.create({ order_id, return_items: [ { item_id, quantity: 1 } ], additional_items: [ { variant_id, quantity: 1 } ] }) .then(({ swap }) => { console.log(swap.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCreateSwap } from "medusa-react"
type Props = { orderId: string }
type CreateData = { return_items: { item_id: string quantity: number }[] additional_items: { variant_id: string quantity: number }[] return_shipping_option: string }
const CreateSwap = ({ orderId }: Props) => { const createSwap = useCreateSwap() // ...
const handleCreate = ( data: CreateData ) => { createSwap.mutate({ ...data, order_id: orderId }, { onSuccess: ({ swap }) => { console.log(swap.id) } }) }
// ... }
export default CreateSwap
lang: Shell label: cURL source: | curl -X POST '{backend_url}/store/swaps' \ -H 'Content-Type: application/json' \ --data-raw '{ "order_id": "{order_id}", "return_items": [ { "item_id": "{item_id}", "quantity": 1 } ], "additional_items": [ { "variant_id": "{variant_id}", "quantity": 1 } ] }'
tags:
- Swaps
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreSwapsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Swap) GetByCart ¶
@oas:path [get] /store/swaps/{cart_id} operationId: GetSwapsSwapCartId summary: Get by Cart ID description: "Retrieve a Swap's details by the ID of its cart." parameters:
- (path) cart_id {string} The id of the Cart
x-codegen:
method: retrieveByCartId
x-codeSamples:
lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.swaps.retrieveByCartId(cartId) .then(({ swap }) => { console.log(swap.id); })
lang: tsx label: Medusa React source: | import React from "react" import { useCartSwap } from "medusa-react" type Props = { cartId: string }
const Swap = ({ cartId }: Props) => { const { swap, isLoading, } = useCartSwap(cartId)
return ( <div> {isLoading && <span>Loading...</span>} {swap && <span>{swap.id}</span>}
</div> ) }
export default Swap
lang: Shell label: cURL source: | curl '{backend_url}/store/swaps/{cart_id}'
tags:
- Swaps
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreSwapsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
type Variant ¶
type Variant struct {
// contains filtered or unexported fields
}
func NewVariant ¶
func (*Variant) Get ¶
@oas:path [get] /store/variants/{id} operationId: GetVariantsVariant summary: Get a Product Variant description: |
Retrieve a Product Variant's details. For accurate and correct pricing of the product variant based on the customer's context, it's highly recommended to pass fields such as `region_id`, `currency_code`, and `cart_id` when available. Passing `sales_channel_id` ensures retrieving only variants of products available in the current sales channel. You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
externalDocs:
description: "How to pass product pricing parameters" url: "https://docs.medusajs.com/modules/products/storefront/show-products#product-pricing-parameters"
parameters:
- (path) id=* {string} The ID of the Product Variant.
- (query) sales_channel_id {string} The ID of the sales channel the customer is viewing the product variant from.
- (query) cart_id {string} The ID of the cart. This is useful for accurate pricing based on the cart's context.
- (query) region_id {string} The ID of the region. This is useful for accurate pricing based on the selected region.
- in: query name: currency_code style: form explode: false description: A 3 character ISO currency code. This is useful for accurate pricing based on the selected currency. schema: type: string externalDocs: url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes description: See a list of codes.
x-codegen:
method: retrieve queryParams: StoreGetVariantsVariantParams
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.product.variants.retrieve(productVariantId) .then(({ variant }) => { console.log(variant.id); })
- lang: Shell label: cURL source: | curl '{backend_url}/store/variants/{id}'
tags:
- Product Variants
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreVariantsRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"
func (*Variant) List ¶
@oas:path [get] /store/variants operationId: GetVariants summary: Get Product Variants description: |
Retrieves a list of product variants. The product variants can be filtered by fields such as `id` or `title`. The product variants can also be paginated. For accurate and correct pricing of the product variants based on the customer's context, it's highly recommended to pass fields such as `region_id`, `currency_code`, and `cart_id` when available. Passing `sales_channel_id` ensures retrieving only variants of products available in the specified sales channel. You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
externalDocs:
description: "How to pass product pricing parameters" url: "https://docs.medusajs.com/modules/products/storefront/show-products#product-pricing-parameters"
parameters:
- (query) ids {string} Filter by a comma-separated list of IDs. If supplied, it overrides the `id` parameter.
- in: query name: id style: form explode: false description: Filter by one or more IDs. If `ids` is supplied, it's overrides the value of this parameter. schema: oneOf:
- type: string description: Filter by an ID.
- type: array description: Filter by IDs. items: type: string
- (query) sales_channel_id {string} "Filter by sales channel IDs. When provided, only products available in the selected sales channels are retrieved. Alternatively, you can pass a publishable API key in the request header and this will have the same effect."
- (query) expand {string} Comma-separated relations that should be expanded in the returned product variants.
- (query) fields {string} Comma-separated fields that should be included in the returned product variants.
- (query) offset=0 {number} The number of products to skip when retrieving the product variants.
- (query) limit=100 {number} Limit the number of product variants returned.
- (query) cart_id {string} The ID of the cart. This is useful for accurate pricing based on the cart's context.
- (query) region_id {string} The ID of the region. This is useful for accurate pricing based on the selected region.
- in: query name: currency_code style: form explode: false description: A 3 character ISO currency code. This is useful for accurate pricing based on the selected currency. schema: type: string externalDocs: url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes description: See a list of codes.
- in: query name: title style: form explode: false description: Filter by title schema: oneOf:
- type: string description: a single title to filter by
- type: array description: multiple titles to filter by items: type: string
- in: query name: inventory_quantity description: Filter by available inventory quantity schema: oneOf:
- type: number description: A specific number to filter by.
- type: object description: Filter using less and greater than comparisons. properties: lt: type: number description: Filter by inventory quantity less than this number gt: type: number description: Filter by inventory quantity greater than this number lte: type: number description: Filter by inventory quantity less than or equal to this number gte: type: number description: Filter by inventory quantity greater than or equal to this number
x-codegen:
method: list queryParams: StoreGetVariantsParams
x-codeSamples:
- lang: JavaScript label: JS Client source: | import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.product.variants.list() .then(({ variants }) => { console.log(variants.length); })
- lang: Shell label: cURL source: | curl '{backend_url}/store/variants'
tags:
- Product Variants
responses:
200: description: OK content: application/json: schema: $ref: "#/components/schemas/StoreVariantsListRes" "400": description: "Bad Request" content: application/json: schema: $ref: "#/components/responses/400_error" "404": description: "Not Found" content: application/json: schema: $ref: "#/components/responses/not_found_error" "409": description: "Invalid State" content: application/json: schema: $ref: "#/components/responses/invalid_state_error" "422": description: "Invalid Request" content: application/json: schema: $ref: "#/components/responses/invalid_request_error" "500": description: "Internal Server" content: application/json: schema: $ref: "#/components/responses/500_error"