Flutter Plugin over Hyper SDK
https://github.com/juspay/hyper-sdk-flutter.git
Flutter plugin for HyperSDK which enables payment orchestration via different dynamic modules.
Add flutter plugin dependency in pubspec.yaml.
Get dependency from pub.dev
Add the clientId ext property in root(top) build.gradle.
OptionalOptionalGroovy 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.
hypersdkflutter is distributed under AGPL-3.0-only license.
This project is based on the OSS project juspay_flutter by Deep Rooted.co published under MIT License
The original repository is accessible here.