Cards & Wallets · Mobile SDK · UI Components

Billing Address Component

This is an optional component. Integrating it is not required to achieve full functionality — you can skip it entirely by providing a pre-filled com.accesspaysuite.mobilesdk.data.common.BillingAddress.
The BillingAddressComponent
The BillingAddressComponent

The BillingAddressComponent is a Composable function used to render a billing address form. It provides various parameters to customise the appearance and behaviour of the component.

Parameters

ParameterDescription
modifierThe modifier to apply to the layout.
fontSizeThe font size of the text in the component.
fontWeightThe font weight of the text in the component.
borderSizeThe size of the border around the component.
borderCornerRadiusThe corner radius of the border.
borderColorThe colour of the border.
defaultCountryCodeThe default country code for the address.
useDropdownWhether to use a dropdown for selecting the country.
showAddressLine2Whether to show the second line of the address.
showAddressLine3Whether to show the third line of the address.
showAddressLine4Whether to show the fourth line of the address.
skipCheckboxUISkip the checkbox UI. Adds a checkbox to enable the component’s control of the billing address if it differs from the one in defaultAddress.
defaultAddressThe default billing address.
onAddressFilledA callback function called when the address is filled.
isOutlinedWhether the component should be outlined.

This renders a billing address form with the specified customisation options. For uses other than Compose you can use BillingAddressState to define its styling.

Example usage

Compose Multiplatform

Kotlin
BillingAddressComponent(
  modifier = Modifier,
  fontSize = 14.sp,
  fontWeight = ComponentFontWeight.NORMAL,
  borderSize = 1.dp,
  borderCornerRadius = 4.dp,
  borderColor = Color.Gray,
  defaultCountryCode = "GBR",
  useDropdown = false,
  showAddressLine2 = true,
  showAddressLine3 = false,
  showAddressLine4 = false,
  skipCheckboxUI = false,
  defaultAddress = null,
  onAddressFilled = { address ->
      // Handle the filled address
  },
  isOutlined = true,
  lightColorScheme = lightColorScheme(),
  darkColorScheme = lightColorScheme()
)

Android View

XML
<com.accesspaysuite.mobilesdk.ui.billing.BillingAddressView
  android:id="@+id/billingAddressView"
  android:layout_width="match_parent"
  android:layout_height="wrap_content" />
Kotlin
val billingAddressView = findViewById<BillingAddressView>(R.id.billingAddressView)
billingAddressView.init(state = BillingAddressState())

iOS

Create the controller representable
Swift
import SwiftUI
import mobilesdk

struct BillingAddressControllerRepresentable: UIViewControllerRepresentable {
  @Binding var state: BillingAddressState

  init(state: Binding<BillingAddressState>) {
      self._state = state
  }

  func makeUIViewController(context: Context) -> UIViewController {
      return BillingAddressController().make()
  }

  func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
      BillingAddressController().update(state: state)
  }
}
Create the billing address view
Swift
import SwiftUI
import mobilesdk

struct BillingAddress: View {

  @Binding var state: BillingAddressState

  init(state: Binding<BillingAddressState>) {
      self._state = state
  }

  var body: some View {
      BillingAddressControllerRepresentable(
          state: $state
      )
      .ignoresSafeArea(.keyboard)
      .onTapGesture {
          UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
      }
  }
}
Use the billing address view
Swift
import SwiftUI
import mobilesdk

struct PaymentView: View {

  @State private var state = BillingAddressState()

  var body: some View {
      BillingAddress(
          state: $state
      )
  }
}

The BillingAddress data class

PropertyDescription
line1(Required) Line 1 of the customer’s billing address.
line2(Optional) Line 2 of the customer’s billing address.
line3(Optional) Line 3 of the customer’s billing address.
line4(Optional) Line 4 of the customer’s billing address.
city(Required) City of the customer’s billing address.
region(Required) Region of the customer’s billing address.
postcode(Required) Postcode of the customer’s billing address.
countryCode(Required) The three-character ISO-3166-1 code for the customer’s billing address country.
email(Optional) Email address of the customer.
Kotlin
/**
* # Billing Address
*
* > The billing address of the Customer. Will be used for AVS checks. We'll save the billing
* > address when the customer makes their first payment.
* > Providing a billing address for subsequent payments will update the address we've saved if
* > you send new, empty or no values for each field.
*
*/
@Parcelize
@Serializable
data class BillingAddress(
  var line1: String? = null,
  var line2: String? = null,
  var line3: String? = null,
  var line4: String? = null,
  var city: String? = null,
  var region: String? = null,
  var postcode: String? = null,
  var countryCode: String? = null,
  var email: String? = null
)