Swift with REST API Integration
Integrate hyper SDK to your Swift App using hyperswitch-node
Requirements
iOS 15.1 and above
CocoaPods
npm
1. Setup the server
Follow the Server Setup section.
2. Build checkout page on your app
2.1 Configure your repository with Hyperswitch dependency
CocoaPods Setup (only required if not already done)
Install the latest version of CocoaPods
To create a Podfile run the following command
pod initSDK Setup
Add these lines to your Podfile:
#use_frameworks!
#target 'YourAPP' do
pod 'hyperswitch-sdk-ios'
#endRun the following command:
Remember that moving forward, you should open your project in Xcode using the .xcworkspace file rather than the .xcodeproj file.
To update to the latest version of the SDK, run:
2.2 Setup the SDK and fetch a Payment
Set up the SDK using your publishable key and profile id using HyperswitchConfiguration. Use this to create a Hyperswitch instance.
To get a publishableKey and profileId, refer to your Hyperswitch dashboard here.
Note: For Open Source Setup, initialize your custom Backend app & log URL as:
2.3 Complete the payment on your app
Fetch a Payment
Request your server to fetch a payment as soon as your view is loaded. Store the sdkAuthorization returned by your server. The PaymentSession will use this secret to complete the payment process.
Important: Make sure to never share your API key with your client application as this could potentially compromise your security.
Handle Payment Result
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.
Please retrieve the payment status from the Hyperswitch backend to get the terminal status of the payment. Do not rely solely on the status returned by the SDK, as it may not always reflect the final state of the transaction.
3. Card Element (Beta)
Create a card element view and pay button and 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 iOS SDK, you can customize the payment sheet to blend with the rest of your app.
Next Step:
Last updated
Was this helpful?

