create
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
The Airwallex session containing payment information
The Airwallex instance for payment operations
Configuration for the payment element
Listener for payment operation callbacks
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
The Airwallex session containing payment information
The Airwallex instance for payment operations
Configuration for the payment element
Optional callback when loading state changes
Callback when payment completes (success, failure, or cancel)
Optional callback when errors occur during initialization or payment
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
The Airwallex session containing payment information
The Airwallex instance for payment operations
Configuration for the payment element
Listener for payment operation callbacks
Callback to receive the result