Kotlin with Node Backend
Integrate hyper SDK to your Kotlin App using hyperswitch-node
In this section, you will get detailed instructions for integrating the Hyperswitch native Android SDK for your Android app
Use this guide to integrate hyper SDK to your Android app. You can use this as a reference with your Hyperswitch credentials to test the setup. You can also checkout the App on Google Play Store to test the payment flow.
Requirements
Android 5.0 (API level 21) and above
Android Gradle Plugin 7.3.1
Gradle 7.5.1+
1. Setup the server
1.1 Install the hyperswitch-node
library
hyperswitch-node
libraryInstall the package and import it in your code
1.2 Create a payment
Before creating a payment, import the hyperswitch-node
dependencies and initialize it with your API key.
Add an endpoint on your server that creates a Payment. Creating a Payment helps to establish the intent of the customer to start a payment. It also helps to track the customerβs payment lifecycle, keeping track of failed payment attempts and ensuring the customer is only charged once. Return the client_secret
obtained in the response to securely complete the payment on the client.
2. Build checkout page on your app
2.1 Configure your repository with Hyperswitch dependency
Add the following maven repository to the settings.gradle file
2.2 Add the Hyperswitch dependency
Add hyperswitch-android to the dependencies block of your build.gradle file to install the SDK
2.3 Implement the HyperInterface
Implement the HyperInterface to your CheckoutActivity
2.4 Setup the SDK and fetch a Payment
Setup the SDK with your publishable key
Note: For Open Source Setup, initialise PaymentConfiguration as:
Fetch a payment by requesting your server for a payment as soon as your view is loaded. Store a reference to the client_secret
returned by the server; the Payment Sheet will use this secret to complete the payment later.
3. Complete the payment on your app
Create a PaymentSheet instance using the client_secret
retrieved from the previous step. Present the payment page from your view controller and use the PaymentSheet.Configuration struct for customising your payment page.
Handle the payment result in the completion block and display appropriate messages to your customer based on whether the payment fails with an error or succeeds.
Congratulations! Now that you have integrated the Android SDK, you can customise the payment sheet to blend with the rest of your app.
Next step:
π³pagePayment methods setupLast updated