UNPKG

shipy-sdk-js

Version:

Shipy Payment Gateway SDK for JavaScript/TypeScript

86 lines (85 loc) 2.57 kB
/** * Supported currency types for payments */ export type Currency = 'TRY' | 'EUR' | 'USD' | 'GBP'; /** * Supported page languages for the payment interface */ export type PageLanguage = 'TR' | 'EN' | 'DE' | 'AR' | 'ES' | 'FR'; /** * Supported languages for payment confirmation emails */ export type MailLanguage = 'TR' | 'EN'; /** * Supported payment types */ export type PaymentType = 'credit_card' | 'mobile' | 'eft'; /** * Supported installment options * 0: Single payment * 3,6,9,12: Number of installments */ export type Installment = 0 | 3 | 6 | 9 | 12; /** * Base payment request parameters */ export interface PaymentRequest { /** IP address of the user making the payment */ usrIp: string; /** Full name of the user making the payment */ usrName: string; /** Address of the user making the payment */ usrAddress: string; /** Phone number of the user making the payment */ usrPhone: string; /** Email address of the user making the payment */ usrEmail: string; /** Payment amount */ amount: number; /** Unique identifier for the payment request */ returnID: string; /** API key for authentication */ apiKey: string; } /** * Extended payment request parameters for credit card payments. * Includes optional fields for currency, page language, mail language, and installment options. */ export interface CreditPaymentRequest extends PaymentRequest { /** Optional currency for the payment */ currency?: Currency; /** Optional language for the payment page */ pageLang?: PageLanguage; /** Optional language for the confirmation email */ mailLang?: MailLanguage; /** Optional number of installments */ installment?: Installment; } /** * Response from payment request */ export interface PaymentResponse { /** Status of the payment request */ status: 'success' | 'error'; /** Error message if status is 'error' */ message?: string; /** Payment page URL if status is 'success' */ link?: string; } /** * Callback data received from Shipy after payment */ export interface CallbackData { /** Unique payment ID generated by Shipy */ paymentID: string; /** Original returnID sent with the payment request */ returnID: string | number; /** Type of payment that was made */ paymentType: PaymentType; /** Amount that was paid */ paymentAmount: number; /** Currency of the payment */ paymentCurrency: Currency; /** Hash for verifying the callback authenticity */ paymentHash: string; }