# Stripe Payment Integration Setup

> Accept credit cards, Apple Pay, and Google Pay on your Discord or Telegram subscription bot with Stripe

Source: https://docs.botsubscription.com/payments/stripe/

Stripe is the recommended payment provider for BotSubscription. It allows your subscription bot to accept credit cards, Apple Pay, Google Pay, and various regional payment methods in over 195 countries.

## Why Stripe?

- Global coverage - Accept payments from almost anywhere in the world
- Seamless Checkout - Supports Apple Pay, Google Pay, and Link for one-click payments
- Automatic Subscription Management - Handles recurring billing and failed payment retries
- Fraud Protection - Built-in fraud detection to protect your business
- Trusted Reliability - The industry standard for online payments

## Prerequisites

Before connecting Stripe to your subscription bot, you'll need:

1. A Stripe account ([Sign up here](https://dashboard.stripe.com/register))
2. A **Restricted Key** (recommended) or Secret Key

### Creating a Restricted Key (Recommended)

While BotSubscription works with your account's master Secret Key, we strongly recommend creating a Restricted Key to limit the bot's access to only what it needs.

1. Log in to your [Stripe Dashboard](https://dashboard.stripe.com).
2. Go to Developers > API keys.
3. Click "Create restricted key".
4. Name it `BotSubscription`.
5. Under Permissions, set the following access levels. Most of these are part of the critical infrastructure required for the bot to operate:

| Category | Permission | Access Level | Status | Reason |
|----------|------------|--------------|--------|--------|
| Core | Charges | Read | Required | To confirm successful payments |
| | Customers | Write | Required | To create and manage subscriber profiles |
| | Disputes | Read | Optional | To detect and handle chargebacks |
| | Payment Intents | Write | Required | To process payments and recurring charges |
| | Payment Methods | Write | Required | To save cards for future renewals |
| | Products | Write | Required | To sync your subscription plans |
| | Prices | Write | Required | To manage pricing tiers |
| | Refunds | Write | Optional | To issue refunds from the bot |
| | Setup Intents | Write | Required | To setup payment methods without immediate charge |
| Billing | Invoices | Write | Required | To generate billing records |
| | Subscriptions | Write | Required | To manage recurring subscriptions |
| Checkout | Checkout Sessions | Write | Required | To create payment pages |
| Webhooks | Webhook Endpoints | Write | Required | To automatically configure payment notifications |

6. Scroll down and click "Create key".
7. Copy the key (it starts with `rk_...`). You won't be able to see it again.

<Warning>
Missing required permissions will break your bot. Ensure every permission marked as Required is set correctly.
</Warning>

## Connecting Stripe

Open the bot settings using the `/settings` command and navigate to Merchant Accounts.

### Step 1: Install Merchant Account

Click "Install Merchant Account" to add a new payment provider.

<Frame caption="Access Merchant Accounts from the bot settings menu to add Stripe">
  <img
    src="/img/payments/merchant-accounts-settings.webp"
    alt="BotSubscription merchant accounts settings showing Install Merchant Account button"
  />
</Frame>

### Step 2: Select Stripe

Choose Stripe from the list of available payment providers.

<Frame caption="Select Stripe to enable credit card payments">
  <img
    src="/img/payments/select-payment-provider.webp"
    alt="Payment provider selection screen showing Stripe option"
  />
</Frame>

### Step 3: Review Requirements

The bot displays the credential needed:

- Secret Key (or Restricted Key `rk_...`)

The current environment (Sandbox/Test or Production/Live) is shown. Click Configure to proceed.

<Frame caption="Review the required Stripe credentials before setup">
  <img
    src="/img/payments/stripe-requirements.webp"
    alt="Stripe configuration preview displaying required Secret Key field"
  />
</Frame>

### Step 4: Enter Your Credentials

A secure form appears where you enter your Stripe key:

1. Paste your Restricted Key (or Secret Key)

<Frame caption="Enter your Stripe API key securely">
  <img
    src="/img/payments/stripe-credentials-form.webp"
    alt="Secure form for entering Stripe Secret Key"
  />
</Frame>

Click Submit to complete the setup.

### Step 5: Confirmation

After validation, BotSubscription creates the required Stripe webhooks automatically and confirms the integration is ready.

<Frame caption="Stripe successfully connected">
  <img
    src="/img/payments/stripe-success.webp"
    alt="Success confirmation showing Stripe connected to BotSubscription"
  />
</Frame>

## Environment Modes

### Test Mode (Sandbox)

Use Test Mode to verify your setup without charging real money.

- Status: Enabled when the bot is in Test Mode.
- Cards: Use [Stripe Test Cards](https://stripe.com/docs/testing#cards) (e.g., `4242 4242 4242 4242`).

<Tip>
We recommend running a full test cycle (subscribe -> payment -> role assignment) in Test Mode before going live.
</Tip>

### Live Mode (Production)

Switch to Live Mode to accept real payments.

- Status: Enabled when the bot is in Live Mode.
- Requirement: You must have a verified business on Stripe.

## Troubleshooting

### "Invalid API Key" Error
- Ensure you copied the key correctly without extra spaces.
- If using a Restricted Key, double-check that all required permissions are set to Write (or Read where specified). Missing permissions are the most common cause of errors.

### "Webhook Creation Failed"
- This usually means your API key lacks the `Webhook Endpoints` > `Write` permission.
- Update the key permissions in Stripe Dashboard or create a new one with the correct access.

### Payments Not Confirming
- Check if your Stripe account has any verification holds.
- Ensure the webhook was created successfully (check Developers > Webhooks in Stripe).
