Once you have initialised the Ryft Drop-In SDK, as indicated in the initial setup, you can show the Drop-In payment UI to your users.
In order to display the Drop-In UI, you can call the show() method on the RyftDropIn instance you created during the initialisation step. This will include passing the necessary configuration parameters required for the payment process, such as:
- Your Public Key;
- The Client Secret obtained from your backend when creating a Payment Session;
- (Optional) The Account ID if you are processing payments on behalf of a Sub-Account.
Here's an example of how to show the Drop-In UI in your activity or fragment:
class CheckoutActivity : ComponentActivity() {
// ...
private lateinit var payButton: Button // Example pay button
// ...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ...
payButton.setOnClickListener {
showDropIn()
}
// ...
}
// ...
private fun showDropIn() {
ryftDropIn.show(
RyftDropInConfiguration.standardAccountPayment(
clientSecret = "", // The client secret returned when creating a Payment Session
publicApiKey = RyftPublicApiKey("") // Your Ryft Public API Key
),
)
}
// ...
}The Drop-In will automatically detect the appropriate environment (test or live) based on the provided Public Key.
To enable Google Pay in the Drop-In UI, you need to ensure that:
- You have provided a RyftDropInGooglePayConfiguration object when displaying the Drop-In UI.
- The user has a valid Google Pay method set up on their device.
Google Pay will be disabled in the Drop-In UI if the above conditions are not met.
Here's an example of how to enable Google Pay in the Drop-In UI:
private fun showDropIn() {
ryftDropIn.show(
RyftDropInConfiguration.standardAccountPayment(
// ...
googlePayConfiguration = RyftDropInGooglePayConfiguration(
merchantName = "", // The name of your business as it should appear in Google Pay
merchantCountryCode = "" // The ISO 3166-1 alpha-2 country code of your business (e.g., "UK")
)
),
)
}With this setup, Google Pay will be available as a payment option in the Drop-In UI, provided the user has it configured on their device.
After displaying the Drop-In UI, you will need to handle the payment result. This is done by implementing the RyftDropInResultListener interface in your activity or fragment.
For more information on how to implement the listener and handle payment results, please refer to the Drop-In Listener section.