docs: update docs across projects following publishable API key change in store routes (#9098)
* docs: update docs across projects following publishable API key change in store routes * rename env variable * move subscribe route out of store
This commit is contained in:
1 parent
ef8dc4087e
commit
58f06be44d
66 files changed
+577
-298
No files matched your search
@@ -37,6 +37,7 @@ For example:
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
shipping_address: address,
|
||||
@@ -57,8 +58,8 @@ export const highlights = [
|
||||
["4", "useCart", "The `useCart` hook was defined in the Cart React Context documentation."],
|
||||
["29", "address", "Assemble the address object to be used for both shipping and billing addresses."],
|
||||
["41"], ["42"], ["43"], ["44"], ["45"], ["46"], ["47"], ["48"],
|
||||
["49"], ["50"], ["51"], ["52"], ["53"], ["54"], ["55"],
|
||||
["102", "", "The address's country can only be within the cart's region."]
|
||||
["49"], ["50"], ["51"], ["52"], ["53"], ["54"], ["55"], ["56"]
|
||||
["103", "", "The address's country can only be within the cart's region."]
|
||||
]
|
||||
|
||||
```tsx highlights={highlights}
|
||||
@@ -107,6 +108,7 @@ export const highlights = [
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
shipping_address: address,
|
||||
|
||||
@@ -17,6 +17,9 @@ fetch(
|
||||
`http://localhost:9000/store/carts/${cartId}/complete`,
|
||||
{
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
method: "POST",
|
||||
}
|
||||
)
|
||||
@@ -53,10 +56,10 @@ export const highlights = [
|
||||
["10", "handlePayment", "This function sends the request\nto the Medusa application to complete the cart."],
|
||||
["21", "TODO", "If you're integrating a third-party payment provider,\nyou perform the custom logic before completing the cart."],
|
||||
["24", "fetch", "Send a request to the Medusa application\nto complete the cart and place the order."],
|
||||
["33", `type === "cart"`, "If the `type` returned is `cart`,\nit means an error occurred and the cart wasn't completed."],
|
||||
["36", `type === "order"`, "If the `type` returned is `order`,\nit means the cart was completed and the order was placed successfully."],
|
||||
["40", "refreshCart", "Unset and reset the cart."],
|
||||
["47", "button", "This button triggers the `handlePayment` function when clicked."]
|
||||
["36", `type === "cart"`, "If the `type` returned is `cart`,\nit means an error occurred and the cart wasn't completed."],
|
||||
["39", `type === "order"`, "If the `type` returned is `order`,\nit means the cart was completed and the order was placed successfully."],
|
||||
["43", "refreshCart", "Unset and reset the cart."],
|
||||
["50", "button", "This button triggers the `handlePayment` function when clicked."]
|
||||
]
|
||||
|
||||
```tsx highlights={highlights}
|
||||
@@ -87,6 +90,9 @@ export default function SystemDefaultPayment() {
|
||||
`http://localhost:9000/store/carts/${cart.id}/complete`,
|
||||
{
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
method: "POST",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -27,6 +27,7 @@ For example:
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
@@ -46,7 +47,7 @@ export const highlights = [
|
||||
["4", "useCart", "The `useCart` hook was defined in the Cart React Context documentation."],
|
||||
["13", "TODO", "Cart must have at least one item. If not, redirect to another page."],
|
||||
["27"], ["28"], ["29"], ["30"], ["31"], ["32"], ["33"], ["34"],
|
||||
["35"], ["36"], ["37"], ["38"], ["39"], ["40"]
|
||||
["35"], ["36"], ["37"], ["38"], ["39"], ["40"], ["41"]
|
||||
]
|
||||
|
||||
```tsx highlights={highlights}
|
||||
@@ -81,6 +82,7 @@ export const highlights = [
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
|
||||
@@ -34,17 +34,17 @@ For example, to implement the payment step flow:
|
||||
export const fetchHighlights = [
|
||||
["6", "retrievePaymentProviders", "This function retrieves the payment provider that the customer can choose from."],
|
||||
["7", "fetch", "Retrieve available payment providers."],
|
||||
["18", "selectPaymentProvider", "This function is executed when the customer submits their chosen payment provider."],
|
||||
["25", "fetch", "Create a payment collection for the cart when it doesn't have one."],
|
||||
["44", "fetch", "Initialize the payment session in the payment collection for the chosen provider."],
|
||||
["62", "fetch", "Retrieve the cart again to update its data."],
|
||||
["73", "getPaymentUi", "This function shows the necessary UI based on the selected payment provider."],
|
||||
["74", "activePaymentSession", "The active session is the first in the payment collection's sessions."],
|
||||
["80", "", "Test which payment provider is chosen based on the prefix of the provider ID."],
|
||||
["81", `"pp_stripe_"`, "Check if the chosen provider is Stripe."],
|
||||
["85", `"pp_system_default"`, "Check if the chosen provider is the default systen provider."],
|
||||
["87", "default", "Handle unrecognized providers."],
|
||||
["94", "handlePayment", "The function that handles the payment process using the above functions."]
|
||||
["21", "selectPaymentProvider", "This function is executed when the customer submits their chosen payment provider."],
|
||||
["28", "fetch", "Create a payment collection for the cart when it doesn't have one."],
|
||||
["48", "fetch", "Initialize the payment session in the payment collection for the chosen provider."],
|
||||
["67", "fetch", "Retrieve the cart again to update its data."],
|
||||
["81", "getPaymentUi", "This function shows the necessary UI based on the selected payment provider."],
|
||||
["82", "activePaymentSession", "The active session is the first in the payment collection's sessions."],
|
||||
["88", "", "Test which payment provider is chosen based on the prefix of the provider ID."],
|
||||
["89", `"pp_stripe_"`, "Check if the chosen provider is Stripe."],
|
||||
["93", `"pp_system_default"`, "Check if the chosen provider is the default systen provider."],
|
||||
["95", "default", "Handle unrecognized providers."],
|
||||
["102", "handlePayment", "The function that handles the payment process using the above functions."]
|
||||
]
|
||||
|
||||
```ts highlights={fetchHighlights}
|
||||
@@ -59,6 +59,9 @@ const retrievePaymentProviders = async () => {
|
||||
cart.region_id
|
||||
}`, {
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
|
||||
@@ -79,6 +82,7 @@ const selectPaymentProvider = async (
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
cart_id: cart.id,
|
||||
@@ -99,6 +103,7 @@ const selectPaymentProvider = async (
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
provider_id: selectedPaymentProviderId,
|
||||
@@ -113,6 +118,9 @@ const selectPaymentProvider = async (
|
||||
`http://localhost:9000/store/carts/${cart.id}`,
|
||||
{
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => res.json())
|
||||
@@ -159,18 +167,18 @@ const handlePayment = () => {
|
||||
export const highlights = [
|
||||
["4", "useCart", "The `useCart` hook was defined in the Cart React Context documentation."],
|
||||
["23", "fetch", "Retrieve available payment providers."],
|
||||
["31", "setSelectedPaymentProvider", "If a payment provider was selected before, pre-fill it."],
|
||||
["37", "handleSelectProvider", "This function is executed when the customer submits their chosen payment provider."],
|
||||
["50", "fetch", "Create a payment collection for the cart when it doesn't have one."],
|
||||
["72", "fetch", "Initialize the payment session in the payment collection for the chosen provider."],
|
||||
["90", "fetch", "Retrieve the cart again to update its data."],
|
||||
["103", "getPaymentUi", "This function shows the necessary UI based on the selected payment provider."],
|
||||
["104", "activePaymentSession", "The active session is the first in the payment collection's sessions."],
|
||||
["110", "", "Test which payment provider is chosen based on the prefix of the provider ID."],
|
||||
["111", `"pp_stripe_"`, "Check if the chosen provider is Stripe."],
|
||||
["119", `"pp_system_default"`, "Check if the chosen provider is the default systen provider."],
|
||||
["125", "default", "Handle unrecognized providers."],
|
||||
["160", "getPaymentUi", "If a provider is chosen, render its UI."]
|
||||
["34", "setSelectedPaymentProvider", "If a payment provider was selected before, pre-fill it."],
|
||||
["40", "handleSelectProvider", "This function is executed when the customer submits their chosen payment provider."],
|
||||
["53", "fetch", "Create a payment collection for the cart when it doesn't have one."],
|
||||
["76", "fetch", "Initialize the payment session in the payment collection for the chosen provider."],
|
||||
["95", "fetch", "Retrieve the cart again to update its data."],
|
||||
["111", "getPaymentUi", "This function shows the necessary UI based on the selected payment provider."],
|
||||
["112", "activePaymentSession", "The active session is the first in the payment collection's sessions."],
|
||||
["118", "", "Test which payment provider is chosen based on the prefix of the provider ID."],
|
||||
["119", `"pp_stripe_"`, "Check if the chosen provider is Stripe."],
|
||||
["127", `"pp_system_default"`, "Check if the chosen provider is the default systen provider."],
|
||||
["133", "default", "Handle unrecognized providers."],
|
||||
["168", "getPaymentUi", "If a provider is chosen, render its UI."]
|
||||
]
|
||||
|
||||
```tsx highlights={highlights}
|
||||
@@ -200,6 +208,9 @@ export default function CheckoutPaymentStep() {
|
||||
cart.region_id
|
||||
}`, {
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then(({ payment_providers }) => {
|
||||
@@ -231,6 +242,7 @@ export default function CheckoutPaymentStep() {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
cart_id: cart.id,
|
||||
@@ -251,6 +263,7 @@ export default function CheckoutPaymentStep() {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
provider_id: selectedPaymentProvider,
|
||||
@@ -265,6 +278,9 @@ export default function CheckoutPaymentStep() {
|
||||
`http://localhost:9000/store/carts/${cart.id}`,
|
||||
{
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => res.json())
|
||||
|
||||
@@ -66,10 +66,10 @@ export const highlights = [
|
||||
["61", "confirmCardPayment", "This function shows the UI to the customer to accept the card payment."],
|
||||
["78", "", "Once the customer enters their card details and submits the form,\nthe Promise resolves and executes this function."],
|
||||
["85", "fetch", "Send a request to the Medusa application\nto complete the cart and place the order."],
|
||||
["94", `type === "cart"`, "If the `type` returned is `cart`,\nit means an error occurred and the cart wasn't completed."],
|
||||
["97", `type === "order"`, "If the `type` returned is `order`,\nit means the cart was completed and the order was placed successfully."],
|
||||
["101", "refreshCart", "Unset and reset the cart."],
|
||||
["111", "button", "This button triggers the `handlePayment` function when clicked."]
|
||||
["97", `type === "cart"`, "If the `type` returned is `cart`,\nit means an error occurred and the cart wasn't completed."],
|
||||
["100", `type === "order"`, "If the `type` returned is `order`,\nit means the cart was completed and the order was placed successfully."],
|
||||
["104", "refreshCart", "Unset and reset the cart."],
|
||||
["114", "button", "This button triggers the `handlePayment` function when clicked."]
|
||||
]
|
||||
|
||||
```tsx highlights={highlights}
|
||||
@@ -161,6 +161,9 @@ const StripeForm = ({
|
||||
`http://localhost:9000/store/carts/${cart.id}/complete`,
|
||||
{
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
method: "POST",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -20,8 +20,8 @@ For example:
|
||||
|
||||
export const fetchHighlights = [
|
||||
["3", "retrieveShippingOptions", "This function retrieves the shipping options of the customer's cart."],
|
||||
["16", "setShippingMethod", "This function sets the shipping method of the cart using the selected shipping option."],
|
||||
["29", "data", "Pass in this property any data relevant to the fulfillment provider."],
|
||||
["19", "setShippingMethod", "This function sets the shipping method of the cart using the selected shipping option."],
|
||||
["33", "data", "Pass in this property any data relevant to the fulfillment provider."],
|
||||
]
|
||||
|
||||
```ts highlights={fetchHighlights}
|
||||
@@ -33,6 +33,9 @@ export const fetchHighlights = [
|
||||
cart.id
|
||||
}`, {
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => res.json())
|
||||
@@ -50,6 +53,7 @@ export const fetchHighlights = [
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
option_id: selectedShippingOptionId,
|
||||
@@ -73,8 +77,8 @@ export const fetchHighlights = [
|
||||
export const highlights = [
|
||||
["4", "useCart", "The `useCart` hook was defined in the Cart React Context documentation."],
|
||||
["22", "fetch", "Retrieve available shipping method of the customer's cart."],
|
||||
["43", "fetch", "Set the cart's shipping method using the selected shipping option."],
|
||||
["53", "data", "Pass in this property any data relevant to the fulfillment provider."]
|
||||
["46", "fetch", "Set the cart's shipping method using the selected shipping option."],
|
||||
["57", "data", "Pass in this property any data relevant to the fulfillment provider."]
|
||||
]
|
||||
|
||||
```tsx highlights={highlights}
|
||||
@@ -103,6 +107,9 @@ export const highlights = [
|
||||
cart.id
|
||||
}`, {
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then(({ shipping_options }) => {
|
||||
@@ -127,6 +134,7 @@ export const highlights = [
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
option_id: selectedShippingOption,
|
||||
|
||||
Reference in new issue
Block a user