Testing Guide ​
Complete guide for testing Bridge Payments integration with test cards, sandbox environments, and best practices.
Test Mode ​
Enable Test Mode ​
Use test credentials for all providers:
Stripe:
bash
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...PayPal:
bash
PAYPAL_MODE=sandbox
PAYPAL_CLIENT_ID=sandbox_client_id
PAYPAL_CLIENT_SECRET=sandbox_client_secretAuthorize.net:
bash
AUTHORIZE_NET_ENVIRONMENT=sandbox
AUTHORIZE_NET_API_LOGIN_ID=sandbox_login_id
AUTHORIZE_NET_TRANSACTION_KEY=sandbox_transaction_keyTest Cards ​
Stripe Test Cards ​
| Card Number | Brand | Result |
|---|---|---|
4242424242424242 | Visa | Success |
4000002500003155 | Visa | Requires 3D Secure |
4000000000009995 | Visa | Declined (insufficient funds) |
4000000000000002 | Visa | Declined (generic) |
4000000000000069 | Visa | Expired card |
4000000000000127 | Visa | Incorrect CVC |
5555555555554444 | Mastercard | Success |
2223003122003222 | Mastercard | Success |
378282246310005 | Amex | Success |
6011111111111117 | Discover | Success |
Expiration: Any future date (e.g., 12/25)
CVC: Any 3 digits (e.g., 123), 4 for Amex
PayPal Test Cards ​
| Card Number | Type | Result |
|---|---|---|
4111111111111111 | Visa | Success |
5555555555554444 | Mastercard | Success |
378282246310005 | Amex | Success |
6011111111111117 | Discover | Success |
Expiration: Any future date
CVV: Any 3 digits (4 for Amex)
Authorize.net Test Cards ​
| Card Number | Type | Result |
|---|---|---|
4111111111111111 | Visa | Approved |
5424000000000015 | Mastercard | Approved |
370000000000002 | Amex | Approved |
6011000000000012 | Discover | Approved |
4222222222222 | Visa | Declined |
Expiration: Any future date
CVV: Any 3 digits (4 for Amex)
Testing Scenarios ​
1. Successful Payment ​
bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/payments/intents" \
-H "Content-Type: application/json" \
-H "X-Session-ID: test_session_123" \
-d '{
"total_cents": 2000,
"currency": "USD",
"provider_id": "stripe",
"card_number": "4242424242424242",
"card_exp_month": "12",
"card_exp_year": "2025",
"card_cvc": "123"
}'2. Declined Payment ​
bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/payments/intents" \
-H "Content-Type: application/json" \
-H "X-Session-ID: test_session_123" \
-d '{
"total_cents": 2000,
"currency": "USD",
"provider_id": "stripe",
"card_number": "4000000000000002",
"card_exp_month": "12",
"card_exp_year": "2025",
"card_cvc": "123"
}'3. 3D Secure Authentication ​
bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/payments/intents" \
-H "Content-Type: application/json" \
-H "X-Session-ID: test_session_123" \
-d '{
"total_cents": 2000,
"currency": "USD",
"provider_id": "stripe",
"card_number": "4000002500003155",
"card_exp_month": "12",
"card_exp_year": "2025",
"card_cvc": "123"
}'4. Guest Checkout ​
bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/payments/intents" \
-H "Content-Type: application/json" \
-d '{
"total_cents": 2000,
"currency": "USD",
"provider_id": "stripe",
"card_number": "4242424242424242",
"card_exp_month": "12",
"card_exp_year": "2025",
"card_cvc": "123",
"guest_data": {
"email": "test@example.com",
"name": "Test User"
}
}'5. Subscription ​
bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/subscriptions" \
-H "Content-Type: application/json" \
-H "X-Session-ID: test_session_123" \
-d '{
"customer_id": "test_customer_123",
"payment_method_id": "test_pm_123",
"provider_id": "stripe",
"total_cents": 2000,
"currency": "USD",
"billing_interval": "monthly",
"trial_days": 14
}'Testing Webhooks ​
Stripe Webhook Testing ​
Use Stripe CLI to trigger test webhooks:
bash
# Install Stripe CLI
brew install stripe/stripe-cli/stripe
# Login
stripe login
# Forward webhooks to local server
stripe listen --forward-to localhost:3000/bridge-payment/webhooks/stripe
# Trigger test events
stripe trigger payment_intent.succeeded
stripe trigger payment_intent.failed
stripe trigger customer.subscription.createdPayPal Webhook Testing ​
Use PayPal Sandbox webhook simulator:
- Go to developer.paypal.com
- Navigate to Webhooks → Simulator
- Select event type
- Send test webhook
Manual Webhook Testing ​
bash
curl -X POST "https://your-instance.pubflow.com/bridge-payment/webhooks/test" \
-H "Content-Type: application/json" \
-H "X-Session-ID: test_session_123" \
-d '{
"event": "payment_intent.succeeded",
"test_data": {
"payment_id": "test_pay_123",
"amount": 2000,
"currency": "USD"
}
}'Automated Testing ​
Unit Tests ​
javascript
import { describe, it, expect } from 'vitest';
import { createPaymentIntent } from './bridge-payments';
describe('Bridge Payments', () => {
it('should create payment intent', async () => {
const result = await createPaymentIntent({
total_cents: 2000,
currency: 'USD',
provider_id: 'stripe',
sessionId: 'test_session_123'
});
expect(result).toHaveProperty('id');
expect(result).toHaveProperty('client_secret');
expect(result.total_cents).toBe(2000);
});
it('should handle declined payment', async () => {
await expect(
createPaymentIntent({
total_cents: 2000,
currency: 'USD',
provider_id: 'stripe',
card_number: '4000000000000002',
sessionId: 'test_session_123'
})
).rejects.toThrow();
});
});Integration Tests ​
javascript
import { describe, it, expect, beforeAll } from 'vitest';
describe('Payment Flow', () => {
let paymentIntentId;
beforeAll(async () => {
// Create payment intent
const intent = await createPaymentIntent({
total_cents: 2000,
currency: 'USD',
provider_id: 'stripe',
sessionId: 'test_session_123'
});
paymentIntentId = intent.id;
});
it('should confirm payment', async () => {
const result = await confirmPayment(paymentIntentId, {
card_number: '4242424242424242',
card_exp_month: '12',
card_exp_year: '2025',
card_cvc: '123'
});
expect(result.status).toBe('succeeded');
});
it('should sync payment status', async () => {
const result = await syncPaymentIntent(
paymentIntentId,
'test_session_123'
);
expect(result.status).toBe('succeeded');
});
});Testing Checklist ​
Before Going Live ​
- [ ] Test successful payments
- [ ] Test declined payments
- [ ] Test 3D Secure authentication
- [ ] Test guest checkout
- [ ] Test saved payment methods
- [ ] Test subscriptions
- [ ] Test webhooks
- [ ] Test error handling
- [ ] Test edge cases (expired cards, insufficient funds)
- [ ] Verify email receipts
- [ ] Check payment records in database
- [ ] Review provider dashboards
- [ ] Test on multiple devices/browsers
- [ ] Verify SSL/HTTPS
- [ ] Check PCI compliance
Best Practices ​
- Use Test Mode - Always test in sandbox/test mode first
- Test All Scenarios - Success, failure, edge cases
- Automate Tests - Write unit and integration tests
- Monitor Webhooks - Verify webhook delivery
- Check Logs - Review application and provider logs
- Test on Real Devices - Mobile, desktop, different browsers
- Verify Data - Check database records match expectations
Troubleshooting ​
"Invalid card number" ​
Cause: Using production card in test mode
Solution: Use test card numbers listed above
"Webhook not received" ​
Cause: Webhook URL not configured or unreachable
Solution:
- Verify webhook URL in provider dashboard
- Check firewall/network settings
- Use webhook testing tools
"Payment stuck in processing" ​
Cause: Frontend didn't sync status
Solution:
- Call
/payments/intents/:id/syncendpoint - Check webhook delivery
- Verify payment status in provider dashboard
Next Steps ​
- Payments API - Complete API reference
- Stripe Integration - Stripe testing details
- PayPal Integration - PayPal testing details
- Authorize.net Integration - Authorize.net testing details