Test Payments and Modifications
Test payment transactions and post-payment modifications
Test Payments and Modifications
Test various payment scenarios and post-payment operations.
Successful payments
Use test cards to simulate successful payments:
const payment = await plexy.payments.create({
amount: 5000,
currency: 'USD',
payment_method: {
type: 'card',
card: {
number: '4242424242424242',
exp_month: 12,
exp_year: 2030,
cvc: '123'
}
}
});
// payment.status === 'succeeded'Failed payments
Trigger specific failure scenarios with special card numbers:
| Card Number | Scenario |
|---|---|
4000000000000002 | Card declined |
4000000000009995 | Insufficient funds |
4000000000009987 | Lost card |
4000000000009979 | Stolen card |
4000000000000069 | Expired card |
4000000000000127 | Invalid CVC |
Capture payments
Test authorization and capture flow:
// Step 1: Authorize (capture: false)
const auth = await plexy.payments.create({
amount: 5000,
currency: 'USD',
capture: false,
payment_method: { /* ... */ }
});
// auth.status === 'requires_capture'
// Step 2: Capture full amount
const captured = await plexy.payments.capture(auth.id);
// captured.status === 'succeeded'Partial capture
Capture less than the authorized amount:
const captured = await plexy.payments.capture(auth.id, {
amount: 3000 // Capture $30 of $50 authorization
});Refunds
Test refund processing:
// Full refund
const refund = await plexy.refunds.create({
payment_id: 'pay_abc123'
});
// Partial refund
const partialRefund = await plexy.refunds.create({
payment_id: 'pay_abc123',
amount: 2500 // Refund $25
});Cancel payments
Cancel an uncaptured authorization:
const canceled = await plexy.payments.cancel('pay_abc123');
// canceled.status === 'canceled'Verify webhook delivery
After each test, verify webhooks were received:
- Check your webhook endpoint logs
- Verify event type matches (
payment.succeeded,refund.created, etc.) - Confirm payload data is correct
See also
- Test Cards - All test card numbers
- Result Codes - Response handling