Testing in Stripe Test Mode

Before launching your affiliate program, it's crucial to test everything in Stripe test mode. This guide walks you through the process.

Why Test Mode?

Stripe test mode allows you to:

- Test the entire affiliate flow without real charges - Verify commission tracking works correctly - Test payout processing - Ensure webhooks are configured properly - Train your team without risk

Setting Up Test Mode

1. Get Stripe Test Keys

1. Log into your [Stripe Dashboard](https://dashboard.stripe.com) 2. Switch to Test Mode (toggle in the top right) 3. Go to DevelopersAPI Keys 4. Copy your Test Publishable Key and Test Secret Key

2. Configure LinkSense with Test Keys

1. In LinkSense, go to SettingsStripe Integration 2. Enter your Stripe test keys: - Publishable Key (starts with pk_test_) - Secret Key (starts with sk_test_) 3. Save the configuration

3. Set Up Test Webhooks

1. In Stripe Dashboard → DevelopersWebhooks 2. Click Add Endpoint 3. Enter your webhook URL: https://your-domain.com/api/webhooks/stripe 4. Select events to listen for: - checkout.session.completed - invoice.payment_succeeded - charge.refunded - charge.dispute.created 5. Copy the webhook signing secret 6. Add it to LinkSense settings

Testing the Complete Flow

Step 1: Create Test Products

1. In LinkSense, create a test product 2. Set a low price (e.g., $10) for easy testing 3. Mark it as a test product in the description

Step 2: Create Test Campaign

1. Create a test campaign with a simple commission rule 2. Use 10% commission for easy calculation 3. Enable the campaign

Step 3: Create Test Affiliate

1. Create a test affiliate account (use a test email) 2. Generate a test coupon code (e.g., TEST10) 3. Note the coupon code for testing

Step 4: Connect Test Stripe Account (Affiliate)

1. As the test affiliate, go to SettingsPayment Method 2. Use Stripe's test account creation flow 3. Use test account details (Stripe provides test accounts)

Step 5: Simulate a Purchase

#### Option A: Using Stripe Checkout Test Mode

1. Go to your product's checkout page 2. Use Stripe's test card numbers: - Success: 4242 4242 4242 4242 - Decline: 4000 0000 0000 0002 - 3D Secure: 4000 0025 0000 3155 3. Apply your test coupon code 4. Complete the checkout

#### Option B: Using Stripe API

`bash curl https://api.stripe.com/v1/checkout/sessions \ -u sk_test_YOUR_KEY: \ -d "mode=payment" \ -d "success_url=https://example.com/success" \ -d "cancel_url=https://example.com/cancel" \ -d "line_items[0][price_data][currency]=usd" \ -d "line_items[0][price_data][product_data][name]=Test Product" \ -d "line_items[0][price_data][unit_amount]=1000" \ -d "discounts[0][coupon]=TEST10" `

Step 6: Verify Commission Tracking

1. Wait a few seconds for webhook processing 2. Go to AdminCommissions 3. Verify a commission entry was created: - Check affiliate is correct - Verify commission amount (should be 10% of purchase) - Status should be "pending"

Step 7: Test Payout Processing

1. Go to AdminPayouts 2. Click Process Payouts Now 3. Verify: - Commission status changes to "paid" - Transfer is created in Stripe (check Stripe Dashboard) - Affiliate receives notification

Testing Edge Cases

Test Refunds

1. In Stripe Dashboard → Payments 2. Find a test payment 3. Click Refund 4. Verify in LinkSense: - Negative commission entry is created - Original commission is adjusted - Affiliate is notified (if on hold)

Test Recurring Commissions

1. Create a subscription product 2. Enable recurring commissions in campaign 3. Complete a test subscription purchase 4. Wait for renewal (or manually trigger in Stripe) 5. Verify commission is created for renewal

Test Multiple Affiliates

1. Create multiple test affiliates 2. Generate different coupon codes 3. Make purchases with different codes 4. Verify each affiliate's commissions are tracked separately

Verifying Webhooks

Check Webhook Delivery

1. In Stripe Dashboard → DevelopersWebhooks 2. Click on your webhook endpoint 3. View Recent events 4. Verify events are being received: - Green checkmark = successful - Red X = failed (check logs)

Test Webhook Manually

You can trigger test events in Stripe:

1. Go to DevelopersWebhooks 2. Click Send test webhook 3. Select event type 4. Send to your endpoint 5. Verify LinkSense processes it correctly

Common Issues

Webhook Not Received

- Verify webhook URL is correct - Check that your server is accessible - Ensure SSL certificate is valid - Check firewall rules

Commission Not Recorded

- Verify coupon code matches exactly - Check campaign is active - Ensure webhook is processing - Review server logs for errors

Payout Failed

- Verify affiliate's Stripe Connect account is active - Check for account restrictions - Ensure sufficient funds in your Stripe account - Review error messages in admin dashboard

Test Data Cleanup

After testing, you may want to clean up:

1. Test Commissions: Can be left (they're marked as test) 2. Test Affiliates: Delete or deactivate 3. Test Products: Archive or delete 4. Stripe Test Data: Stripe automatically cleans up after 90 days

Going Live

When you're ready to go live:

1. Switch to Live Keys: Update Stripe keys in LinkSense settings 2. Update Webhook URL: Point to production webhook endpoint 3. Verify Live Webhook: Test with a small real transaction 4. Monitor Closely: Watch for any issues in the first few days

Best Practices

1. Test Everything: Don't skip any part of the flow 2. Document Issues: Keep notes of any problems encountered 3. Test Regularly: Re-test after major updates 4. Use Test Mode for Development: Always develop in test mode 5. Train Your Team: Use test mode to train support staff

Additional Resources

- [Stripe Testing Guide](https://stripe.com/docs/testing) - [Stripe Test Cards](https://stripe.com/docs/testing#cards) - [LinkSense API Documentation](#)