diff --git a/docs/articles/monetization-dev-portal-setup.md b/docs/articles/monetization-dev-portal-setup.md index 935db6b9..ab3f975e 100644 --- a/docs/articles/monetization-dev-portal-setup.md +++ b/docs/articles/monetization-dev-portal-setup.md @@ -9,7 +9,7 @@ API plans. If you don't already have a Zuplo API, you can create a new project using the "ToDo" sample or following step 1 of the -[Getting Started quickstart](./step-1-setup-basic-gateway.md). +[Getting Started guide](./step-1-setup-basic-gateway.md). You'll also need a Stripe account. If you don't already have one, you'll need to [register](https://dashboard.stripe.com/register) for one. @@ -102,7 +102,7 @@ Now that your Developer Portal is configured for monetization you can open it and view the pricing page. Click the toolbar on the bottom of the Zuplo Portal to find the URL of your Developer Portal. -![Dev Portal Link](../../public/media/monetization-dev-portal-setup/image-3a.png) +![Developer Portal Link](../../public/media/monetization-dev-portal-setup/image-3a.png) Once you open your Developer Portal, you will find a link to the **Pricing** page on the top right menu section. Open the **Pricing** page in your Developer diff --git a/docs/articles/monetization-policy-setup.md b/docs/articles/monetization-policy-setup.md index e110ee7a..a9ba7bf4 100644 --- a/docs/articles/monetization-policy-setup.md +++ b/docs/articles/monetization-policy-setup.md @@ -12,9 +12,6 @@ We will configure this using Zuplo's [API Key Authentication Policy](/docs/policies/api-key-inbound) and the [Monetization Inbound Policy](/docs/policies/monetization-inbound). -The Monetization Inbound Policy is what ensures that customers are only able to -call your API withing the quotas set in their Plan. - ## 1/ Add API Key Authentication In order to identify customers calling your API, you'll add the @@ -46,7 +43,9 @@ endpoint. ## 2/ Add the Monetization Policy With the user identified via the API Key Authentication policy, next you will -enforce that they are calling the API within the limits of their plan. +enforce that they are calling the API within the limits of their plan. The +[Monetization Inbound Policy](/docs/policies/monetization-inbound) is what +enables us to do that. 1. Open the **Policies** section of the same route and click **Add Policy**. @@ -84,9 +83,11 @@ header. ![Successful response](../../public/media/monetization-policy-setup/image-1.png) -5. Close the API Playground and click the **Subscription** link in the Dev - Portal header. Notice the Analytics section now shows that you have consumed - some of your request quota from your plan. +5. Close the API Playground and click the **Subscription** link in the Developer + Portal header. Notice the Usage section shows that you have consumed some of + your request quota from your plan. + +![Max quota status](../../public/media/monetization-policy-setup/image-2.png) 6. Return to the API Playground and click **Test** until you receive an error response telling you that you have exhausted your quota. @@ -98,6 +99,4 @@ earlier steps, this is going to take a while. ::: -![Max quota status](../../public/media/monetization-policy-setup/image-2.png) - Congratulations, you are now ready to monetize your API! diff --git a/docs/articles/monetization-programmatic-quotas.md b/docs/articles/monetization-programmatic-quotas.md index dcecf239..9a2cc373 100644 --- a/docs/articles/monetization-programmatic-quotas.md +++ b/docs/articles/monetization-programmatic-quotas.md @@ -3,10 +3,10 @@ title: Monetization Programmatic Quotas sidebar_label: Programmatic Quotas --- -Typically, when adding monetization to your API, you set the number of meters a -request will consume in the settings of the +When adding monetization to your API, you would usually set the number of meters +a request will consume in the settings of the [Monetization Policy](https://zuplo.com/docs/policies/monetization-inbound). For -example, the policy below specifies that the request will consume 1 `requests` +example, the policy below specifies that each request will consume 1 `requests` meter and 5 `computeUnits` meters. ```json @@ -67,23 +67,23 @@ export default async function ( request: ZuploRequest, context: ZuploContext, options: any, - policyName: string, + policyName: string ) { const headerValue = response.headers.get("compute-units"); - let computeUnits; + let computeUnitsValue; if (headerValue && typeof headerValue === "string") { - computeUnits = parseInt(headerValue); + computeUnitsValue = parseInt(headerValue); } // Throw an error if the server doesn't send compute units // Alternatively, you could have a default value - if (!computeUnits) { + if (!computeUnitsValue) { throw new Error("Invalid response, no compute units sent."); } // Set the compute units for the request MonetizationInboundPolicy.setMeters(context, { - computeUnits, + computeUnits: computeUnitsValue, }); return response; diff --git a/docs/articles/monetization-webhook-setup.md b/docs/articles/monetization-webhook-setup.md index fb01ea83..38a8a20c 100644 --- a/docs/articles/monetization-webhook-setup.md +++ b/docs/articles/monetization-webhook-setup.md @@ -46,9 +46,10 @@ During the test phase, set the value of the **Max Value** to a low number like ## 2/ Set Up the Zuplo Plugin -The Zuplo `StripeMonetizationPlugin` enables your Zuplo API to listen to Stripe -Webhook subscription events. This plugin adds an endpoint that is used when -configuring the Stripe Webhook. +The Zuplo +[`StripeMonetizationPlugin`](/docs/articles/stripe-monetization-plugin.md) +enables your Zuplo API to listen to Stripe Webhook subscription events. This +plugin adds an endpoint that is used when configuring the Stripe Webhook. 1. To start, navigate to the **Code** section of your Zuplo project. On the `modules` folder click the **+** button and select **Runtime Extension**. diff --git a/docs/articles/stripe-monetization-plugin.md b/docs/articles/stripe-monetization-plugin.md index 7b1c087e..e5db9a72 100644 --- a/docs/articles/stripe-monetization-plugin.md +++ b/docs/articles/stripe-monetization-plugin.md @@ -1,21 +1,21 @@ --- title: Stripe Monetization Plugin -sidebar_label: Stripe Plugin +sidebar_label: Stripe Monetization Plugin --- -The Stripe Monetization Plugin makes makes it easy to register a Stripe Webhook -in your Zuplo API that will handle Stripe subscription events. - -When you register the Stripe Plugin a new route is configured on your API at the -path `/__plugins/stripe/webhook`. This route is used to receive webhooks sent by -stripe for Stripe subscription events. +The Stripe Monetization Plugin makes it easy to register a Stripe Webhook in +your Zuplo API that will handle Stripe subscription events. The Plugin is registered in the `zuplo.runtime.ts` extension. It requires setting the `webhooks.signingSecret` value and the `stripeSecretKey` in order to function. -There is additional configuration if you wan to customize the path, etc, but for -most cases no additional configuration is required. +When you register the Stripe Monetization Plugin, a new route is configured on +your API at the path `/__plugins/stripe/webhook`. This route is used to receive +webhooks sent by Stripe for subscription events. + +There is additional configuration if you want to customize the path, etc. In +most cases, no additional configuration is required. ```ts import { @@ -39,9 +39,9 @@ export function runtimeInit(runtime: RuntimeExtensions) { ## Debugging & Troubleshooting -The Runtime Plugin emits logs that show what the Webhook is doing. For example, -when a new subscription is created, the plugin will log information about the -Stripe subscription, user, etc. +The Plugin emits logs that show what the Webhook is doing. For example, when a +new subscription is created, the plugin will log information about the Stripe +subscription, user, etc. If are having trouble with the Webhooks, reviewing the logs for the Plugin is the place to start.