Interface SessionComponentCallback
-
- All Implemented Interfaces:
-
com.adyen.checkout.components.core.internal.BaseComponentCallback
public interface SessionComponentCallback<T extends PaymentComponentState<?>> implements BaseComponentCallbackImplement this callback to interact with a PaymentComponent initialized with a session.
-
-
Method Summary
Modifier and Type Method Description abstract UnitonAction(Action action)Indicates that an action needs to be handled to continue the payment flow. abstract UnitonFinished(SessionPaymentResult result)Indicates that the payment flow has finished. abstract UnitonError(ComponentError componentError)The component has encountered an error. UnitonStateChanged(T state)You can implement this optional method to receive an update any time the state of the component changes. BooleanonSubmit(T state)Override this method if you want to take over the sessions flow and make a network call to the /payments endpoint of the Checkout API through your server. BooleanonAdditionalDetails(ActionComponentData actionComponentData)Override this method if you want to take over the sessions flow and make a network call to the /payments/details endpoint of the Checkout API through your server. UnitonLoading(Boolean isLoading)Indicates that an API call is being executed by the component. UnitonPermissionRequest(String requiredPermission, PermissionHandlerCallback permissionCallback)Should be overridden to support runtime permissions for components. -
-
Method Detail
-
onAction
abstract Unit onAction(Action action)
Indicates that an action needs to be handled to continue the payment flow. You can call component.handleAction to handle this action.
- Parameters:
action- The action that need to be handled.
-
onFinished
abstract Unit onFinished(SessionPaymentResult result)
Indicates that the payment flow has finished.
- Parameters:
result- The result of the payment.
-
onError
abstract Unit onError(ComponentError componentError)
The component has encountered an error. Use ComponentError.exception to get the internal exception.
- Parameters:
componentError- The error encountered.
-
onStateChanged
Unit onStateChanged(T state)
You can implement this optional method to receive an update any time the state of the component changes.
This mainly occurs through a user interaction (editing an input, selecting an item from a list, etc) and will be triggered regardless whether the component is valid or not.
We provide a PaymentComponentState which contains information about the state of the payment component at that moment.
- Parameters:
state- The state of the payment component at the current moment.
-
onSubmit
Boolean onSubmit(T state)
Override this method if you want to take over the sessions flow and make a network call to the /payments endpoint of the Checkout API through your server.
You need to return true if you want to take over the sessions flow, otherwise the API calls will still be handled internally by the SDK. This could be useful in case you want to handle the flow yourself only in certain conditions, then you can return false if these conditions are not met.
Once you take over the flow you will need to handle all the necessary subsequent network calls, otherwise a MethodNotImplementedException will be thrown.
We provide a PaymentComponentState which contains information about the state of the payment component at the moment the user submits the payment.
We also provide inside PaymentComponentState.data the parameters that we can infer from the component's configuration and the user input, especially the state.data.paymentMethod object with the shopper input details.
Use PaymentComponentData.SERIALIZER to serialize this data to a JSONObject. The rest of the /payments call request data should be filled in, on your server, according to your needs.
In case you receive an additional action, you can call component.handleAction with an Action containing the result of the network request.
See https://docs.adyen.com/api-explorer/ for more information on the API documentation.
- Parameters:
state- The state of the payment component at the moment the user submits the payment.- Returns:
true if you took over the sessions flow, false otherwise.
-
onAdditionalDetails
Boolean onAdditionalDetails(ActionComponentData actionComponentData)
Override this method if you want to take over the sessions flow and make a network call to the /payments/details endpoint of the Checkout API through your server.
You need to return true if you want to take over the sessions flow, otherwise the API calls will still be handled internally by the SDK. This could be useful in case you want to handle the flow yourself only in certain conditions, then you can return false if these conditions are not met.
Once you take over the flow you will need to handle all the necessary subsequent network calls, otherwise a MethodNotImplementedException will be thrown.
We provide inside ActionComponentData the whole request data expected by the /payments/details endpoint. Use ActionComponentData.SERIALIZER to serialize this data to a JSONObject.
See https://docs.adyen.com/api-explorer/ for more information on the API documentation.
- Parameters:
actionComponentData- The data from the action component.- Returns:
true if you took over the sessions flow, false otherwise.
-
onLoading
Unit onLoading(Boolean isLoading)
Indicates that an API call is being executed by the component. Could be used to show a loading indicator in your UI.
-
onPermissionRequest
Unit onPermissionRequest(String requiredPermission, PermissionHandlerCallback permissionCallback)
Should be overridden to support runtime permissions for components. Runtime permission should be requested and communicated back through the callback. If not overridden, PermissionHandlerCallback.onPermissionRequestNotHandled will be invoked, which will show an error message.
- Parameters:
requiredPermission- Required runtime permission.permissionCallback- Callback to be used when passing permission result.
-
-
-
-