import type { Double } from 'react-native/Libraries/Types/CodegenTypes'; import { MFCurrencyISO, MFFontFamily, MFFontWeight, MFLanguage, MFRecurringType } from './MFEnums'; import { ProcessedColorValue, processColor } from 'react-native'; //#region InitiatePayment export class MFInitiatePaymentRequest { constructor(invoiceAmount: Double, currencyIso: MFCurrencyISO) { this.InvoiceAmount = invoiceAmount; this.CurrencyIso = currencyIso; } InvoiceAmount: Double; CurrencyIso: MFCurrencyISO; } export class MFInitiatePaymentResponse { PaymentMethods: MFPaymentMethod[] | null = null; } export class MFPaymentMethod { PaymentMethodId: number | null = null; PaymentMethodAr: String | null = null; PaymentMethodEn: String | null = null; PaymentMethodCode: String | null = null; IsDirectPayment: Boolean | null = null; ServiceCharge: Double | null = null; TotalAmount: Double | null = null; CurrencyIso: String | null = null; ImageUrl: string | null = null; IsEmbeddedSupported: Boolean | null = null; PaymentCurrencyIso: String | null = null; } //#endregion //#region SendPayment export class MFSendPaymentRequest { constructor(invoiceValue: number, notificationOption: string, customerName: string) { this.InvoiceValue = invoiceValue; this.CustomerName = customerName; this.NotificationOption = notificationOption; } InvoiceValue: number; NotificationOption: string; CustomerName: string; MobileCountryCode: String | null = null; CustomerMobile: String | null = null; CustomerEmail: String | null = null; DisplayCurrencyIso: String | null = null; Language: MFLanguage = MFLanguage.ENGLISH; CustomerReference: String | null = null; CustomerCivilId: String | null = null; UserDefinedField: String | null = null; CustomerAddress: MFCustomerAddress | null = null; ExpiryDate: String | null = null; InvoiceItems: MFInvoiceItem[] | null = null; WebhookUrl: String | null = null; } export class MFCustomerAddress { constructor(block: String | null, street: String | null, houseBuildingNo: String | null, address: String | null, addressInstructions: String | null) { this.Block = block; this.Street = street; this.HouseBuildingNo = houseBuildingNo; this.Address = address; this.AddressInstructions = addressInstructions; } Block: String | null = null; Street: String | null = null; HouseBuildingNo: String | null = null; Address: String | null = null; AddressInstructions: String | null = null; } export class MFInvoiceItem { constructor(itemName: String, quantity: number, unitPrice: Double) { this.ItemName = itemName; this.Quantity = quantity; this.UnitPrice = unitPrice; } ItemName: String; Quantity: number; UnitPrice: Double; } export class MFSupplier { constructor(supplierCode: number | null, invoiceShare: Double | null, proposedShare: Double | null = null) { this.SupplierCode = supplierCode; this.ProposedShare = proposedShare; this.InvoiceShare = invoiceShare; } SupplierCode: number | null = null; ProposedShare: Double | null = null; InvoiceShare: Double | null = null; } export class MFSendPaymentResponse { InvoiceId: number | null = null; InvoiceURL: String | null = null; CustomerReference: String | null = null; UserDefinedField: String | null = null; } //#endregion //#region ExecutePayment export class MFExecutePaymentRequest { constructor(invoiceValue: number) { this.InvoiceValue = invoiceValue; } InvoiceValue: number; PaymentMethodId: number | null = null; SessionId: String | null = null; CustomerName: String | null = null; DisplayCurrencyIso: String | null = null; MobileCountryCode: String | null = null; CustomerMobile: String | null = null; CustomerEmail: String | null = null; Language: MFLanguage | null = null; CustomerReference: String | null = null; CustomerCivilId: String | null = null; UserDefinedField: String | null = null; CustomerAddress: MFCustomerAddress | null = null; ExpiryDate: String | null = null; InvoiceItems: MFInvoiceItem[] | null = null; Suppliers: MFSupplier[] | null = null; RecurringModel: MFRecurringModel | null = null; ProcessingDetails: MFProcessingDetails | null = null; WebhookUrl: String | null = null; } export class MFExecutePaymentResponse { InvoiceId: number | null = null; IsDirectPayment: Boolean | null = null; PaymentURL: String | null = null; CustomerReference: String | null = null; UserDefinedField: String | null = null; RecurringId: String | null = null; } export class MFRecurringModel { constructor(mFRecurringType: MFRecurringType, iteration: number | null = null) { this.Iteration = iteration; this.RecurringType = mFRecurringType; } RecurringType: MFRecurringType | null = null; IntervalDays: number | null = null; Iteration: number | null = null; } export class MFProcessingDetails { constructor(autoCapture: Boolean | null = null, bypass3DS: Boolean | null = null) { this.AutoCapture = autoCapture; this.Bypass3DS = bypass3DS; } AutoCapture: Boolean | null = null; Bypass3DS: Boolean | null = null; } export class MFPaymentWithTokenRequest { constructor(executePaymentRequest: MFExecutePaymentRequest, token: String, securityCode: String | null = null) { this.ExecutePaymentRequest = executePaymentRequest; this.Token = token; this.SecurityCode = securityCode; } ExecutePaymentRequest: MFExecutePaymentRequest; Token: String; SecurityCode: String | null = null; } //#endregion //#region GetPaymentStatus // MFKeyType export class MFGetPaymentStatusRequest { constructor(key: string, keyType: string) { this.Key = key; this.KeyType = keyType; } // constructor(invoiceId: String = '', paymentId: String = '') { // if (invoiceId === '') { // this.key = paymentId; // this.keyType = MFKeyType.PAYMENTID; // } else if (paymentId === '') { // this.key = invoiceId; // this.keyType = MFKeyType.INVOICEID; // } // } Key: String | null = null; KeyType: String | null = null; } export class MFGetPaymentStatusResponse { InvoiceId: number | null = null; InvoiceStatus: String | null = null; InvoiceReference: String | null = null; CustomerReference: String | null = null; CreatedDate: String | null = null; ExpiryDate: String | null = null; InvoiceValue: Double | null = null; Comments: String | null = null; CustomerName: String | null = null; CustomerMobile: String | null = null; CustomerEmail: String | null = null; UserDefinedField: String | null = null; InvoiceDisplayValue: String | null = null; InvoiceItems: MFInvoiceItem[] | null = null; InvoiceTransactions: MFInvoiceTransaction[] | null = null; Suppliers: MFSupplierItem[] | null = null; RecurringId: String | null = null; } export class MFInvoiceTransaction { TransactionDate: String | null = null; PaymentGateway: String | null = null; ReferenceId: String | null = null; TrackId: String | null = null; TransactionId: String | null = null; PaymentId: String | null = null; AuthorizationId: String | null = null; TransactionStatus: String | null = null; TransationValue: String | null = null; CustomerServiceCharge: String | null = null; DueValue: String | null = null; PaidCurrency: String | null = null; PaidCurrencyValue: String | null = null; Currency: String | null = null; Error: String | null = null; CardNumber: String | null = null; ErrorCode: String | null = null; } export class MFSupplierItem { SupplierCode: number | null = null; SupplierName: String | null = null; InvoiceShare: Double | null = null; ProposedShare: Double | null = null; DepositShare: Double | null = null; } //#endregion //#region InitiateSession export class MFInitiateSessionRequest { constructor(customerIdentifier: string) { this.CustomerIdentifier = customerIdentifier; } CustomerIdentifier: string; SaveToken: Boolean | null; IsRecurring: Boolean; } export class MFInitiateSessionResponse { SessionId: String | null = null; CountryCode: String | null = null; CustomerTokens: CustomerTokens[] = []; } export class CustomerTokens { Token: String | null = null; CardNumber: String | null = null; CardBrand: String | null = null; Is3DSVerified: Boolean = false; } export class MFCallbackResponse { CardBrand: String | null = null; } //#endregion //#region DirectPayment export class MFDirectPaymentRequest { constructor(executePaymentRequest: MFExecutePaymentRequest, token: string | null, card: MFCardRequest | null) { this.ExecutePaymentRequest = executePaymentRequest; this.Token = token; this.Card = card; } ExecutePaymentRequest: MFExecutePaymentRequest; Card: MFCardRequest | null = null; Token: string | null = null; SaveToken: boolean | null = null; Bypass3DS: boolean | null = null; } export class MFCardRequest { constructor(Number: string, ExpiryMonth: string, ExpiryYear: string, SecurityCode: string, CardHolderName: string) { this.Number = Number; this.ExpiryMonth = ExpiryMonth; this.ExpiryYear = ExpiryYear; this.SecurityCode = SecurityCode; this.CardHolderName = CardHolderName; } Number: string; ExpiryMonth: string; ExpiryYear: string; SecurityCode: string; CardHolderName: string; } export class MFDirectPaymentResponse { MfPaymentStatusResponse: MFGetPaymentStatusResponse = new MFGetPaymentStatusResponse(); CardInfoResponse: DirectPaymentResponse = new DirectPaymentResponse(); } export class DirectPaymentResponse { Status: String | null = null; ErrorMessage: String | null = null; PaymentId: String | null = null; Token: String | null = null; RecurringId: String | null = null; CardInfo: CardInfo | null = null; PaymentURL: String | null = null; } export class CardInfo { Number: String | null = null; ExpiryMonth: String | null = null; ExpiryYear: String | null = null; Brand: String | null = null; Issuer: String | null = null; } //#endregion //#region Error export class MFError { code: String | null = null; message: String | null = null; } //#endregion //#region PaymentCardViewConfig export class MFSubmitCardViewResponse { CardBrand: String | null = null; SessionId: String | null = null; CardIdentifier?: String | null = null; CardToken?: String | null = null; } export class MFCardViewStyle { constructor( hideCardIcons: Boolean = false, direction: String = 'ltr', cardHeight: number = 230, input: MFCardViewInput = new MFCardViewInput(), label: MFCardViewLabel = new MFCardViewLabel(), error: MFCardViewError = new MFCardViewError() ) { this.HideCardIcons = hideCardIcons; this.Direction = direction; this.CardHeight = cardHeight; this.Input = input; this.Label = label; this.Error = error; } HideCardIcons: Boolean; Direction: String; CardHeight: number; BackgroundColor: ProcessedColorValue | null | undefined = processColor('#ffffff00'); TokenHeight: number; Input: MFCardViewInput; Text: MFSavedCardText; Label: MFCardViewLabel; Error: MFCardViewError; /** * V3 card view only: whether to show the cardholder-name field. Ignored by the * legacy (V2) MFCardPaymentView. Defaults to true. */ ShowCardholderName: Boolean = true; } export class MFSavedCardText { constructor( saveCardText: String = 'Save card no. for future payments', addCardText: String = 'Use Another Card', deleteAlertText: MFDeleteAlert = new MFDeleteAlert() ) { this.SaveCardText = saveCardText; this.AddCardText = addCardText; this.DeleteAlertText = deleteAlertText; } SaveCardText: String; AddCardText: String; DeleteAlertText: MFDeleteAlert; } export class MFDeleteAlert { constructor( title: String = 'Delete Card', message: String = 'Are you sure you want to remove this Card?', confirm: String = 'Yes', cancel: String = 'No' ) { this.Title = title; this.Message = message; this.Confirm = confirm; this.Cancel = cancel; } Title: String; Message: String; Confirm: String; Cancel: String; } export class MFCardViewInput { constructor( color: ProcessedColorValue | null | undefined = processColor('black'), fontSize: number = 13, fontFamily: MFFontFamily = MFFontFamily.SansSerif, inputHeight: number = 32, inputMargin: number = 0, borderColor: ProcessedColorValue | null | undefined = processColor('#c7c7c7'), borderWidth: number = 1, borderRadius: number = 8, boxShadow: MFBoxShadow = new MFBoxShadow(0, 0, 0, 0, processColor('white')), placeHolder: MFCardViewPlaceHolder = new MFCardViewPlaceHolder() ) { this.Color = color; this.FontSize = fontSize; this.FontFamily = fontFamily; this.InputHeight = inputHeight; this.InputMargin = inputMargin; this.BorderColor = borderColor; this.BorderWidth = borderWidth; this.BorderRadius = borderRadius; this.BoxShadow = boxShadow; this.PlaceHolder = placeHolder; } Color: ProcessedColorValue | null | undefined; FontSize: number; FontFamily: MFFontFamily; BackgroundColor: ProcessedColorValue | null | undefined = processColor('#ffffff00'); InputHeight: number; InputMargin: number; BorderColor: ProcessedColorValue | null | undefined; BorderWidth: number; BorderRadius: number; OuterRadius: number | null; BoxShadow: MFBoxShadow; PlaceHolder: MFCardViewPlaceHolder; } export class MFCardViewPlaceHolder { constructor(holderName: String = 'Name On Card', cardNumber: String = 'Number', expiryDate: String = 'MM / YY', securityCode: String = 'CVV') { this.HolderName = holderName; this.CardNumber = cardNumber; this.ExpiryDate = expiryDate; this.SecurityCode = securityCode; } Color: ProcessedColorValue | null | undefined = processColor('#d3d3d3'); HolderName: String; CardNumber: String; ExpiryDate: String; SecurityCode: String; } export class MFCardViewLabel { constructor( display: Boolean = false, color: ProcessedColorValue | null | undefined = processColor('black'), fontSize: number = 13, fontFamily: MFFontFamily = MFFontFamily.SansSerif, fontWeight: MFFontWeight = MFFontWeight.Normal, text: MFCardViewText = new MFCardViewText() ) { this.Display = display; this.Color = color; this.FontSize = fontSize; this.FontFamily = fontFamily; this.FontWeight = fontWeight; this.Text = text; } Display: Boolean; Color: ProcessedColorValue | null | undefined; FontSize: number; FontFamily: MFFontFamily; FontWeight: MFFontWeight; Text: MFCardViewText; } export class MFCardViewText { constructor( holderName: String = 'Card Holder Name', cardNumber: String = 'Card Number', expiryDate: String = 'Expiry Date', securityCode: String = 'Security Code' ) { this.HolderName = holderName; this.CardNumber = cardNumber; this.ExpiryDate = expiryDate; this.SecurityCode = securityCode; } HolderName: String; CardNumber: String; ExpiryDate: String; SecurityCode: String; } export class MFCardViewError { constructor(borderColor: ProcessedColorValue | null | undefined = processColor('red'), borderRadius: number = 8, boxShadow: MFBoxShadow = new MFBoxShadow()) { this.BorderColor = borderColor; this.BorderRadius = borderRadius; this.BoxShadow = boxShadow; } BorderColor: ProcessedColorValue | null | undefined; BorderRadius: number; BoxShadow: MFBoxShadow; } export class MFBoxShadow { constructor( hOffset: number = 0, vOffset: number = 0, blur: number = 0, spread: number = 0, color: ProcessedColorValue | null | undefined = processColor('white') ) { this.HOffset = hOffset; this.VOffset = vOffset; this.Blur = blur; this.Spread = spread; this.Color = color; } HOffset: number; VOffset: number; Blur: number; Spread: number; Color: ProcessedColorValue | null | undefined; } export class MFApplePayStyle { constructor( height: number | null | undefined, borderRadius: number | null | undefined, buttonText: String | null | undefined, hideLoadingIndicator: Boolean | undefined ) { this.Height = height; this.BorderRadius = borderRadius; this.ButtonText = buttonText; this.HideLoadingIndicator = hideLoadingIndicator; } Height: number | null | undefined; BorderRadius: number | null | undefined; ButtonText: String | null | undefined; HideLoadingIndicator: Boolean | null | undefined; VendorName: String | null | undefined; } //#endregion //#region Apple Pay Native export class MFApplePayRequest { constructor(merchantId: string, companyName: string, amount: number, currencyCode: string) { this.MerchantId = merchantId; this.CompanyName = companyName; this.Amount = amount; this.CurrencyCode = currencyCode; } MerchantId: string; CompanyName: string; Amount: number; CurrencyCode: string; CustomerIdentifier: string | null = null; SupportedCountries: [string] | null = null; SupportedNetworks: [string] | null = null; } export class MFApplePayToken { Token: string; } //#endregion //#region GooglePayButton export class MFGooglePayRequest { constructor(totalPrice: String, merchantId: String, merchantName: String, countryCode: String, currencyIso: String) { this.TotalPrice = totalPrice; this.MerchantId = merchantId; this.MerchantName = merchantName; this.CountryCode = countryCode; this.CurrencyIso = currencyIso; } TotalPrice: String; MerchantId: String; MerchantName: String; CountryCode: String; CurrencyIso: String; } export class MFGooglePayButtonStyle {} //#endregion //#region V3 Card View // // Types for the V3 embedded card view (see src/MFCardV3.tsx). Field names are // PascalCase to match the native SDK's REST models and the rest of this bridge. // These are read-only response shapes produced by the native serializers; the // same shapes are emitted on iOS and (in future) Android so the JS is shared. /** Order block echoed inside a session. */ export interface MFV3Order { Amount?: number; Currency?: string; ExternalIdentifier?: string; } /** A saved card token attached to a customer, returned inside a session. */ export interface MFV3SavedCard { Is3DSVerified?: boolean; Token?: string; Number?: string; Brand?: string; TokenType?: string; NameOnCard?: string; ExpiryMonth?: string; ExpiryYear?: string; } /** Customer block returned inside a session response. */ export interface MFV3SessionCustomer { Reference?: string; Cards?: MFV3SavedCard[]; } /** * A V3 session. Returned by MFV3Session.create/createVerify (SDK path) or built by * MFV3Session.fromBackend(sessionId, encryptionKey?) (backend path). Pass it to * MFCardViewV3.load(). * * Note: SessionId must be the full country-prefixed id (e.g. "KWT-abc123"). */ export interface MFV3SessionData { SessionId: string; SessionExpiry?: string; /** Used by the SDK to decrypt the inline (non-3DS) result. */ EncryptionKey?: string; OperationType?: string; Order?: MFV3Order; Customer?: MFV3SessionCustomer; } /** Card details returned by the widget in COLLECT_DETAILS mode. */ export interface MFV3CardDetails { Brand?: string; PanHash?: string; Token?: string; Number?: string; NameOnCard?: string; ExpiryYear?: string; ExpiryMonth?: string; Issuer?: string; IssuerCountry?: string; FundingMethod?: string; ProductName?: string; } /** User-defined fields echoed with an invoice. */ export interface MFV3ResultMetaData { UDF1?: string; UDF2?: string; UDF3?: string; UDF4?: string; UDF5?: string; } export interface MFV3Invoice { Id?: string; Status?: string; Reference?: string; CreationDate?: string; ExpirationDate?: string; ExternalIdentifier?: string; UserDefinedField?: string; MetaData?: MFV3ResultMetaData; } export interface MFV3TransactionError { Code?: string; Message?: string; } export interface MFV3IP { Address?: string; Country?: string; } export interface MFV3TransactionCard { NameOnCard?: string; Number?: string; PanHash?: string; ExpiryMonth?: string; ExpiryYear?: string; Brand?: string; Issuer?: string; IssuerCountry?: string; FundingMethod?: string; Token?: string; } export interface MFV3Transaction { Id?: string; Status?: string; PaymentMethod?: string; PaymentId?: string; ReferenceId?: string; TrackId?: string; AuthorizationId?: string; TransactionDate?: string; ECI?: string; IP?: MFV3IP; Error?: MFV3TransactionError; Card?: MFV3TransactionCard; } export interface MFV3PaymentCustomer { Name?: string; Mobile?: string; Email?: string; } export interface MFV3Amount { BaseCurrency?: string; ValueInBaseCurrency?: string; ServiceCharge?: string; ServiceChargeVAT?: string; ReceivableAmount?: string; DisplayCurrency?: string; ValueInDisplayCurrency?: string; PayCurrency?: string; ValueInPayCurrency?: string; } export interface MFV3Supplier { Code?: number; Name?: string; InvoiceShare?: string; ProposedShare?: string; DepositShare?: string; } /** Final payment status for a COMPLETE_PAYMENT flow. */ export interface MFV3PaymentDetails { Invoice?: MFV3Invoice; Transaction?: MFV3Transaction; Customer?: MFV3PaymentCustomer; Amount?: MFV3Amount; Suppliers?: MFV3Supplier[]; } /** Card verification outcome (VERIFY flow). */ export interface MFV3VerifyCard { Number?: string; ExpiryMonth?: string; ExpiryYear?: string; Brand?: string; PanType?: string; Issuer?: string; PanHash?: string; Token?: string; NameOnCard?: string; IssuerCountry?: string; FundingMethod?: string; ProductName?: string; IsValidCard?: boolean; Is3DSVerified?: boolean; } /** Result of GET /v3/sessions/{id} for a VERIFY session. */ export interface MFV3GetSessionData { SessionExpiry?: string; IsUsed?: boolean; OperationType?: string; Order?: MFV3Order; CustomerReference?: string; Card?: MFV3VerifyCard; TransactionResult?: MFV3PaymentDetails; } /** * Outcome of MFCardViewV3.submit(), discriminated by `type`: * - completed: COMPLETE_PAYMENT resolved to a final status. * - cardCollected: COLLECT_DETAILS tokenized the card (charge it on your backend). * - pendingBackendResolution: the SDK has no key/paymentId; resolve on your backend. */ export type MFV3PaymentResult = | { type: 'completed'; details: MFV3PaymentDetails } | { type: 'cardCollected'; sessionId?: string; card: MFV3CardDetails } | { type: 'pendingBackendResolution'; paymentData?: string; redirectionUrl?: string; paymentId?: string }; /** * Outcome of MFCardViewV3.verify(), discriminated by `type`: * - verified: resolved via GET /v3/sessions/{id}; inspect session.Card.IsValidCard. * - pendingBackendResolution: the SDK has no key; resolve on your backend. */ export type MFV3VerifyResult = | { type: 'verified'; session: MFV3GetSessionData } | { type: 'pendingBackendResolution'; sessionId: string; redirectionUrl?: string }; /** A widget lifecycle event delivered through MFCardViewV3 onWidgetEvent. */ export interface MFV3WidgetEvent { name: string; id?: number; paymentMethodName?: string; } //#endregion