import Medusa from "@medusajs/js-sdk"
let MEDUSA_BACKEND_URL = "http://localhost:9000"
if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
}
export const sdk = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
debug: process.env.NODE_ENV === "development",
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})
// TODO must be authenticated as the customer to request the order transfer
sdk.store.order.requestTransfer(
"order_123",
{
description: "I want to transfer this order to my friend."
},
{},
{
Authorization: `Bearer ${token}`
}
)
.then(({ order }) => {
console.log(order)
})Request an order to be transfered to the logged-in customer’s account. The transfer is confirmed using the Accept Order Transfer API route.
import Medusa from "@medusajs/js-sdk"
let MEDUSA_BACKEND_URL = "http://localhost:9000"
if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
}
export const sdk = new Medusa({
baseUrl: MEDUSA_BACKEND_URL,
debug: process.env.NODE_ENV === "development",
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})
// TODO must be authenticated as the customer to request the order transfer
sdk.store.order.requestTransfer(
"order_123",
{
description: "I want to transfer this order to my friend."
},
{},
{
Authorization: `Bearer ${token}`
}
)
.then(({ order }) => {
console.log(order)
})Publishable API Key created in the Medusa Admin.
The locale in BCP 47 format to retrieve localized content.
"en-US"
The order's ID.
Comma-separated fields that should be included in the returned data.
if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields.
without prefix it will replace the entire default fields.
Comma-separated fields that should be included in the returned data. If a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. Without prefix it will replace the entire default fields.
The locale in BCP 47 format to retrieve localized content.
"en-US"
The details of requesting the order transfer.
The transfer's description, which can be shown to the other customer receiving the request.
OK
The order's details.
The order's details.
Show child attributes