Stripe
We use Stripe to handle payments and subscriptions. This guide will walk you through the process of setting up Stripe for local development.
Prerequisites
- Stripe Account: If you don't have one already, create a free Stripe account at https://dashboard.stripe.com/register.
- Memogic Stripe Organization Access: Contact the Memogic team to be added to the organization's Stripe account. This grants you the necessary permissions.
- Stripe CLI: Install the Stripe CLI tool following the instructions on https://docs.stripe.com/stripe-cli. The Stripe CLI lets you interact with Stripe directly from your terminal.
Local Webhook Forwarding
After installing the CLI, log in to your Stripe account using the following command:
stripe login
Start the webhook forwarding by running the following command:
stripe listen --forward-to localhost:5000/stripe/webhook
This redirects webhooks from Stripe's testing environment to your local machine on port 5000, specifically the /stripe/webhook route.
info
Ensure that port 5000 is correct for your local API. If it’s not, adjust the port in the command as needed.
Manually triggering Events
The stripe-CLI allows to manually trigger events. This can be useful for testing.
This command creates a payment_intent.canceled-Event and adds a customer to it (because that's how it is in production):
stripe trigger payment_intent.canceled --add payment_intent:customer=cus_RDW8V59IHgcody