๐Ÿ“ฆ juspay / hyper-sdk-flutter

Flutter Plugin over Hyper SDK

โ˜… 7 stars โ‘‚ 30 forks ๐Ÿ‘ 7 watching โš–๏ธ GNU Affero General Public License v3.0
๐Ÿ“ฅ Clone https://github.com/juspay/hyper-sdk-flutter.git
HTTPS git clone https://github.com/juspay/hyper-sdk-flutter.git
SSH git clone git@github.com:juspay/hyper-sdk-flutter.git
CLI gh repo clone juspay/hyper-sdk-flutter
Yaswanth Polisetti Yaswanth Polisetti fix: security fix on build.yaml fdfb0d2 1 days ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ android
๐Ÿ“ example
๐Ÿ“ ios
๐Ÿ“ lib
๐Ÿ“„ .editorconfig
๐Ÿ“„ .gitignore
๐Ÿ“„ .metadata
๐Ÿ“„ .pubignore
๐Ÿ“„ CHANGELOG.md
๐Ÿ“„ CODE_OF_CONDUCT.md
๐Ÿ“„ CONTRIBUTING.md
๐Ÿ“„ LICENSE
๐Ÿ“„ LICENSE.parent
๐Ÿ“„ pubspec.yaml
๐Ÿ“„ README.md
๐Ÿ“„ README.md

Hyper SDK Flutter

Flutter plugin for HyperSDK which enables payment orchestration via different dynamic modules.

Flutter Setup

Add flutter plugin dependency in pubspec.yaml. Get dependency from pub.dev

Android Setup

Add the clientId ext property in root(top) build.gradle.

  • Override HyperSDK Version by adding hyperSDKVersion - Optional
  • Exclude microSDKs provided with HyperSDK for given clientId by adding excludedMicroSDKs - Optional
Depending on the flutter version or the build.gradle format, kindly use either the below groovy code snippet or the Kotlin one:

Groovy Format

buildscript {
    ....
    ext {
        ....
        clientId = "<clientId shared by Juspay team>"
        hyperSDKVersion = "<Version shared by Juspay team>"
        excludedMicroSDKs = []
        ....
    }
    ....
}

Kotlin DSL Format ``Kotlin DSL buildscript { .... extra["clientId"] = "<clientId shared by Juspay team>" extra["hyperSDKVersion"] = "<Version shared by Juspay team>" .... } %%CODEBLOCK1%%kotlin import io.flutter.embedding.android.FlutterFragmentActivity class MainActivity: FlutterFragmentActivity() { } %%CODEBLOCK2%%sh post_install do |installer| fuse_path = "./Pods/HyperSDK/Fuse.rb" clean_assets = true if File.exist?(fuse_path) if system("ruby", fuse_path.to_s, clean_assets.to_s) end end end %%CODEBLOCK3%%txt clientId = <clientId> shared by Juspay Team %%CODEBLOCK4%%yaml # pubspec.yaml name: your_flutter_app description: A new Flutter project. # Other configurations... hyper_sdk_ios_version: "<New version>" %%CODEBLOCK5%%dart import 'package:hypersdk/hypersdkflutter.dart'; %%CODEBLOCK6%%dart final hyperSDK = HyperSDK(); %%CODEBLOCK7%%dart hyperSDK.createHyperServicesWithTenantId("<tenantName>", "clientId"); %%CODEBLOCK8%%dart await hyperSDK.initiate(initiatePayload, initiateCallbackHandler); %%CODEBLOCK9%%dart await hyperSDK.process(processPayload, hyperSDKCallbackHandler) %%CODEBLOCK10%%dart await hyperSDK.processWithActivity(processPayload, hyperSDKCallbackHandler) %%CODEBLOCK11%%dart hyperSDK.hyperSdkView(processPayload, hyperSDKCallbackHandler) %%CODEBLOCK12%%dart Container( color: Colors.white, child: hyperSDK.hyperSdkView(processPayload, hyperSDKCallbackHandler) ) %%CODEBLOCK13%%dart hyperSDK.hyperFragmentView(height, width, "paymentWidget", processPayload, hyperSDKCallbackHandler) %%CODEBLOCK14%%dart Container( color: Colors.white, child: hyperSDK.hyperFragmentView(height, width, "paymentWidget", processPayload, hyperSDKCallbackHandler) ) %%CODEBLOCK15%%dart onWillPop: () async { if (Platform.isAndroid) { var backpressResult = await hyperSDK.onBackPress(); if (backpressResult.toLowerCase() == "true") { return false; } else { return true; } } else { return true; } } %%CODEBLOCK16%%dart await hyperSDK.terminate(); %%CODEBLOCK17%%dart await hyperSDK.isInitialised(); %%CODEBLOCK18%%dart void initiateCallbackHandler(MethodCall methodCall) { if (methodCall.method == "initiate_result") { // check initiate result } } %%CODEBLOCK19%%dart void hyperSDKCallbackHandler(MethodCall methodCall) { switch (methodCall.method) { case "hide_loader": break; case "process_result": var args = {}; try { args = json.decode(methodCall.arguments); } catch (e) { print(e); } var error = args["error"] ?? false; var innerPayload = args["payload"] ?? {}; var status = innerPayload["status"] ?? " "; var pi = innerPayload["paymentInstrument"] ?? " "; var pig = innerPayload["paymentInstrumentGroup"] ?? " "; if (!error) { switch (status) { case "charged": { // Successful Transaction // check order status via S2S API } break; case "cod_initiated": { // User opted for cash on delivery option displayed on payment page } break; } } else { var errorCode = args["errorCode"] ?? " "; var errorMessage = args["errorMessage"] ?? " "; switch (status) { case "backpressed": { // user back-pressed from PP without initiating any txn } break; case "user_aborted": { // user initiated a txn and pressed back // check order status via S2S API } break; case "pending_vbv": {} break; case "authorizing": { // txn in pending state // check order status via S2S API } break; case "authorization_failed": {} break; case "authentication_failed": {} break; case "api_failure": { // txn failed // check order status via S2S API } break; case "new": { // order created but txn failed // check order status via S2S API } break; } } } } %%CODEBLOCK20%%kotlin import in.juspay.hyper_sdk_flutter.HyperSdkFlutterPlugin import in.juspay.hypersdk.core.JuspayWebViewConfigurationCallback HyperSdkFlutterPlugin.webViewConfigurationCallback = JuspayWebViewConfigurationCallback { webview -> } %%CODEBLOCK21%%java import in.juspay.hyper_sdk_flutter.HyperSdkFlutterPlugin; HyperSdkFlutterPlugin.setWebViewConfigurationCallback(webView -> { }); %%CODEBLOCK22%%swift import hypersdkflutter SwiftHyperSdkFlutterPlugin.setJuspayWebViewConfigurationCallback { webView in } %%CODEBLOCK23%%objective-c #if __has_include(<hypersdkflutter/hypersdkflutter-Swift.h>) #import <hypersdkflutter/hypersdkflutter-Swift.h> #else @import hypersdkflutter; #endif [SwiftHyperSdkFlutterPlugin setJuspayWebViewConfigurationCallback:^(WKWebView * _Nonnull webview) { }]; ` ## Payload Structure Payload type is Map`

For Payment Page Product, click here for payload.

For EC-Headless Product, click here for payload.

License

hypersdkflutter is distributed under AGPL-3.0-only license.

Attribution

This project is based on the OSS project juspay_flutter by Deep Rooted.co published under MIT License

The original repository is accessible here.