ProBuy Logo
PB

ProBuy Docs

Version 1.0

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 Environments

ProBuy provides separate environments for testing and production:

Environment
Sandbox
API URL
sandboxapi.probuy.dev
Portal URL
sandboxsupplier.probuy.dev
Purpose
Pre-production testing with production-like data
Environment
Production
API URL
api.probuy.me
Portal URL
supplier.probuy.me
Purpose
Live environment with real transactions

Test Scenarios

Test all possible payment outcomes to ensure your integration handles each scenario correctly:

1. Successful Payment (Approved)

2. Declined Payment

3. Cancelled Payment

4. Session Timeout

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
Baseline
Concurrent Users
10
Duration
5 minutes
Success Criteria
100% success rate, <2s response time
Test Type
Normal Load
Concurrent Users
50
Duration
15 minutes
Success Criteria
99.5% success rate, <3s response time
Test Type
Peak Load
Concurrent Users
200
Duration
10 minutes
Success Criteria
98% success rate, <5s response time
Test Type
Stress Test
Concurrent Users
500+
Duration
5 minutes
Success Criteria
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
iOS
Devices to Test
iPhone 15, iPhone 13, iPhone SE, iPad Pro
OS Versions
iOS 15, 16, 17
Platform
Android
Devices to Test
Samsung Galaxy S23, Pixel 7, OnePlus, Xiaomi
OS Versions
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 example
describe('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 test
test('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="email"]', '[email protected]');
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
Approved
Use Case
Test successful payment flow
Result
Declined
Use Case
Test declined payment handling
Result
Timeout
Use Case
Test session timeout handling
Result
Error
Use Case
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
Test@123
Purpose
Test supplier account for complete flow testing
Password
Test@123
Purpose
Secondary test account for multi-merchant scenarios
Password
Test@123
Purpose
Additional test account for various testing needs

Test Cards

Use these test cards in sandbox environment for different payment scenarios:

Knet Cards

Card Number
8888880000000001
Expiry Date
09/30
CVC
Any 4 digit
Result
Captured
Card Number
8888880000000001
Expiry Date
Any
CVC
Any 4 digit
Result
Not Captured

Visa/Mastercard

Card Number
4508750015741019
Expiry Date
Any
CVC
Any
Result
โ€”
Card Number
5454545454545454
Expiry Date
Any
CVC
Any
Result
โ€”
Card Number
5453010000095539
Expiry Date
12/25
CVC
300
Result
โ€”
Card Number
5123450000000008
Expiry Date
Any
CVC
Any
Result
โ€”
Card Number
5457210001000019
Expiry Date
12/25
CVC
212
Result
โ€”
Card Number
4012001037141112
Expiry Date
12/24
CVC
207
Result
โ€”

Benefit Cards

Card Number
4600410123456789
Expiry Date
Any
CVC
Any 6 digit
Result
Captured
Card Number
4550120123456789
Expiry Date
Any
CVC
Any 6 digit
Result
Expired card
Card Number
4845550123456789
Expiry Date
Any
CVC
Any 6 digit
Result
Incorrect PIN
Card Number
4575550123456789
Expiry Date
Any
CVC
Any 6 digit
Result
Refer to Issuer
Card Number
4895550123456789
Expiry Date
Any
CVC
Any 6 digit
Result
Please contact issuer

American Express (AMEX)

Card Number
345678901234564
Expiry Date
05/21
CVC
1000
Result
Unspecified Failure
Card Number
345678901234564
Expiry Date
04/37
CVC
1000
Result
Declined

Mada Cards

Card Number
4464040000000007
Expiry Date
02/29
CVC
123
Result
Capture
Card Number
5297412542005689
Expiry Date
05/25
CVC
350
Result
Capture

STC Pay

Mobile Number
966557877988
OTP
1234
Result
Success

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:

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 implementation
function 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
});
}
// Usage
logCheckoutEvent('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

Next Steps