payfyio
API Reference

PayfyioHandler

Framework-agnostic HTTP handler for routing payment requests.

PayfyioHandler is a framework-agnostic HTTP handler that routes incoming requests to the correct provider method based on the URL path.

Route Format

POST /api/pay/:provider/:action
GET  /api/pay/:provider/:action
SegmentValues
:provideriyzico, paytr, akbank, parampos
:actionsee table below

Supported Routes

Common (all providers)

MethodActionProvider method
POSTcreatecreatePayment()
POST3ds/initinitThreeDSPayment()
POST3ds/completecompleteThreeDSPayment()
POSTrefundrefund()
POSTcancelcancel()
POSTinstallmentgetInstallmentInfo()

İyzico-specific

MethodActionProvider method
POSTcheckout/initinitCheckoutForm()
POSTcheckout/retrieveretrieveCheckoutForm()
POSTpwi/initinitPWIPayment()
POSTpwi/retrieveretrievePWIPayment()
POSTbin-checkcheckBIN()
POSTsubscription/initializeinitializeSubscription()
POSTsubscription/cancelcancelSubscription()
POSTsubscription/upgradeupgradeSubscription()
POSTsubscription/retrieveretrieveSubscription()
POSTsubscription/card-updateupdateSubscriptionCard()
POSTsubscription/productcreateSubscriptionProduct()
POSTsubscription/pricing-plancreateSubscriptionPricingPlan()

Handler Interface

import type { PayfyioRequest, PayfyioResponse } from 'payfyio';

// Input
interface PayfyioRequest {
  method: string;
  url: string;
  headers: Record<string, string>;
  body?: unknown;
}

// Output
interface PayfyioResponse {
  status: number;
  headers?: Record<string, string>;
  body: unknown;
}

// Usage
const res = await payment.handler.handle(req);

Accessing the Handler

const payment = new Payfyio({ /* ... */ });

// The handler is on .handler
const handler = payment.handler;

// Process a request
const response = await handler.handle({
  method: 'POST',
  url: 'https://yoursite.com/api/pay/iyzico/create',
  headers: { 'content-type': 'application/json' },
  body: { price: '100.00', /* ... */ },
});
// response.status === 200
// response.body === { status: 'success', paymentId: '...' }

On this page