create

suspend fun create(session: AirwallexSession, airwallex: Airwallex, configuration: PaymentElementConfiguration, paymentFlowListener: PaymentFlowListener): Result<PaymentElement>

Creates a PaymentElement by fetching required data.

This method obtains a PaymentFlowViewModel scoped to the Activity, checks if data is already loaded (for configuration changes), and fetches if necessary.

This is the public API that always uses EMBEDDED launch type. For SDK internal usage with custom launch types, use the internal overload.

Return

Result containing the PaymentElement or an error if fetching failed

Parameters

session

The Airwallex session containing payment information

airwallex

The Airwallex instance for payment operations

configuration

Configuration for the payment element

paymentFlowListener

Listener for payment operation callbacks


suspend fun create(session: AirwallexSession, airwallex: Airwallex, configuration: PaymentElementConfiguration, onLoadingStateChanged: (Boolean) -> Unit? = null, onPaymentResult: (AirwallexPaymentStatus) -> Unit, onError: (Throwable) -> Unit? = null): Result<PaymentElement>

Creates a PaymentElement using callback-based approach.

This is a convenience method that wraps PaymentFlowListener with lambda callbacks.

Return

Result containing the PaymentElement or an error if fetching failed

Parameters

session

The Airwallex session containing payment information

airwallex

The Airwallex instance for payment operations

configuration

Configuration for the payment element

onLoadingStateChanged

Optional callback when loading state changes

onPaymentResult

Callback when payment completes (success, failure, or cancel)

onError

Optional callback when errors occur during initialization or payment


fun create(session: AirwallexSession, airwallex: Airwallex, configuration: PaymentElementConfiguration, paymentFlowListener: PaymentFlowListener, callback: PaymentElementCallback)

Java-friendly: Creates a PaymentElement without automatic rendering.

Use this from Java code when you want to control rendering yourself. Call PaymentElement.renderIn on the element to render it when ready.

Example usage from Java:

PaymentElement.create(
session,
airwallex,
configuration,
listener,
new PaymentElementCallback() {
@Override
public void onSuccess(PaymentElement element) {
// Render when ready
element.renderIn(composeView);
}

@Override
public void onFailure(Throwable error) {
// Handle error
}
}
);

Parameters

session

The Airwallex session containing payment information

airwallex

The Airwallex instance for payment operations

configuration

Configuration for the payment element

paymentFlowListener

Listener for payment operation callbacks

callback

Callback to receive the result