iOS Models Documentation
This documentation provides detailed information about the models used in the iOS SDK. Each model includes a code snippet and a comprehensive description of its properties and usage.
Here is the Swift documentation for the models in the same style as your React Native documentation:
1. Language
public enum Language: String, Codable {
case arabic = "ar"
case english = "en"
case french = "fr"
}
- Description: Enum representing different languages supported by the SDK.
- Enum Cases:
- arabic: Arabic language.
- english: English language.
- french: French language.
2. LogLevel
public enum LogLevel: String, Codable {
case verbose = "VERBOSE"
case debug = "DEBUG"
case info = "INFO"
case warn = "WARN"
case error = "ERROR"
case assertion = "ASSERTION"
}
- Description: Enum representing different levels of logging.
- Enum Cases:
- verbose: Verbose logging.
- debug: Debug-level logging.
- info: Informational messages.
- warn: Warning messages.
- error: Error messages.
- assertion: Assertion failures.
3. DiscountType
public enum DiscountType: String, Codable {
case amount
case percentage
}
- Description: Enum representing the type of discount.
- Enum Cases:
- amount: The discount is a fixed amount.
- percentage: The discount is a percentage of the total.
4. DiscountItem
public struct DiscountItem: Codable {
public let title: [Language: String]?
public let type: DiscountType?
public let value: String?
}
- Description: Represents a discount applied to a fee or intent.
- Properties:
- title: A dictionary of titles by language, describing the discount.
- type: The type of discount (
DiscountType
). - value: The value of the discount.
5. DiscountData
public struct DiscountData: Codable {
public let discount: DiscountItem?
public let amount: String?
}
- Description: Represents data related to a discount applied to an intent.
- Properties:
- discount: The
DiscountItem
associated with the intent. - amount: The amount after the discount is applied.
- discount: The
6. FeeItem
public struct FeeItem: Codable {
public let title: [Language: String]?
public let value: String?
public let discount: DiscountItem?
}
- Description: Represents a fee item associated with an intent.
- Properties:
- title: A dictionary of titles by language, describing the fee.
- value: The value of the fee.
- discount: The discount applied to this fee, if any.
7. FeesData
public struct FeesData: Codable {
public let amount: String?
public let fees: [FeeItem]?
}
- Description: Represents the fees data associated with the intent.
- Properties:
- amount: The total amount of the fees.
- fees: A list of
FeeItem
objects representing individual fees.
8. ErrorType
public enum ErrorType: String, Codable {
case cancelled
case cardValidation = "card_validation"
case network
case unknown
case notCompatibleWithApplePay
case applePayTransactionFailed
}
- Description: Enum representing different types of errors that can occur in the SDK.
- Enum Cases:
- cancelled: The operation was cancelled.
- cardValidation: Error related to card validation.
- network: Network-related error.
- unknown: An unknown error.
- notCompatibleWithApplePay: Device is not compatible with Apple Pay.
- applePayTransactionFailed: Apple Pay transaction failed.
9. ErrorInfo
public struct ErrorInfo: Codable {
public let key: String
public let message: String
}
- Description: Represents detailed information about an error.
- Properties:
- key: The error key or code.
- message: The error message.
10. MHError
public struct MHError: Error, Codable {
public let type: ErrorType
public let message: String
public let errors: [ErrorInfo]
}
- Description: Represents an error occurring in the SDK.
- Properties:
- type: The type of error (
ErrorType
). - message: A human-readable error message.
- errors: An array of
ErrorInfo
objects providing details about the error.
- type: The type of error (
11. AmountData
public struct AmountData: Codable {
public let value: String?
public let formatted: Double?
public let currency: String?
public let maxPayoutAmount: Double?
}
- Description: Represents the monetary value related to an intent.
- Properties:
- value: The raw value of the amount.
- formatted: The formatted amount value.
- currency: The currency code (e.g., "USD").
- maxPayoutAmount: The maximum payout amount allowed.
12. CardTokenData
public struct CardTokenData: Codable {
public let bin: String?
public let brand: String?
public let cardHolderName: String?
public let country: String?
public let expiryMonth: String?
public let expiryYear: String?
public let issuer: String?
public let last4: String?
public let logo: String?
public let paymentMethods: [String]?
public let requiresCvv: Bool?
}
- Description: Represents token data for a card used in payment processing.
- Properties:
- bin: Bank Identification Number of the card.
- brand: Brand of the card (e.g., Visa, MasterCard).
- cardHolderName: Name of the cardholder.
- country: Country where the card was issued.
- expiryMonth: Expiry month of the card.
- expiryYear: Expiry year of the card.
- issuer: Issuer of the card.
- last4: Last four digits of the card number.
- logo: Logo associated with the card brand.
- paymentMethods: List of payment methods associated with the card.
- requiresCvv: Indicates if CVV is required for transactions.
13. OptionItem
public struct OptionItem: Codable {
public let label: String
public let value: String
}
- Description: Represents an option item in a selectable list within an input field.
- Properties:
- label: The label displayed to the user.
- value: The value associated with the option.
14. InputFieldType
public enum InputFieldType: String, Codable {
case text
case email
case phoneNumber = "phone_number"
case dateField = "date_field"
case numberField = "number_field"
case choiceField = "choice_field"
}
- Description: Enum representing the type of an input field.
- Enum Cases:
- text: Standard text input field.
- email: Email input field.
- phoneNumber: Phone number input field.
- dateField: Date input field.
- numberField: Numeric input field.
- choiceField: Dropdown or select input field.
15. InputField
public struct InputField: Codable {
public let type: InputFieldType
public let name: String?
public let value: String?
public let label: String?
public let maxLength: Int?
public let isRequired: Bool
public let optionsList: [OptionItem]?
public let optionsMap: [String: [OptionItem]]?
public let hint: String?
public let minLength: Int?
public let readOnly: Bool
public let dependsOn: String?
}
- Description: Represents a field in a form used for collecting user input.
- Properties:
- type: Type of the input field (
InputFieldType
). - name: Name of the input field.
- value: Current value of the input field.
- label: Label for the input field.
- maxLength: Maximum length of the input.
- isRequired: Indicates if the field is required.
- optionsList: List of selectable options (
OptionItem[]
). - optionsMap: Map of selectable options.
- hint: Hint message for the input field.
- minLength: Minimum length of the input.
- readOnly: Indicates if the field is read-only.
- dependsOn: Specifies another field that this field depends on.
- type: Type of the input field (
16.IntentStatus
public enum IntentStatus: String, Codable {
case processed = "PROCESSED"
case unprocessed = "UNPROCESSED"
case timeExpired = "TIME_EXPIRED"
case closed = "CLOSED"
}
- Description: Enum representing the possible statuses of an intent.
- Enum Cases:
- processed: The intent has been processed.
- unprocessed: The intent remains unprocessed.
- timeExpired: The intent has expired due to time constraints.
- closed: The intent has been closed.
17. IntentType
public enum IntentType: String, Codable {
case payment
case payout
}
- Description: Enum representing the type of intent.
- Enum Cases:
- payment: Represents a payment intent.
- payout: Represents a payout intent.
18. Intent
public struct Intent: Codable {
public let id: String?
public let amount: AmountData?
public let secret: String?
public let isLive: Bool?
public let status: IntentStatus?
public let expirationDate: String?
public let fees: [FeeItem]?
public let totalDiscount: String?
public let subtotalAmount: String?
}
- Description: Represents a payment or payout intent.
- Properties:
- id: The unique identifier for the intent.
- amount: The associated amount data for the intent.
- secret: A secret key for the intent.
- isLive: Indicates if the intent is in live mode.
- status: The current status of the intent.
- expirationDate: The expiration date of the intent.
- fees: A list of fees associated with the intent.
- totalDiscount: The total discount applied to the intent.
- subtotalAmount: The subtotal amount before discounts and fees.
19. Transaction
public struct Transaction: Codable {
public let id: String?
public let createdDate: String?
public let status: String?
public let amount: Double?
public let amountCurrency: String?
public let method: String?
public let methodName: String?
public let billingData: String?
public let customFields: String?
public let customFormAnswers: String?
public let externalActionMessage: [String]?
public let providerTransactionFields: String?
}
- Description: Represents a transaction in the intent process.
- Properties:
- id: The unique identifier for the transaction.
- createdDate: The date the transaction was created.
- status: The status of the transaction.
- amount: The amount involved in the transaction.
- amountCurrency: The currency of the transaction amount.
- method: The method used in the transaction.
- methodName: The name of the payment method.
- billingData: Billing data associated with the transaction.
- customFields: Custom fields related to the transaction.
- customFormAnswers: Custom form answers provided during the transaction.
- externalActionMessage: External action messages, if any.
- providerTransactionFields: Fields specific to the transaction provider.
20. ProductItem
public struct ProductItem: Codable {
public let name: String?
public let type: String?
public let amount: String?
public let category: String?
public let quantity: Int?
public let description: String?
public let subcategory: String?
public let referenceId: String?
}
- Description: Represents a product item associated with an intent.
- Properties:
- name: The name of the product item.
- type: The type of the product item.
- amount: The amount associated with the product item.
- category: The category of the product item.
- quantity: The quantity of the product item.
- description: A description of the product item.
- subcategory: The subcategory of the product item.
- referenceId: A reference ID associated with the product item.
21. IntentDetails
public struct IntentDetails: Codable {
public let selectedMethod: String?
public let wallet: Double?
public let intent: Intent?
public let productItems: [ProductItem]?
public let state: IntentStateDetails?
public let transaction: Transaction?
public let id: String?
}
- Description: Provides detailed information about an intent.
- Properties:
- selectedMethod: The payment method selected for the intent.
- wallet: The wallet balance associated with the current customer.
- intent: The
Intent
object containing core details of the intent. - productItems: A list of product items related to the intent.
- state: The current state of the intent (
IntentStateDetails
). - transaction: Details about the transaction (
Transaction
). - id: The unique identifier for the intent.
22. MethodType
public enum MethodType: String, Codable {
case expressMethod
case customerBalance
case savedCard
case paymentMethod
case payoutMethod
}
- Description: Enum representing different types of methods available for an intent.
- Enum Cases:
- expressMethod: Represents an express payment method.
- customerBalance: Represents a customer balance method.
- savedCard: Represents a saved card method.
- paymentMethod: Represents a standard payment method.
- payoutMethod: Represents a payout method.
23. CustomerBalance
public struct CustomerBalance: Codable {
public let balance: Double?
public let id: String?
public let icon: String?
public let isSelected: Bool?
public let type: MethodType?
}
- Description: Represents a customer balance available for use in an intent.
- Properties:
- balance: The balance amount.
- id: The unique identifier of the customer balance.
- icon: An icon associated with the balance.
- isSelected: Indicates if this balance is selected.
- type: The type of method (
MethodType
).
24. PaymentMethod
public struct PaymentMethod: Codable {
public let id: String?
public let title: String?
public let isSelected: Bool?
public let confirmationRequired: Bool?
public let icons: [String]?
public let type: MethodType?
public let requiredBillingData: [InputField]?
}
- Description: Represents a payment method available for the user.
- Properties:
- id: The unique identifier of the payment method.
- title: The title or name of the payment method.
- isSelected: Indicates if this method is selected.
- confirmationRequired: Indicates if confirmation is required for this method.
- icons: Icons associated with the payment method.
- type: The type of method (
MethodType
). - requiredBillingData: A list of input fields required for billing data (
InputField[]
).
25. PayoutMethod
public struct PayoutMethod: Codable {
public let id: String?
public let title: String?
public let isSelected: Bool?
public let confirmationRequired: Bool?
public let icons: [String]?
public let type: MethodType?
public let requiredBillingData: [InputField]?
}
- Description: Represents a payout method available for the user.
- Properties:
- id: The unique identifier of the payout method.
- title: The title or name of the payout method.
- isSelected: Indicates if this method is selected.
- confirmationRequired: Indicates if confirmation is required for this method.
- icons: Icons associated with the payout method.
- type: The type of method (
MethodType
). - requiredBillingData: A list of input fields required for billing data (
InputField[]
).
26. ExpressMethod
public struct ExpressMethod: Codable {
public let id: String?
public let title: String?
public let isSelected: Bool?
public let confirmationRequired: Bool?
public let icons: [String]?
public let type: MethodType?
public let requiredBillingData: [InputField]?
}
- Description: Represents an express payment method.
- Properties:
- id: The unique identifier of the express method.
- title: The title or name of the express method.
- isSelected: Indicates if this method is selected.
- confirmationRequired: Indicates if confirmation is required for this method.
- icons: Icons associated with the express method.
- type: The type of method (
MethodType
). - requiredBillingData: A list of input fields required for billing
data (InputField[]
).
27. CvvConfig
public struct CvvConfig: Codable {
public let digitsCount: Int?
}
- Description: Configuration details for entering the CVV during a transaction.
- Properties:
- digitsCount: The number of digits required for the CVV.
28. SavedCard
public struct SavedCard: Codable {
public let id: String?
public let brand: String?
public let last4: String?
public let expiryMonth: String?
public let expiryYear: String?
public let country: String?
public let logo: String?
public let requireCvv: Bool?
public let cvvConfig: CvvConfig?
public let type: MethodType?
public let first6Digits: String?
}
- Description: Represents a saved card used in transactions.
- Properties:
- id: The unique identifier of the saved card.
- brand: The brand of the card (e.g., Visa, MasterCard).
- last4: The last four digits of the card number.
- expiryMonth: The expiry month of the card.
- expiryYear: The expiry year of the card.
- country: The country where the card was issued.
- logo: The logo associated with the card brand.
- requireCvv: Indicates if CVV is required for this card.
- cvvConfig: Configuration related to CVV input (
CvvConfig
). - type: The type of method (
MethodType
). - first6Digits: The first six digits of the saved card number.
29. IntentMethods
public struct IntentMethods: Codable {
public let customerBalances: [CustomerBalance]?
public let paymentMethods: [PaymentMethod]?
public let expressMethods: [ExpressMethod]?
public let savedCards: [SavedCard]?
public let payoutMethods: [PayoutMethod]?
}
- Description: Represents different payment methods available for an intent.
- Properties:
- customerBalances: A list of available customer balances.
- paymentMethods: A list of available payment methods.
- expressMethods: A list of available express methods.
- savedCards: A list of saved cards.
- payoutMethods: A list of available payout methods.
30. IntentResult
public struct MethodsResult: Codable {
public let methods: IntentMethods?
public let intentData: IntentDetails?
}
- Description: Represents the result of available methods for an intent.
- Properties:
- methods: Contains the available payment methods (
IntentMethods
). - intentData: Provides detailed information about the intent (
IntentDetails
).
- methods: Contains the available payment methods (
31. IntentStateDetails (Updated)
public enum IntentStateDetails: Codable {
case methodSelection(methods: IntentMethods?)
case intentForm
case intentProcessed
case transactionWaitingUserAction
case transactionFailed(recommendedMethods: IntentMethods?)
case expired
case closed
case formFields(tokenizeCardInfo: TokenizeCardInfo?, billingFields: [InputField]?, shippingFields: [InputField]?)
case redirectToURL(url: String?, renderStrategy: RenderStrategy?)
case savedCardCVV(cvvField: InputField, cardTokenData: CardTokenData?)
case cardIntentSuccess
case cardIntentFailed
case nativePay(nativePayData: NativePayData?)
case installmentPlans(plans: [InstallmentPlan]?)
}
- Description: Enum representing different states that an intent can be in during the payment or payout process.
- Enum Cases:
- methodSelection: User is selecting a payment method.
- intentForm: The form is rendered for user input.
- intentProcessed: The intent has been successfully processed.
- transactionWaitingUserAction: The transaction is waiting for user action.
- transactionFailed: The transaction failed and might provide recommended methods to retry.
- expired: The intent has expired.
- closed: The intent has been closed.
- formFields: Form fields related to card tokenization or billing/shipping information.
- redirectToURL: URL rendering or redirect required for the intent.
- savedCardCVV: The user is entering the CVV for a saved card.
- cardIntentSuccess: The card intent has been successfully processed.
- cardIntentFailed: The card intent failed.
- nativePay: Using a native payment method such as Apple Pay.
- installmentPlans: User is selecting an installment plan from available options.
MethodSelection
case methodSelection(methods: IntentMethods?)
- Description: Represents the state where the user selects a payment method from the available options.
- Properties:
- methods: The available methods for selection (
IntentMethods?
).
- methods: The available methods for selection (
IntentForm
case intentForm
- Description: Represents the state where a form is displayed to the user for entering payment or other details..
IntentProcessed
case intentProcessed
- Description: Represents the state where the intent has been processed successfully..
TransactionWaitingUserAction
case transactionWaitingUserAction
- Description: Represents the state where the transaction is waiting for user action (e.g., confirmation or additional input)..
TransactionFailed
case transactionFailed(recommendedMethods: IntentMethods?)
- Description: Represents the state where the transaction has failed.
- Properties:
- recommendedMethods: Optional recommended methods for retrying the transaction (
IntentMethods?
).
- recommendedMethods: Optional recommended methods for retrying the transaction (
Expired
case expired
- Description: Represents the state where the intent has expired due to time constraints or other conditions..
Closed
case closed
- Description: Represents the state where the intent has been closed.
FormFields
case formFields(tokenizeCardInfo: TokenizeCardInfo?, billingFields: [InputField]?, shippingFields: [InputField]?)
- Description: Represents the state where form fields (e.g., billing, shipping, or card details) are required for the intent.
- Properties:
- tokenizeCardInfo: Information for tokenizing a card (
TokenizeCardInfo?
). - billingFields: A list of billing input fields (
[InputField]?
). - shippingFields: A list of shipping input fields (
[InputField]?
).
- tokenizeCardInfo: Information for tokenizing a card (
RedirectToURL
case redirectToURL(url: String?, renderStrategy: RenderStrategy?)
- Description: Represents the state where a URL needs to be rendered or the user needs to be redirected to it.
- Properties:
- url: The URL to render or redirect to (
String?
). - renderStrategy: The strategy for rendering the URL (e.g., iframe, popup) (
RenderStrategy?
).
- url: The URL to render or redirect to (
SavedCardCVV
case savedCardCVV(cvvField: InputField, cardTokenData: CardTokenData?)
- Description: Represents the state where the user is required to enter the CVV for a saved card.
- Properties:
- cvvField: The CVV input field (
InputField
). - cardTokenData: Token data for the saved card (
CardTokenData?
).
- cvvField: The CVV input field (
CardIntentSuccess
case cardIntentSuccess
- Description: Represents the state where the card intent has been successfully processed..
CardIntentFailed
case cardIntentFailed
- Description: Represents the state where the card intent has failed..
NativePay
case nativePay(nativePayData: NativePayData?)
- Description: Represents the state where a native payment method (e.g., Apple Pay) is used for the transaction.
- Properties:
- nativePayData: Data related to native payment methods (
NativePayData?
).
- nativePayData: Data related to native payment methods (
InstallmentPlans
case installmentPlans(plans: [InstallmentPlan]?)
- Description: Represents the state where the user is required to select an installment plan from the available options.
- Properties:
- plans: A list of available installment plans (
[InstallmentPlan]?
)
- plans: A list of available installment plans (
32. MethodMetaData
public struct MethodMetaData: Codable {
public let cvv: String?
}
- Description: Contains metadata related to a payment method, such as CVV.
- Properties:
- cvv: The CVV code for a card.
33. RenderStrategy
public enum RenderStrategy: String, Codable {
case iframe
case popupIFrame = "popup_iframe"
case redirect
case none
}
- Description: Enum representing different strategies for rendering web content within the SDK.
- Enum Cases:
- iframe: Content is rendered within an iframe.
- popupIFrame: Content is rendered within a popup iframe.
- redirect: Content is rendered via a URL redirect.
- none: No rendering strategy is applied.
34. SaveCardCheckbox
public struct SaveCardCheckbox: Codable {
public let mandatory: Bool?
public let show: Bool?
}
- Description: Represents the configuration for the save card checkbox.
- Properties:
- mandatory: Indicates if saving the card is mandatory.
- show: Indicates if the save card checkbox should be shown.
35. TokenizeCardInfo
public struct TokenizeCardInfo: Codable {
public let accessToken: String?
public let isLive: Bool?
public let saveCard: Bool?
public let saveCardCheckboxMandatory: SaveCardCheckbox?
}
- Description: Represents the data needed to tokenize a card in the payment process.
- Properties:
- accessToken: An access token used for tokenizing the card.
- isLive: Indicates if the card is in live mode.
- saveCard: Indicates if the card should be saved.
- saveCardCheckboxMandatory: Configuration for the save card checkbox (
SaveCardCheckbox
).
36. NativePayData and ApplePayData
public enum NativePayData: Codable {
case applePay(ApplePayData)
}
public struct ApplePayData: Codable {
public let countryCode: String?
public let merchantId: String?
public let currencyCode: String?
public let amount: Float?
public let supportedNetworks: [String]?
}
- Description: Contains data necessary for configuring an Apple Pay transaction.
- Properties:
- countryCode: The country code for the transaction (e.g., "US").
- merchantId: The merchant identifier for Apple Pay.
- currencyCode: The currency code for the transaction (e.g., "USD").
- amount: The amount to be charged.
- supportedNetworks: A list of supported networks for Apple Pay (e.g., Visa, MasterCard).
37. CardFieldType
public enum CardFieldType: String, Codable {
case cardNumber = "card_number"
case cardHolderName = "card_holder_name"
case expireMonth = "expiry_month"
case expireYear = "expiry_year"
case cvv
}
- Description: Enum representing different types of card fields used in forms.
- Enum Cases:
- cardNumber: Represents the card number field.
- cardHolderName: Represents the cardholder’s name field.
- expireMonth: Represents the expiration month field.
- expireYear: Represents the expiration year field.
- cvv: Represents the CVV field (Card Verification Value).
38. CardInputFieldState
public struct CardInputFieldState: Codable {
public let isValid: Bool?
public let errorMessage: String?
public let isOnFocused: Bool
public let inputLength: Int
}
- Description: Represents the state of a card input field.
- Properties:
- isValid: A boolean indicating whether the input in the field is valid.
- errorMessage: An optional string that contains an error message if the input is invalid.
- isOnFocused: A boolean indicating whether the input in the field is on focus.
- inputLength: An integer value indicates the length of the input.
39. VaultData
public struct VaultData: Codable {
public let firstSixDigits: String?
public let lastFourDigits: String?
public let cardScheme: String?
public let cardHolderName: String?
public let expiryYear: String?
public let expiryMonth: String?
public let isLive: Bool?
public let accessToken: String?
public let cardToken: String?
public let cvv: String?
public let saveCard: Bool?
public let fingerprint: String?
}
- Description: Represents the data stored in the vault for a card used in payment processing.
- Properties:
- firstSixDigits: The first six digits of the card number.
- lastFourDigits: The last four digits of the card number.
- cardScheme: The scheme of the card (e.g., Visa, MasterCard).
- cardHolderName: The name of the cardholder.
- expiryYear: The expiry year of the card.
- expiryMonth: The expiry month of the card.
- isLive: Indicates if the card is in live mode.
- accessToken: An access token associated with the card.
- cardToken: A token representing the card.
- cvv: The CVV code for the card.
- saveCard: Indicates if the card should be saved.
- fingerprint: A fingerprint associated with the card for additional security.
40. Brand
public enum Brand: String, Codable {
case visa
case mastercard
case mada
case unknown
}
- Description: Enum representing different card brands.
- Enum Cases:
- visa: Visa card brand.
- mastercard: MasterCard brand.
- mada: Mada card brand.
- unknown: Unknown card brand.
41. CardBrand
public struct CardBrand: Codable {
public let first6Digits: String
public let brand: Brand
public let brandIconUrl: String
}
- Description: Represents the card brand information based on the first six digits.
- Properties:
- first6Digits: The first six digits of the card number.
- brand: The brand of the card (
Brand
enum). - brandIconUrl: The URL of the brand’s icon.:
42. InstallmentPlan
public struct InstallmentPlan: Codable {
public var id: String?
public var installmentPeriod: Int?
public var interestRate: Double?
public var amount: AmountData?
public var upfrontFees: Double?
}
- Description: Represents an installment plan option available for selection.
- Properties:
- id: The unique identifier of the installment plan.
- installmentPeriod: The number of periods over which payments will be made.
- interestRate: The interest rate applied to the installment plan.
- amount: The amount data associated with the installment plan (
AmountData
). - upfrontFees: Any upfront fees required for the installment plan.
43. InstallmentPlanData
public struct InstallmentPlanData: Codable {
public var id: String?
public var issuerCode: String?
}
- Description: Represents data related to a selected installment plan, including the plan ID and issuer code.
- Properties:
- id: The unique identifier of the selected installment plan.
- issuerCode: The code of the issuer providing the installment plan.
Updated 19 days ago