import { PaymentProvider, CreateCustomerOptions, Customer, CreateCheckoutOptions, CheckoutSession, CreateSubscriptionOptions, Subscription, UpdateSubscriptionOptions, CreatePortalOptions, PortalSession, WebhookEvent } from '../types.js'; import '@parsrun/types'; /** * @parsrun/payments - iyzico Provider * Edge-compatible iyzico provider using fetch API */ /** * iyzico provider config */ interface IyzicoProviderConfig { /** iyzico API key */ apiKey: string; /** iyzico secret key */ secretKey: string; /** Environment */ environment?: "sandbox" | "production" | undefined; /** Base URL override */ baseUrl?: string | undefined; } /** * iyzico basket item */ interface IyzicoBasketItem { id: string; name: string; category1: string; category2?: string | undefined; itemType: "PHYSICAL" | "VIRTUAL"; price: string; } /** * iyzico buyer info */ interface IyzicoBuyer { id: string; name: string; surname: string; email: string; gsmNumber?: string | undefined; identityNumber: string; registrationAddress: string; city: string; country: string; ip: string; } /** * iyzico address */ interface IyzicoAddress { contactName: string; city: string; country: string; address: string; } /** * Extended checkout options for iyzico */ interface IyzicoCheckoutOptions extends CreateCheckoutOptions { /** Buyer information (required for iyzico) */ buyer: IyzicoBuyer; /** Billing address */ billingAddress: IyzicoAddress; /** Shipping address */ shippingAddress: IyzicoAddress; /** Basket items */ basketItems: IyzicoBasketItem[]; /** Price (total amount as decimal string) */ price: string; /** Paid price (can include installment fees) */ paidPrice: string; /** Currency (TRY, USD, EUR, GBP, IRR) */ currency: "TRY" | "USD" | "EUR" | "GBP" | "IRR"; /** Installment options */ enabledInstallments?: number[] | undefined; /** Force 3D Secure */ force3ds?: boolean | undefined; /** Conversation ID for tracking */ conversationId?: string | undefined; } /** * iyzico Payment Provider * Edge-compatible using fetch API * * @example * ```typescript * const iyzico = new IyzicoProvider({ * apiKey: process.env.IYZICO_API_KEY, * secretKey: process.env.IYZICO_SECRET_KEY, * environment: 'sandbox', * }); * * const checkout = await iyzico.createCheckoutForm({ * price: '100.00', * paidPrice: '100.00', * currency: 'TRY', * basketItems: [...], * buyer: {...}, * billingAddress: {...}, * shippingAddress: {...}, * callbackUrl: 'https://example.com/callback', * }); * ``` */ declare class IyzicoProvider implements PaymentProvider { readonly type: "iyzico"; private apiKey; private secretKey; private baseUrl; constructor(config: IyzicoProviderConfig); private request; private generateRandomString; private generateAuthorizationString; private generatePkiString; createCustomer(_options: CreateCustomerOptions): Promise; getCustomer(_customerId: string): Promise; updateCustomer(_customerId: string, _options: Partial): Promise; deleteCustomer(_customerId: string): Promise; createCheckout(_options: CreateCheckoutOptions): Promise; /** * Create iyzico checkout form (iframe/popup) */ createCheckoutForm(options: IyzicoCheckoutOptions): Promise; /** * Retrieve checkout form result */ retrieveCheckoutForm(token: string): Promise; getCheckout(_sessionId: string): Promise; /** * Initialize 3D Secure payment */ initialize3DSPayment(options: { price: string; paidPrice: string; currency: "TRY" | "USD" | "EUR" | "GBP" | "IRR"; installment: number; paymentCard: { cardHolderName: string; cardNumber: string; expireMonth: string; expireYear: string; cvc: string; registerCard?: 0 | 1; }; buyer: IyzicoBuyer; billingAddress: IyzicoAddress; shippingAddress: IyzicoAddress; basketItems: IyzicoBasketItem[]; callbackUrl: string; conversationId?: string; }): Promise; /** * Complete 3D Secure payment after callback */ complete3DSPayment(paymentId: string, conversationId?: string): Promise; /** * Create a refund */ createRefund(options: { paymentTransactionId: string; price: string; currency: "TRY" | "USD" | "EUR" | "GBP" | "IRR"; ip: string; conversationId?: string; }): Promise; /** * Cancel a payment (full refund before settlement) */ cancelPayment(options: { paymentId: string; ip: string; conversationId?: string; }): Promise; /** * Get installment info for a BIN number */ getInstallmentInfo(binNumber: string, price: string): Promise; createSubscription(_options: CreateSubscriptionOptions): Promise; getSubscription(_subscriptionId: string): Promise; updateSubscription(_subscriptionId: string, _options: UpdateSubscriptionOptions): Promise; cancelSubscription(_subscriptionId: string, _cancelAtPeriodEnd?: boolean): Promise; listSubscriptions(_customerId: string): Promise; createPortalSession(_options: CreatePortalOptions): Promise; verifyWebhook(payload: string | Uint8Array, _signature: string): Promise; private mapEventType; } interface IyzicoCheckoutResult { token: string; checkoutFormContent: string; tokenExpireTime: number; paymentPageUrl: string; } interface IyzicoPaymentResult { paymentId: string; status: string; paymentStatus: string; price: string; paidPrice: string; currency: string; installment: number; basketId: string; binNumber: string; lastFourDigits: string; cardAssociation: string; cardFamily: string; cardType: string; fraudStatus: number; raw: unknown; } interface IyzicoThreeDSInitResult { threeDSHtmlContent: string; status: string; } interface IyzicoRefundResult { paymentId: string; paymentTransactionId: string; price: string; status: string; } interface IyzicoCancelResult { paymentId: string; price: string; currency: string; status: string; } interface IyzicoInstallmentResult { installmentDetails: Array<{ binNumber: string; price: string; cardType: string; cardAssociation: string; cardFamilyName: string; force3ds: number; bankCode: number; bankName: string; forceCvc: number; installmentPrices: Array<{ installmentNumber: number; totalPrice: string; installmentPrice: string; }>; }>; } /** * Create an iyzico provider */ declare function createIyzicoProvider(config: IyzicoProviderConfig): IyzicoProvider; export { type IyzicoAddress, type IyzicoBasketItem, type IyzicoBuyer, type IyzicoCancelResult, type IyzicoCheckoutOptions, type IyzicoCheckoutResult, type IyzicoInstallmentResult, type IyzicoPaymentResult, IyzicoProvider, type IyzicoProviderConfig, type IyzicoRefundResult, type IyzicoThreeDSInitResult, createIyzicoProvider };