# Testing ## Overview This guide provides comprehensive testing resources for your xMoney integration. Use our test cards, magic amounts to simulate various payment scenarios before going live. All test transactions should be performed in the xMoney **test environment** using your test API credentials. ## Test Mode vs Live Mode | Test Mode | Live Mode | | --- | --- | | Use test credentials from your sandbox account | Use production credentials from your live account | | No real money is transferred | Real money is transferred | | Simulated payment scenarios | Actual payment processing | | Test API endpoint: `https://api-stage.xmoney.com` | Live API endpoint: `https://api.xmoney.com` | ## Test Cards Card Testing > Use these test cards to simulate different payment scenarios in your test environment. | Card Brand | Card Number | Expiry Date | CVV | 3DS Code | Result | | --- | --- | --- | --- | --- | --- | | Visa | `4111 1111 1111 1111` | Any future date | `123` | `00000` | Successful payment | | Mastercard | `5555 5555 5555 4444` | Any future date | `123` | `00000` | Successful payment | | Mastercard | `5555 5555 5555 5599` | `12/34` | `123` | `00000` | Successful payment (3DS2 Full) | | Visa | `4111 1111 1111 1111` | `12/26` | `123` | `00000` | Successful payment (3DS2 Frictionless) | | Mastercard | `5168 4948 9505 5780` | `12/26` | `123` | `00000` | Failed payment (3DS2 Frictionless) | | Visa | `4000 0011 1111 1118` | `12/30` | `123` | `00000` | Successful payment (3DS2 Attempt) | | Visa | `4444 5555 1111 3333` | `12/26` | `123` | N/A | Successful payment (SSL) | Checkout hosted page For 3DS test cards, use `00000` as the authentication code when prompted. Magic Amounts > Use these specific transaction amounts to trigger different payment responses in your test environment. | Scenario | Magic Amount | Failure Reason | Response Code | | --- | --- | --- | --- | | Successful Payment | `1.00` | N/A | `200` | | Insufficient Funds | `0.02` | `insufficient_funds` | `402` | | Bank Timeout | `0.03` | `bank_timeout` | `408` | | Pending at Bank | `0.04` | `pending_at_bank` | `202` | | Declined by Bank | `0.05` | `declined_by_bank` | `403` | | Rejected by Processor | `0.06` | `rejected_by_processor` | `422` | | Malformed Processor Response | `0.07` | `malformed_response` | `500` | | Processor Timeout | `0.08` | `processor_timeout` | `504` | | 3D Secure Required | `25.01` or higher | N/A (requires 3DS authentication) | `201` with redirect | You can combine test cards with magic amounts to simulate specific scenarios. Testing Flow ### Complete Testing Workflow 1. **Make a test payment** - Use a test card from the list above - Set a magic amount to trigger a specific response - Complete the payment flow 2. **Receive webhook notification** - Configure your webhook endpoint in the test environment - Process the webhook payload according to your implementation - Validate the transaction status and details 3. **Check transaction status** - Use the Transaction API to verify the status - Confirm the `failureReason` matches the expected result - Test your error handling logic Always implement proper error handling for all possible payment scenarios. ## Testing Specific Scenarios ### 3D Secure Authentication To test 3D Secure (3DS) authentication: 1. Use a test card from above 2. Set the transaction amount to `25.01` or higher 3. When redirected to the 3DS page, use `00000` as the authentication code 4. Complete the payment flow 3DS testing simulates both the card issuer authentication and the redirect flow your customers will experience. ### Refunds To test refund functionality: 1. Make a successful test payment 2. Use the Refund API to process a full or partial refund 3. Verify the refund status through the API and webhooks ### Recurring Payments Test recurring payment scenarios: 1. Create a successful initial payment with `recurring: true` 2. Store the payment method token returned in the response 3. Use the token to create subsequent payments 4. Test different intervals and amounts ## Debugging Tools ### Response Codes | Code | Status | Description | | --- | --- | --- | | 200 | OK | Transaction processed successfully | | 201 | Created | Transaction created (may require 3DS) | | 202 | Accepted | Transaction is being processed | | 400 | Bad Request | Invalid parameters or request format | | 401 | Unauthorized | Invalid API credentials | | 402 | Payment Required | Payment failed (see failureReason) | | 403 | Forbidden | Transaction declined by issuer | | 404 | Not Found | Resource not found | | 408 | Timeout | Request timed out | | 422 | Unprocessable | Invalid transaction data | | 500 | Server Error | Internal server error | | 504 | Gateway Timeout | Processing timeout | ### Webhook Testing 1. Configure your webhook URL in the test environment 2. Make test transactions to trigger webhook events 3. Use the Webhook Logs in your dashboard to inspect delivery status 4. Implement proper validation of webhook signatures Always validate webhook signatures to ensure the authenticity of webhook events. ## Common Testing Issues | Issue | Possible Cause | Solution | | --- | --- | --- | | 3DS not triggered | Transaction amount below threshold | Use amount > 25.00 | | Webhook not received | Incorrect webhook URL | Verify URL in dashboard | | Invalid signature | Wrong API key used for validation | Check signature calculation | | Unexpected decline | Using production card in test mode | Use test cards only | | API connection failure | Incorrect API endpoint | Verify test vs. production endpoint | ## Going Live Checklist Before transitioning to the production environment: - [ ] Test all payment flows with test cards - [ ] Implement proper error handling for all scenarios - [ ] Test webhook integration and signature validation - [ ] Verify 3DS flows work correctly - [ ] Implement proper logging and monitoring - [ ] Update API endpoints from test to production - [ ] Update API credentials from test to production - [ ] Complete a test transaction in production environment Never use your production API credentials in your development or staging environments.