import { chaos } from 'better-payment/plugins';
const payment = betterPayment({
providers: { ... },
plugins: [
chaos({
enabled: process.env.CHAOS === '1',
seed: 42,
rules: [
{ operation: 'createPayment', probability: 0.2, fail: 'NETWORK_ERROR' },
{ operation: 'refund', delay: '3s' },
],
}),
],
});
Injects failures and delays into operations, so that you can test how your application handles declines, lost responses (
NETWORK_ERROR) and slow providers. Failed calls never reach the provider. Throws inproductionmode unlessallowProductionis set.