PlexySDK DOCS

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 NumberScenario
4000000000000002Card declined
4000000000009995Insufficient funds
4000000000009987Lost card
4000000000009979Stolen card
4000000000000069Expired card
4000000000000127Invalid 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:

  1. Check your webhook endpoint logs
  2. Verify event type matches (payment.succeeded, refund.created, etc.)
  3. Confirm payload data is correct

See also

На этой странице