Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,60 @@ HyperSdkReact.isInitialised().then((init: boolean) => {
});
```

### WebView Configuration Callback (Optional)

The Minkasu SDK requires access to the bank WebView SDK. This can be enabled after whitelisting on Juspay end. Below is a reference to changes required post getting SDK whitelisted. This should be called before calling process.

#### Android

**Kotlin:**

```kotlin
import `in`.juspay.hypersdkreact.HyperSdkReactModule
import `in`.juspay.hypersdk.core.JuspayWebViewConfigurationCallback


HyperSdkReactModule.setWebViewConfigurationCallback(
JuspayWebViewConfigurationCallback { webView ->

}
)
```

**Java:**

```java
import in.juspay.hypersdkreact.HyperSdkReactModule;


HyperSdkReactModule.setWebViewConfigurationCallback(webView -> {

});
```

#### iOS

**Swift:**

```swift
import hyper_sdk_react


HyperSdkReact.setJuspayWebViewConfigurationCallback { webView in

}
```

**Objective-C:**

```objective-c
#import "HyperSdkReact.h"

[HyperSdkReact setJuspayWebViewConfigurationCallback:^(WKWebView * _Nonnull webView) {

}];
```

### Optional: Update Base ViewController - Only for iOS

This is an optional method to update the base view controller in case if any new view controller is presented over top view controller after the SDK initiation. This method should be called before making `HyperSdkReact.process()` call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.Set;

import in.juspay.hypercheckoutlite.HyperCheckoutLite;
import in.juspay.hypersdk.core.JuspayWebViewConfigurationCallback;
import in.juspay.hypersdk.core.MerchantViewType;
import in.juspay.hypersdk.core.SdkTracker;
import in.juspay.hypersdk.data.JuspayResponseHandler;
Expand Down Expand Up @@ -89,6 +90,18 @@ public class HyperSdkReactModule extends ReactContextBaseJavaModule implements A

private static WeakReference<HyperServices> hyperServicesReference = new WeakReference<>(null);

@Nullable
private static JuspayWebViewConfigurationCallback webViewConfigurationCallback = null;

/**
* Sets the WebView configuration callback used by HyperSDK. Merchants can use this to
* customise the {@link android.webkit.WebView} created by the SDK (for example, to enable
* Minkasu SDK access). Must be called before {@code process} to take effect.
*/
public static void setWebViewConfigurationCallback(@Nullable JuspayWebViewConfigurationCallback callback) {
webViewConfigurationCallback = callback;
}

private final ReactApplicationContext context;

private boolean wasProcessWithActivity = false;
Expand Down Expand Up @@ -592,6 +605,9 @@ private void process(HyperServices hyperService, String data) {
}
hyperService.setActivityLaunchDelegate(new ReactLaunchDelegate(context));
hyperService.setRequestPermissionDelegate(new ReactRequestDelegate(activity));
if (webViewConfigurationCallback != null) {
hyperService.setWebViewConfigurationCallback(webViewConfigurationCallback);
}

hyperService.process(activity, payload);
} catch (JSONException e) {
Expand Down Expand Up @@ -650,6 +666,9 @@ public void onCreated(@NonNull FragmentActivity fragmentActivity) {

wasProcessWithActivity = true;
processActivityRef = new WeakReference<>(fragmentActivity);
if (webViewConfigurationCallback != null) {
hyperService.setWebViewConfigurationCallback(webViewConfigurationCallback);
}
hyperService.process(fragmentActivity, payload);
}

Expand Down
6 changes: 6 additions & 0 deletions ios/HyperSdkReact.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#import <HyperSDK/HyperSDK.h>
#import <React/RCTRootView.h>
#import <React/RCTViewManager.h>
#import <WebKit/WebKit.h>

typedef void (^JuspayWebViewConfigurationCallback)(WKWebView *webView);

@interface HyperSdkReact : RCTEventEmitter <RCTBridgeModule>

Expand All @@ -21,6 +24,9 @@
@property (nonatomic, strong) NSMutableDictionary *hyperDelegatesDict;
@property (nonatomic, strong) NSMutableSet<NSString *> *knownEventKeys;

+ (void)setJuspayWebViewConfigurationCallback:(JuspayWebViewConfigurationCallback)callback;
+ (nullable JuspayWebViewConfigurationCallback)juspayWebViewConfigurationCallback;

@end

@protocol HyperSdkReactDelegate <NSObject>
Expand Down
16 changes: 15 additions & 1 deletion ios/HyperSdkReact.mm
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,26 @@ - (UIView * _Nullable)merchantViewForViewType:(NSString * _Nonnull)viewType {
}

- (void) onWebViewReady:(WKWebView *)webView {
//Ignored
JuspayWebViewConfigurationCallback callback = [HyperSdkReact juspayWebViewConfigurationCallback];
if (callback) {
callback(webView);
}
}

@end

@implementation HyperSdkReact

static JuspayWebViewConfigurationCallback _juspayWebViewConfigurationCallback = nil;

+ (void)setJuspayWebViewConfigurationCallback:(JuspayWebViewConfigurationCallback)callback {
_juspayWebViewConfigurationCallback = [callback copy];
}

+ (nullable JuspayWebViewConfigurationCallback)juspayWebViewConfigurationCallback {
return _juspayWebViewConfigurationCallback;
}

RCT_EXPORT_MODULE()

NSString *HYPER_EVENT = @"HyperEvent";
Expand Down
Loading