Skip to main content
PrimerFormRedirectScope manages payment methods that collect user input (OTP code or phone number) before completing payment in an external app (e.g., BLIK, MBWay).

Declaration

@MainActor
public protocol PrimerFormRedirectScope: PrimerPaymentMethodScope where State == PrimerFormRedirectState

Properties

PropertyTypeDescription
paymentMethodTypeStringPayment method type identifier (e.g., "ADYEN_BLIK")
stateAsyncStream<PrimerFormRedirectState>Stream of form redirect state changes

Customization

PropertyTypeDescription
screenFormRedirectScreenComponent?Full screen replacement (replaces both form and pending screens). Signature: (any PrimerFormRedirectScope) -> any View
formSectionFormRedirectFormSectionComponent?Custom form fields area. Signature: (any PrimerFormRedirectScope) -> any View
submitButtonFormRedirectButtonComponent?Custom submit button. Signature: (any PrimerFormRedirectScope) -> any View
submitButtonTextString?Submit button label (default: payment method specific)

Methods

MethodDescription
updateField(_:value:)Update a form field value by field type
This scope inherits start(), submit(), cancel(), onBack(), presentationContext, and dismissalMechanism from PrimerPaymentMethodScope.

PrimerFormRedirectState

public struct PrimerFormRedirectState: Equatable {
  public enum Status: Equatable {
    case ready
    case submitting
    case awaitingExternalCompletion
    case success
    case failure(String)
  }

  var status: Status
  var fields: [PrimerFormFieldState]
  var isSubmitEnabled: Bool        // Computed: all fields valid
  var pendingMessage: String?
  var surchargeAmount: String?

  // Convenience
  var otpField: PrimerFormFieldState?
  var phoneField: PrimerFormFieldState?
  var isLoading: Bool
  var isTerminal: Bool
}

Flow

PropertyTypeDescription
statusStatusCurrent payment status
fields[PrimerFormFieldState]Form fields for user input
isSubmitEnabledBoolWhether all fields are valid (computed)
pendingMessageString?Message while awaiting external completion
surchargeAmountString?Formatted surcharge amount
otpFieldPrimerFormFieldState?Convenience accessor for OTP field
phoneFieldPrimerFormFieldState?Convenience accessor for phone field
isLoadingBoolWhether payment is submitting
isTerminalBoolWhether payment reached terminal state

PrimerFormFieldState

public struct PrimerFormFieldState: Equatable, Identifiable {
  public enum FieldType: String, Equatable, Sendable {
    case otpCode       // BLIK 6-digit code
    case phoneNumber   // MBWay phone number
  }

  public enum KeyboardType: Equatable, Sendable {
    case numberPad
    case phonePad
    case `default`
  }

  var id: String { fieldType.rawValue }
  let fieldType: FieldType
  var value: String
  var isValid: Bool
  var errorMessage: String?
  let placeholder: String
  let label: String
  let helperText: String?
  let keyboardType: KeyboardType
  let maxLength: Int?
  var countryCodePrefix: String?
  var dialCode: String?
}
PropertyTypeDescription
fieldTypeFieldType.otpCode or .phoneNumber
valueStringCurrent text value
isValidBoolWhether the value passes validation
errorMessageString?Validation error message
placeholderStringPlaceholder text
labelStringDisplay label
helperTextString?Helper text below field
keyboardTypeKeyboardTypeKeyboard type for input
maxLengthInt?Max length (nil = unlimited)
countryCodePrefixString?Display prefix for phone fields
dialCodeString?Dial code for session info

Payment methods

Payment MethodType StringField Type
BLIK"ADYEN_BLIK"OTP code (6 digits)
MBWay"ADYEN_MBWAY"Phone number

See also

Scopes overview

All available scopes