Object DropIn
-
- All Implemented Interfaces:
public class DropInDrop-in is our pre-built checkout UI for accepting payments. You only need to integrate through your backend with the /sessions API endpoint and provide some configuration data. Drop-in will handle the rest of the checkout flow.
Alternatively you can opt for a more advanced implementation with the 3 main API endpoints: /paymentMethods, /payments and /payments/details.
To start the checkout flow, register you activity or fragment using registerForDropInResult to receive the result of Drop-in. Then call one of the startPayment methods.
-
-
Method Summary
Modifier and Type Method Description final static ActivityResultLauncher<SessionDropInResultContractParams>registerForDropInResult(ActivityResultCaller caller, SessionDropInCallback callback)Register your Activity or Fragment with the Activity Result API and receive the final Drop-in result using the SessionDropInCallback. final static ActivityResultLauncher<DropInResultContractParams>registerForDropInResult(ActivityResultCaller caller, DropInCallback callback)Register your Activity or Fragment with the Activity Result API and receive the final Drop-in result using the DropInCallback. final static UnitstartPayment(Context context, ActivityResultLauncher<SessionDropInResultContractParams> dropInLauncher, CheckoutSession checkoutSession, DropInConfiguration dropInConfiguration, Class<out SessionDropInService> serviceClass)Starts the checkout flow to be handled by the Drop-in solution. final static UnitstartPayment(Context context, ActivityResultLauncher<SessionDropInResultContractParams> dropInLauncher, CheckoutSession checkoutSession, CheckoutConfiguration checkoutConfiguration, Class<out SessionDropInService> serviceClass)Starts the checkout flow to be handled by the Drop-in solution. final static UnitstartPayment(Context context, ActivityResultLauncher<DropInResultContractParams> dropInLauncher, PaymentMethodsApiResponse paymentMethodsApiResponse, DropInConfiguration dropInConfiguration, Class<out DropInService> serviceClass)Starts the advanced checkout flow to be handled by the Drop-in solution. final static UnitstartPayment(Context context, ActivityResultLauncher<DropInResultContractParams> dropInLauncher, PaymentMethodsApiResponse paymentMethodsApiResponse, CheckoutConfiguration checkoutConfiguration, Class<out DropInService> serviceClass)Starts the advanced checkout flow to be handled by the Drop-in solution. -
-
Method Detail
-
registerForDropInResult
final static ActivityResultLauncher<SessionDropInResultContractParams> registerForDropInResult(ActivityResultCaller caller, SessionDropInCallback callback)
Register your Activity or Fragment with the Activity Result API and receive the final Drop-in result using the SessionDropInCallback.
This must be called unconditionally, as part of the initialization path, typically as a field initializer of an Activity or Fragment.
You will receive the Drop-in result in the SessionDropInCallback.onDropInResult method. Check out SessionDropInResult class for all the possible results you might receive.
- Parameters:
caller- The class that needs to launch Drop-in and receive its callback.callback- Callback for the Drop-in result.- Returns:
The ActivityResultLauncher required to receive the result of Drop-in.
-
registerForDropInResult
final static ActivityResultLauncher<DropInResultContractParams> registerForDropInResult(ActivityResultCaller caller, DropInCallback callback)
Register your Activity or Fragment with the Activity Result API and receive the final Drop-in result using the DropInCallback.
This must be called unconditionally, as part of the initialization path, typically as a field initializer of an Activity or Fragment.
You will receive the Drop-in result in the DropInCallback.onDropInResult method. Check out DropInResult for all the possible results you might receive.
- Parameters:
caller- The class that needs to launch Drop-in and receive its callback.callback- Callback for the Drop-in result.- Returns:
The ActivityResultLauncher required to receive the result of Drop-in.
-
startPayment
final static Unit startPayment(Context context, ActivityResultLauncher<SessionDropInResultContractParams> dropInLauncher, CheckoutSession checkoutSession, DropInConfiguration dropInConfiguration, Class<out SessionDropInService> serviceClass)
Starts the checkout flow to be handled by the Drop-in solution. With this solution your backend only needs to integrate the /sessions endpoint to start the checkout flow.
Call registerForDropInResult to create a launcher when initializing your Activity or Fragment and receive the final result of Drop-in.
Use dropInConfiguration to configure Drop-in and the components that will be loaded inside it.
Optionally, you can extend SessionDropInService with your own implementation and add it to your manifest file. This allows you to interact with Drop-in, and take over the checkout flow.
- Parameters:
context- The context to start the Checkout flow with.dropInLauncher- A launcher to start Drop-in, obtained with registerForDropInResult.checkoutSession- The result from the /sessions endpoint passed onto CheckoutSessionProvider.createSession to create this object.dropInConfiguration- Additional required configuration data.serviceClass- Service that extends from SessionDropInService to optionally take over the checkout flow.
-
startPayment
final static Unit startPayment(Context context, ActivityResultLauncher<SessionDropInResultContractParams> dropInLauncher, CheckoutSession checkoutSession, CheckoutConfiguration checkoutConfiguration, Class<out SessionDropInService> serviceClass)
Starts the checkout flow to be handled by the Drop-in solution. With this solution your backend only needs to integrate the /sessions endpoint to start the checkout flow.
Call registerForDropInResult to create a launcher when initializing your Activity or Fragment and receive the final result of Drop-in.
Use checkoutConfiguration to configure Drop-in and the components that will be loaded inside it.
Optionally, you can extend SessionDropInService with your own implementation and add it to your manifest file. This allows you to interact with Drop-in, and take over the checkout flow.
- Parameters:
context- The context to start the Checkout flow with.dropInLauncher- A launcher to start Drop-in, obtained with registerForDropInResult.checkoutSession- The result from the /sessions endpoint passed onto CheckoutSessionProvider.createSession to create this object.checkoutConfiguration- Additional required configuration data.serviceClass- Service that extends from SessionDropInService to optionally take over the checkout flow.
-
startPayment
final static Unit startPayment(Context context, ActivityResultLauncher<DropInResultContractParams> dropInLauncher, PaymentMethodsApiResponse paymentMethodsApiResponse, DropInConfiguration dropInConfiguration, Class<out DropInService> serviceClass)
Starts the advanced checkout flow to be handled by the Drop-in solution. With this solution your backend needs to integrate the 3 main API endpoints: /paymentMethods, /payments and /payments/details.
Extend DropInService with your own implementation and add it to your manifest file. This class allows you to interact with Drop-in during the checkout flow.
Call registerForDropInResult to create a launcher when initializing your Activity or Fragment and receive the final result of Drop-in.
Use dropInConfiguration to configure Drop-in and the components that will be loaded inside it.
- Parameters:
context- The context to start the Checkout flow with.dropInLauncher- A launcher to start Drop-in, obtained with registerForDropInResult.paymentMethodsApiResponse- The result from the /paymentMethods endpoint.dropInConfiguration- Additional required configuration data.serviceClass- Service that extends from DropInService to interact with Drop-in during the checkout flow.
-
startPayment
final static Unit startPayment(Context context, ActivityResultLauncher<DropInResultContractParams> dropInLauncher, PaymentMethodsApiResponse paymentMethodsApiResponse, CheckoutConfiguration checkoutConfiguration, Class<out DropInService> serviceClass)
Starts the advanced checkout flow to be handled by the Drop-in solution. With this solution your backend needs to integrate the 3 main API endpoints: /paymentMethods, /payments and /payments/details.
Extend DropInService with your own implementation and add it to your manifest file. This class allows you to interact with Drop-in during the checkout flow.
Call registerForDropInResult to create a launcher when initializing your Activity or Fragment and receive the final result of Drop-in.
Use checkoutConfiguration to configure Drop-in and the components that will be loaded inside it.
- Parameters:
context- The context to start the Checkout flow with.dropInLauncher- A launcher to start Drop-in, obtained with registerForDropInResult.paymentMethodsApiResponse- The result from the /paymentMethods endpoint.checkoutConfiguration- Additional required configuration data.serviceClass- Service that extends from DropInService to interact with Drop-in during the checkout flow.
-
-
-
-