docs: update recipe contents (#12515)
This commit is contained in:
@@ -14,6 +14,10 @@ Subscription-based purchase allows customers to purchase products for a specifie
|
||||
|
||||
For example, a customer can purchase a book subscription box for a period of three months. Each month, the payment is captured for that order and, if the payment is successful, the fulfillment is processed.
|
||||
|
||||
Medusa's [Framework](!docs!/learn/fundamentals/framework) for customizations facilitates building subscription-based purchases. You can create a Subscription Module that implements data models for subscriptions, and link those data models to existing ones such as products and orders.
|
||||
|
||||
You can also expose custom features using API routes, and implement complex flows using workflows.
|
||||
|
||||
<Note title="Related use-case">
|
||||
|
||||
[How Goodchef built subscription-based purchases with Medusa](https://medusajs.com/blog/goodchef/).
|
||||
@@ -26,7 +30,7 @@ For example, a customer can purchase a book subscription box for a period of thr
|
||||
|
||||
Subscriptions have details related to the subscription interval, subscription period, and more.
|
||||
|
||||
To store the subscription details, create a data model in a new subscription module. The module's main service provides data management feature of the data model.
|
||||
To store the subscription details, you can create a data model in a new subscription module. The module's main service provides data management feature of the data model.
|
||||
|
||||
You can link the subscription data model to models of other modules, such as the Order Module's `Order` data model.
|
||||
|
||||
@@ -47,7 +51,7 @@ You can link the subscription data model to models of other modules, such as the
|
||||
|
||||
---
|
||||
|
||||
## Define Module Links
|
||||
## Link Subscription to Existing Data Models
|
||||
|
||||
Define a module link that links a data model from your subscription module with a data model from another module.
|
||||
|
||||
@@ -74,32 +78,41 @@ By implementing the subscription logic within your application, you have full co
|
||||
|
||||
Implementing the logic depends on your use case, but you'll mainly implement the following:
|
||||
|
||||
1. Create an API route in place of the [Complete Cart Store API Route](!api!/store#carts_postcartsidcomplete) that creates a subscription for the order.
|
||||
1. Create a workflow that completes a cart and creates a subscription for the order.
|
||||
1. Create an API route that executes the workflow.
|
||||
2. Create a scheduled job that checks daily for subscriptions that need renewal.
|
||||
3. Create another scheduled job that checks daily for subscriptions that are expired.
|
||||
|
||||
<CardList itemsPerRow={2} items={[
|
||||
{
|
||||
href: "!docs!/learn/fundamentals/workflows",
|
||||
title: "Create a Workflow",
|
||||
text: "Learn how to create a workflow.",
|
||||
icon: AcademicCapSolid,
|
||||
},
|
||||
{
|
||||
href: "!docs!/learn/fundamentals/api-routes",
|
||||
title: "Create an API Route",
|
||||
text: "Learn how to create an API route.",
|
||||
icon: AcademicCapSolid,
|
||||
},
|
||||
{
|
||||
href: "!docs!/learn/fundamentals/scheduled-jobs",
|
||||
title: "Create a Scheduled Job",
|
||||
text: "Learn how to create a scheduled job.",
|
||||
icon: AcademicCapSolid,
|
||||
}
|
||||
]} />
|
||||
|
||||
<Card
|
||||
href="!docs!/learn/fundamentals/scheduled-jobs#1-create-a-scheduled-job"
|
||||
title="Create a Scheduled Job"
|
||||
text="Learn how to create a scheduled job."
|
||||
icon={AcademicCapSolid}
|
||||
className="mt-1"
|
||||
/>
|
||||
|
||||
### Option 2: Using Stripe Subscriptions
|
||||
|
||||
Stripe provides a [subscription payments feature](https://stripe.com/docs/billing/subscriptions/overview) that allows you to authorize payment on a subscription basis within Stripe. Stripe then handles checking for recurring payments and capturing payment at the specified interval.
|
||||
|
||||
This approach allows you to delegate the complications of implementing the subscription logic to Stripe, but doesn't support using other payment providers.
|
||||
|
||||
Although Medusa provides a Stripe module provider, it doesn't handle subscriptions. You can create a custom Stripe Subscription module provider.
|
||||
Although Medusa provides a [Stripe Payment Module Provider](../../commerce-modules/payment/payment-provider/stripe/page.mdx), it doesn't handle subscriptions. You can create a custom Stripe Subscription Module Provider instead.
|
||||
|
||||
<Card
|
||||
href="/references/payment/provider"
|
||||
@@ -110,44 +123,60 @@ Although Medusa provides a Stripe module provider, it doesn't handle subscriptio
|
||||
|
||||
---
|
||||
|
||||
## Customize Admin
|
||||
## Customize Admin Dashboard
|
||||
|
||||
You can extend the admin to provide an interface to manage your custom features, such as view the subscriptions.
|
||||
Based on your use case, you may need to customize the Medusa Admin to add new widgets or pages.
|
||||
|
||||
Extend the Medusa Admin to add widgets to existing pages or add new pages.
|
||||
For example, you can create a page that lists all subscriptions or a widget that shows an order's subscription information.
|
||||
|
||||
The Medusa Admin is an extensible application within your Medusa application. You can customize it by:
|
||||
|
||||
- **Widgets**: Adding widgets to existing pages, such as the order page.
|
||||
- **UI Routes**: Adding new pages to the Medusa Admin, such as a page to manage subscriptions.
|
||||
- **Settings Pages**: Adding new pages to the Medusa Admin settings, such as a page to manage subscription settings.
|
||||
|
||||
<CardList items={[
|
||||
{
|
||||
href: "!docs!/learn/fundamentals/admin/widgets",
|
||||
title: "Create Admin Widget",
|
||||
text: "Learn how to add widgets into existing admin pages.",
|
||||
text: "Add widgets into existing admin pages.",
|
||||
icon: AcademicCapSolid,
|
||||
},
|
||||
{
|
||||
href: "!docs!/learn/fundamentals/admin/ui-routes",
|
||||
title: "Create Admin UI Routes",
|
||||
text: "Learn how to add new pages to your Medusa Admin.",
|
||||
text: "Add new pages to your Medusa Admin.",
|
||||
icon: AcademicCapSolid,
|
||||
}
|
||||
},
|
||||
]} />
|
||||
|
||||
<Card
|
||||
href="!docs!/learn/fundamentals/admin/ui-routes#create-settings-page"
|
||||
title="Create Admin Setting Page"
|
||||
text="Add new page to the Medusa Admin settings."
|
||||
icon={AcademicCapSolid}
|
||||
className="mt-1"
|
||||
/>
|
||||
|
||||
---
|
||||
|
||||
## Build a Storefront
|
||||
## Customize or Build Storefront
|
||||
|
||||
Medusa provides a Next.js Starter. Since you've customized your Medusa project, you must either customize the existing Next.js Starter, or create a custom storefront.
|
||||
Medusa provides a Next.js Starter Storefront to use with your application. You can customize it to for your subscription use case, such as allowing customers to manage their subscriptions.
|
||||
|
||||
Alternatively, you can build your own storefront using the Medusa APIs. This headless approach gives you the flexibility to build a custom storefront without limitations on which tech stack you use, or the design of the storefront.
|
||||
|
||||
<CardList items={[
|
||||
{
|
||||
href: "/nextjs-starter",
|
||||
title: "Option 1: Use Next.js Starter",
|
||||
text: "Install the Next.js Starter to customize it.",
|
||||
title: "Next.js Starter Storefront",
|
||||
text: "Learn how to install and customize the Next.js Starter Storefront.",
|
||||
icon: AcademicCapSolid,
|
||||
},
|
||||
{
|
||||
href: "/storefront-development",
|
||||
title: "Option 2: Build Custom Storefront",
|
||||
text: "Find guides for your storefront development.",
|
||||
title: "Storefront Development",
|
||||
text: "Find guides to build your own storefront.",
|
||||
icon: AcademicCapSolid,
|
||||
}
|
||||
]} />
|
||||
},
|
||||
]} />
|
||||
Reference in New Issue
Block a user