Introduction
A unified, type-safe payment gateway library for Node.js and Turkish payment providers.
better-payment lets you integrate Turkish payment providers — iyzico, PayTR, Akbank and Parampos — through one TypeScript API.
0.0.1 is a fresh start. The version history was reset. Releases 1.x–3.x contained incorrect provider integrations and callback checks that could be bypassed, and are deprecated. Read What's New in 0.0.1 for what changed and how to migrate.
Why better-payment?
Every payment provider has its own SDK, request format, signature scheme and error model. better-payment hides those differences behind one interface.
Single API
createPayment, initThreeDSPayment, refund, cancel and getPayment work the same way for every provider.
Verified callbacks
3D Secure callbacks are checked with your own credentials before any result is trusted.
Secure HTTP handler
Framework-agnostic handler that exposes only what you enable, with authorize and server-side amount hooks.
Multi-Provider
Enable several providers at once and pick one per request.
Supported Providers
| Provider | Non-3D | 3D Secure | Refund | Cancel | Status | BIN | Installments |
|---|---|---|---|---|---|---|---|
| iyzico | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| PayTR | ✅ ¹ | ✅ iFrame | ✅ | ✅ ² | ✅ | ✅ | ✅ |
| Akbank | ✅ | ✅ 3D_PAY | ✅ | ✅ | ✅ | — | — |
| Parampos | ✅ (TRY) | ✅ | ✅ | ✅ | ✅ | ✅ | — |
¹ Your PayTR account must be approved for non-3D payments.
² PayTR has no void endpoint, so cancel() issues a full refund.
Quick Example
import { BetterPayment, ProviderType } from 'better-payment';
const payment = new BetterPayment({
mode: 'sandbox',
defaultProvider: ProviderType.IYZICO,
providers: {
iyzico: {
enabled: true,
config: {
apiKey: process.env.IYZICO_API_KEY!,
secretKey: process.env.IYZICO_SECRET_KEY!,
},
},
},
});
const result = await payment.initThreeDSPayment({
price: '100.00',
paidPrice: '100.00',
currency: 'TRY',
basketId: 'B1',
callbackUrl: 'https://yoursite.com/api/pay/iyzico/payment/complete-3ds',
paymentCard: { /* ... */ },
buyer: { /* ... */ },
shippingAddress: { /* ... */ },
billingAddress: { /* ... */ },
basketItems: [{ /* ... */ }],
});
// Render result.threeDSHtmlContent in the customer's browser