Testing Guide
Thoroughly testing your ProBuy integration is critical to ensure a smooth payment experience for your customers. This guide covers testing strategies, test scenarios, and best practices for all integration types.
Testing Phases
- โข **Development Testing:** Test in sandbox environment with test data
- โข **Integration Testing:** Verify end-to-end flow works correctly
- โข **User Acceptance Testing:** Test with real user scenarios
- โข **Performance Testing:** Ensure system handles load
- โข **Security Testing:** Verify data protection and compliance
- โข **Production Validation:** Final checks before public launch
Testing Environments
ProBuy provides separate environments for testing and production:
| Environment | API URL | Portal URL | Purpose |
|---|---|---|---|
| Sandbox | sandboxapi.probuy.dev | sandboxsupplier.probuy.dev | Pre-production testing with production-like data |
| Production | api.probuy.me | supplier.probuy.me | Live environment with real transactions |
sandboxapi.probuy.devsandboxsupplier.probuy.devapi.probuy.mesupplier.probuy.meImportant: Use Test API Tokens
Test Scenarios
Test all possible payment outcomes to ensure your integration handles each scenario correctly:
1. Successful Payment (Approved)
Test Case: Approved Payment
Scenario: Customer successfully completes payment and is approved for installments.
Test Data:
- โข Amount: 1,500 SAR
- โข Email: [email protected]
- โข Phone: +966501234567
Expected Results:
- โข โ Checkout session created successfully
- โข โ Customer redirected to ProBuy portal
- โข โ Customer completes identity verification
- โข โ Payment approved instantly
- โข โ Customer redirected to success URL
- โข โ Order status: approved
- โข โ Webhook fired (if configured)
- โข โ Order appears in Supplier Portal
Verify:
- โข Success page displays with correct order details
- โข Customer receives confirmation email
- โข Order can be fulfilled in your system
- โข Payment amount matches order total
2. Declined Payment
Test Case: Declined Payment
Scenario: Customer does not meet approval criteria and payment is declined.
Test Data:
- โข Amount: 10,000 SAR
- โข Email: [email protected]
- โข Phone: +966509999999
Expected Results:
- โข โ Checkout session created
- โข โ Customer redirected to ProBuy portal
- โข โ Customer completes application
- โข โ Payment declined
- โข โ Customer shown polite decline message
- โข โ Customer redirected to failure URL
- โข โ Order status: declined
Verify:
- โข Failure page displays gracefully
- โข Alternative payment methods offered
- โข Cart items remain in shopping cart
- โข No order created in fulfillment system
- โข Customer can retry with different payment
3. Cancelled Payment
Test Case: User Cancellation
Scenario: Customer clicks cancel/back button during checkout process.
Steps:
- 1. Start checkout process
- 2. Reach ProBuy portal
- 3. Click "Cancel" or browser back button
Expected Results:
- โข โ Customer redirected to cancel URL
- โข โ Order status: CANCELLED
- โข โ Cart preserved with all items
- โข โ Customer can retry checkout
Verify:
- โข Cancel page displays appropriate message
- โข Customer returned to cart/checkout
- โข No duplicate orders created
- โข Session cleaned up properly
4. Session Timeout
Test Case: Session Expiry
Scenario: Checkout session expires after 30 minutes of inactivity.
Expected Results:
- โข โ Session expires after 30 minutes
- โข โ Customer shown expiry message
- โข โ Option to create new session
- โข โ Cart data preserved
Verify:
- โข Clear error message about expiry
- โข Easy way to restart checkout
- โข No data loss
- โข Proper error logging
Integration Testing Checklist
Basic Integration Tests
- โ SDK/API initialization successful
- โ API token authentication working
- โ Payment button displays correctly
- โ Checkout session creates successfully
- โ Customer redirected to ProBuy portal
- โ Return URLs working (success, failure, cancel)
- โ Order data passed correctly
- โ Payment status retrieved accurately
Data Validation Tests
- โ Email validation working
- โ Phone number format validation
- โ Amount within min/max limits (100-50000)
- โ Currency code validation (SAR)
- โ Country code validation (SA)
- โ Required fields enforced
- โ Order reference ID uniqueness
- โ Special characters handled correctly
User Experience Tests
- โ Mobile responsive on iOS and Android
- โ Cross-browser compatibility (Chrome, Safari, Firefox, Edge)
- โ Loading states display correctly
- โ Error messages user-friendly
- โ Success confirmation clear
- โ Page load times acceptable (<3 seconds)
- โ No JavaScript errors in console
- โ Accessibility requirements met (WCAG 2.1)
Security Tests
- โ HTTPS enabled on all pages
- โ API tokens not exposed in client-side code
- โ CSRF protection implemented
- โ XSS protection in place
- โ Payment verification done server-side
- โ No sensitive data in URLs
- โ Secure cookie settings
- โ Content Security Policy configured
Error Handling Tests
- โ Network failure handled gracefully
- โ API timeout handled
- โ Invalid token error shown
- โ Rate limiting handled
- โ Server error (500) handled
- โ Validation errors displayed clearly
- โ Retry mechanism for failures
- โ Error logging implemented
Performance Testing
Load Testing
Test your integration under various load conditions:
| Test Type | Concurrent Users | Duration | Success Criteria |
|---|---|---|---|
| Baseline | 10 | 5 minutes | 100% success rate, <2s response time |
| Normal Load | 50 | 15 minutes | 99.5% success rate, <3s response time |
| Peak Load | 200 | 10 minutes | 98% success rate, <5s response time |
| Stress Test | 500+ | 5 minutes | System remains stable, graceful degradation |
Performance Metrics to Monitor
- **API Response Time:** <2 seconds average
- **Page Load Time:** <3 seconds
- **Time to Interactive:** <5 seconds
- **Error Rate:** <0.5%
- **Success Rate:** >99%
- **Server CPU Usage:** <70%
- **Memory Usage:** Stable, no leaks
Mobile Testing
Device Testing Matrix
| Platform | Devices to Test | OS Versions |
|---|---|---|
| iOS | iPhone 15, iPhone 13, iPhone SE, iPad Pro | iOS 15, 16, 17 |
| Android | Samsung Galaxy S23, Pixel 7, OnePlus, Xiaomi | Android 11, 12, 13, 14 |
Mobile-Specific Tests
- โ Touch targets minimum 44x44 pixels
- โ Text readable without zoom
- โ Forms easy to fill on mobile
- โ Payment button accessible with thumb
- โ Portrait and landscape orientations
- โ Works on slow 3G connection
- โ Deep links working correctly
- โ App switching handled properly
Automated Testing
Unit Tests Example
// Jest test exampledescribe('ProBuy Integration', () => { test('creates checkout session with valid data', async () => { const orderData = { order_reference_id: 'TEST-001', currency: 'SAR', total_amount: 1500, consumer: { first_name: 'Test', last_name: 'User' }, country_code: 'SA' };
const result = await createCheckout(orderData);
expect(result.checkout_id).toBeDefined(); expect(result.checkout_url).toContain('company.probuy.me'); expect(result.status).toBe('pending'); });
test('handles invalid email format', async () => { const orderData = { consumer: { email: 'invalid-email', // ... other fields } };
await expect(createCheckout(orderData)) .rejects .toThrow('Invalid email format'); });});E2E Tests Example (Playwright)
// Playwright E2E testtest('complete payment flow', async ({ page }) => { // Navigate to product page await page.goto('https://yourstore.com/products/laptop');
// Add to cart await page.click('button:has-text("Add to Cart")');
// Go to checkout await page.click('a:has-text("Checkout")');
// Select ProBuy payment await page.click('button:has-text("Pay with ProBuy")');
// Wait for redirect to ProBuy await page.waitForURL(/company\.probuy\.dev/);
// Verify checkout page loaded await expect(page.locator('h1')).toContainText('Complete Your Purchase');
// Fill in test customer details await page.fill('input[name="phone"]', '+966501234567');
// Submit payment await page.click('button:has-text("Complete Payment")');
// Wait for success redirect await page.waitForURL(/yourstore\.com.*success/);
// Verify success page await expect(page.locator('h1')).toContainText('Order Confirmed');});Test Data Reference
Use these test credentials in development/sandbox environments:
Test Email Addresses
| Result | Use Case | |
|---|---|---|
[email protected] | Approved | Test successful payment flow |
[email protected] | Declined | Test declined payment handling |
[email protected] | Timeout | Test session timeout handling |
[email protected] | Error | Test error handling |
Company Portal Test Accounts
Use these test accounts to access the Company Portal and experience the complete payment flow from the supplier/merchant perspective:
| Password | Purpose | |
|---|---|---|
[email protected] | Test@123 | Test supplier account for complete flow testing |
[email protected] | Test@123 | Secondary test account for multi-merchant scenarios |
[email protected] | Test@123 | Additional test account for various testing needs |
Using Company Portal Test Accounts
These credentials allow you to:
- โข Log in to the Company Portal in sandbox environment
- โข Create and manage test orders from the merchant perspective
- โข View order history and payment details
- โข Test the complete end-to-end integration flow
- โข Access merchant dashboard features and reports
Portal URL (Sandbox): https://sandboxcompany.probuy.dev
Sandbox Environment Only
Test Cards
Use these test cards in sandbox environment for different payment scenarios:
Knet Cards
| Card Number | Expiry Date | CVC | Result |
|---|---|---|---|
8888880000000001 | 09/30 | Any 4 digit | Captured |
8888880000000001 | Any | Any 4 digit | Not Captured |
88888800000000018888880000000001Visa/Mastercard
| Card Number | Expiry Date | CVC | Result |
|---|---|---|---|
4508750015741019 | Any | Any | โ |
5454545454545454 | Any | Any | โ |
5453010000095539 | 12/25 | 300 | โ |
5123450000000008 | Any | Any | โ |
5457210001000019 | 12/25 | 212 | โ |
4012001037141112 | 12/24 | 207 | โ |
450875001574101954545454545454545453010000095539512345000000000854572100010000194012001037141112Benefit Cards
| Card Number | Expiry Date | CVC | Result |
|---|---|---|---|
4600410123456789 | Any | Any 6 digit | Captured |
4550120123456789 | Any | Any 6 digit | Expired card |
4845550123456789 | Any | Any 6 digit | Incorrect PIN |
4575550123456789 | Any | Any 6 digit | Refer to Issuer |
4895550123456789 | Any | Any 6 digit | Please contact issuer |
46004101234567894550120123456789484555012345678945755501234567894895550123456789American Express (AMEX)
| Card Number | Expiry Date | CVC | Result |
|---|---|---|---|
345678901234564 | 05/21 | 1000 | Unspecified Failure |
345678901234564 | 04/37 | 1000 | Declined |
345678901234564345678901234564Mada Cards
| Card Number | Expiry Date | CVC | Result |
|---|---|---|---|
4464040000000007 | 02/29 | 123 | Capture |
5297412542005689 | 05/25 | 350 | Capture |
44640400000000075297412542005689STC Pay
| Mobile Number | OTP | Result |
|---|---|---|
966557877988 | 1234 | Success |
9665578779881234Card Holder's Name
See the Test Cards Guide for more test data including phone numbers and amounts.
Pre-Production Checklist
Before switching to production, verify all items on this checklist:
Go-Live Checklist
Integration Testing
- โ All test scenarios passed
- โ Mobile testing completed on real devices
- โ Cross-browser testing completed
- โ Error handling verified
- โ Performance testing passed
Configuration
- โ Production API token generated
- โ Environment changed from dev/sandbox to prod
- โ HTTPS enabled on all pages
- โ Return URLs verified and working
- โ Webhooks configured (if using)
Security
- โ API tokens secured (not in client-side code)
- โ Server-side payment verification implemented
- โ Security headers configured
- โ CSRF protection enabled
- โ Rate limiting configured
Operations
- โ Customer support team trained
- โ Order fulfillment process ready
- โ Monitoring and alerts configured
- โ Error logging set up
- โ Backup payment method available
See our detailed Go-Live Checklist for complete preparation guide.
Monitoring and Logging
Key Metrics to Monitor
- **Payment Success Rate:** Target >95%
- **Average Response Time:** Target <2 seconds
- **Error Rate:** Target <1%
- **Session Completion Rate:** Track abandoned checkouts
- **Approval Rate:** Monitor trends
- **API Availability:** Target 99.9% uptime
Logging Best Practices
// Example logging implementationfunction logCheckoutEvent(event, data) { const logEntry = { timestamp: new Date().toISOString(), event: event, checkout_id: data.checkout_id, order_reference_id: data.order_reference_id, amount: data.total_amount, currency: data.currency, status: data.status, user_agent: navigator.userAgent, // Do NOT log sensitive data like customer PII };
// Send to your logging service logger.info('ProBuy Checkout Event', logEntry);
// Track in analytics analytics.track(event, { checkout_id: data.checkout_id, value: data.total_amount, currency: data.currency });}
// UsagelogCheckoutEvent('checkout_created', checkoutData);logCheckoutEvent('checkout_completed', checkoutData);logCheckoutEvent('checkout_failed', { ...checkoutData, error: error.message });Troubleshooting Failed Tests
Tests failing intermittently
Common causes:
- โข Network latency or timeouts
- โข Race conditions in async code
- โข Browser cache issues
- โข Test data conflicts
Solutions: Increase timeout values, add explicit waits, use unique test data, clear cache between tests
Mobile tests failing but desktop works
Check:
- โข Responsive design CSS media queries
- โข Touch event handlers
- โข Mobile-specific JavaScript
- โข Viewport meta tag
API tests returning 401 Unauthorized
Verify:
- โข API token is valid and active
- โข Using correct environment (dev/sandbox/prod)
- โข Authorization header formatted correctly: "Bearer YOUR_TOKEN"
- โข Token hasn't expired
Getting Help
If you encounter issues during testing:
Technical Support
Integration testing assistance and troubleshooting
Email: [email protected]
Response: Within 4 hours
Include: Error logs, test scenario, environment
Documentation
Additional testing resources
- ๐ Test Cards & Data
- ๐ฎ Postman Collection
- โ Go-Live Checklist