Flutter with Node Backend
Integrate hyper SDK to your Flutter App using payswitcher-node
Last updated
Integrate hyper SDK to your Flutter App using payswitcher-node
Last updated
Before following these steps, please configure your payment methods.
Android 5.0 (API level 21) and above
7.3.1
7.5.1+
iOS 13.0 and above
CocoaPods
npm
payswitcher-node
libraryInstall the package and import it in your code
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.
flutter_payswitcher
libraryAdd flutter_payswitcher
to your pubspec.yaml
file
Run the following command to fetch and install the dependencies.
Initialize a Payment Session by passing the clientSecret to the initPaymentSession
To display the Payment Sheet, integrate a "Pay Now" button within the checkout page, which, when clicked, invokes the presentPaymentSheet()
method and handles the payment response.
Consider the below function, it invokes presentPaymentSheet
and handles payment results.
Before creating a payment, import the hyper dependencies and initialize it with your API key. Get your API key from .
Initialise Hyper
onto your app with your publishable key with the Hyper
constructor. To get a PublishableKey please find it .
Make a network request to the backend endpoint you created in the . The clientSecret returned by your endpoint is used to complete the payment.
Congratulations! Now that you have integrated the Flutter SDK, you can the payment sheet to blend with the rest of your app.