Skip to main content
Before processing real payments, thoroughly test your integration using Stripe’s test mode. This guide covers the complete testing workflow from local development to production readiness.

Test Mode vs Live Mode

AspectTest ModeLive Mode
API Keyspk_test_*, sk_test_*pk_live_*, sk_live_*
Card NumbersStripe test cardsReal credit cards
ChargesNo real moneyReal transactions
Webhook URL.../webhooks/{id}/test.../webhooks/{id}/live

Development Testing Workflow

Step 1: Configure Test Mode

In Cloud Admin, navigate to Payments > Settings and enter your test credentials:
1

Get Test Keys from Stripe

Go to Stripe Dashboard > Developers > API keysCopy:
  • Publishable key: pk_test_...
  • Secret key: sk_test_...
2

Enter Keys in Cloud Admin

Paste both keys in the Test Mode section and click Validate.
3

Copy Webhook URL

Copy the test webhook URL displayed on the settings page.

Step 2: Set Up Local Webhook Testing

Use Stripe CLI to forward webhooks to your local development environment:
# Install Stripe CLI
brew install stripe/stripe-cli/stripe

# Login to Stripe
stripe login

# Forward webhooks to Cloud API
stripe listen --forward-to https://api.devkit4ai.com/api/v1/payments/stripe/webhooks/{your-project-id}/test
Replace {your-project-id} with your actual project UUID from Cloud Admin.
The CLI will display a webhook signing secret:
Ready! Your webhook signing secret is whsec_...
Add this secret to your Cloud Admin webhook configuration.

Step 3: Trigger Test Events

Use Stripe CLI to simulate events:
# Trigger a checkout completion
stripe trigger checkout.session.completed

# Trigger subscription lifecycle events
stripe trigger customer.subscription.created
stripe trigger customer.subscription.updated
stripe trigger invoice.payment_succeeded

# Trigger payment failure
stripe trigger invoice.payment_failed

Test Card Numbers

Use these Stripe test cards to simulate various scenarios:

Successful Payments

Card NumberDescription
4242 4242 4242 4242Standard successful payment
4000 0025 0000 3155Requires 3D Secure authentication
5555 5555 5555 4444Mastercard (successful)
3782 822463 10005American Express (successful)

Failed Payments

Card NumberFailure Type
4000 0000 0000 0002Card declined
4000 0000 0000 9995Insufficient funds
4000 0000 0000 9987Lost card
4000 0000 0000 9979Stolen card
4000 0000 0000 0069Expired card
4000 0000 0000 0127Incorrect CVC

Special Scenarios

Card NumberScenario
4000 0027 6000 3184Requires authentication (fails if not completed)
4000 0000 0000 32203D Secure 2 required
4000 0000 0000 0341Attach payment method fails
For all test cards, use any future expiry date and any 3-digit CVC.

Testing Subscription Scenarios

New Subscription Flow

1

Start Subscription

In your app, navigate to the pricing page and select a plan.
2

Complete Checkout

Use test card 4242 4242 4242 4242 with any future date and CVC.
3

Verify in Cloud Admin

Check Payments > Subscriptions - new subscription should appear.
4

Verify in Stripe

Check Stripe Dashboard > Customers > Your test customer.

Test Plan Changes

# Simulate upgrade (proration charge)
stripe trigger customer.subscription.updated

# Check Cloud Admin for updated subscription

Test Payment Failure

1

Create Subscription

Complete checkout with 4242 4242 4242 4242.
2

Update to Failing Card

In Stripe Dashboard, update the customer’s payment method to 4000 0000 0000 0341.
3

Trigger Invoice

stripe trigger invoice.payment_failed
4

Verify Status

Check Payments > Subscriptions - status should change to past_due.

Test Cancellation

1

Cancel via Customer Portal

In your app, open the Customer Portal and cancel the subscription.
2

Verify Webhook

Check Stripe CLI output for customer.subscription.updated with cancel_at_period_end.
3

Check Cloud Admin

Subscription should show as cancelled with access until period end.

Monitoring Test Events

Stripe CLI Output

Watch the CLI for incoming webhooks:
2024-01-15 14:30:22  --> checkout.session.completed [evt_...]
2024-01-15 14:30:22  <-- 200 OK [POST] took 245ms
2024-01-15 14:30:23  --> customer.subscription.created [evt_...]
2024-01-15 14:30:23  <-- 200 OK [POST] took 189ms

Cloud Admin Dashboard

After test events:
  1. Statistics - Verify subscription and transaction counts update
  2. Subscriptions - New subscription appears in the list
  3. Transactions - Payment record shows in transaction history

Stripe Dashboard

Check webhook logs for delivery status:
  1. Go to Developers > Webhooks
  2. Select your test endpoint
  3. View recent deliveries and response codes
(((REPLACE_THIS_WITH_IMAGE: cloud-admin-testing-stripe-webhook-logs.png: Stripe Dashboard webhook logs showing successful delivery attempts)))

Testing Checklist

Use this checklist before going live:
1

Basic Checkout

  • Successful payment with 4242 4242 4242 4242
  • Subscription created in Cloud Admin
  • User sees active subscription in dashboard
2

Payment Failures

  • Declined card shows appropriate error
  • Insufficient funds triggers retry
  • Subscription goes to past_due correctly
3

Subscription Management

  • Plan upgrade creates proration charge
  • Plan downgrade creates proration credit
  • Cancellation marks subscription correctly
  • Uncancellation works if before period end
4

Customer Portal

  • User can access portal
  • Payment method update works
  • Invoice download works
5

Webhooks

  • All expected events received and processed
  • Signature validation working
  • Failed webhook delivery alerts configured

Going Live Checklist

When testing is complete, prepare for production:
1

Configure Live Credentials

In Cloud Admin: Payments > Settings > Live ModeEnter your live Stripe keys (pk_live_*, sk_live_*).
2

Create Live Webhook

In Stripe Dashboard, create a new webhook endpoint with your live URL:https://api.devkit4ai.com/api/v1/payments/stripe/webhooks/{project_id}/live
3

Update Environment

Ensure your deployed application uses the live mode configuration.
4

Make a Real Test

Process a small real transaction (e.g., $1) and immediately refund it to verify the live integration.
5

Monitor First Customers

Watch the first few real customers closely:
  • Verify webhooks are received
  • Confirm subscription status updates
  • Check email receipts are sent
Never use live credentials in development. Keep test and live environments completely separate.

Troubleshooting Tests

  • Verify Stripe CLI is running: stripe listen --forward-to ...
  • Check the forwarding URL is correct
  • Ensure no firewall blocking outbound connections
  • Try stripe listen --print-json for detailed output
  • Use the webhook secret from the current stripe listen session
  • Secrets change each time you restart Stripe CLI
  • For persistent secrets, create an endpoint in Stripe Dashboard
  • Check webhook delivery in Stripe Dashboard
  • Verify the project_id in the webhook URL matches your project
  • Check Cloud API logs for processing errors
  • Use card 4000 0025 0000 3155 which requires authentication
  • Ensure your checkout session has correct billing address fields