WebView ViewController Delegate
my2c2pSDK support OTP and it will open the WebView ViewController when payment is required.
This delegate method is also using for Master Pass, AliPay , UPOP and MPU.
Objective-C
For delegate , my2c2pSDK support
- (void)my2c2pSDKWillOpenWebView;
- (void)my2c2pSDKDidOpenWebView;
- (void)my2c2pSDKWillCloseWebViewWithCancel:(BOOL)cancel;
- (void)my2c2pSDKDidCloseWebViewWithCancel:(BOOL)cancel;
func my2c2pSDKWillOpenWebView() {
}
func my2c2pSDKDidOpenWebView() {
}
func my2c2pSDKWillCloseWebViewWithCancel(cancel: Bool) {
}
func my2c2pSDKDidCloseWebViewWithCancel(cancel: Bool) {
}
To receive the Delegate
Declare My2c2pSDKDelegate in your .h file.
@interface ViewController : UIViewController <My2c2pSDKDelegate>
class ViewController: UIViewController , My2c2pSDKDelegate
In your my2c2pSDK object, you need to set delegate
paymentSDK.delegate = self;
paymentSDK.delegate = self
Delegate Method
When WebView ViewController will open , it will call
- (void)my2c2pSDKWillOpenWebView;
func my2c2pSDKWillOpenWebView()
When WebView ViewController did open , it will call
- (void)my2c2pSDKDidOpenWebView;
func my2c2pSDKDidOpenWebView()
When WebView ViewController will close, it will call
- (void)my2c2pSDKWillCloseWebViewWithCancel:(BOOL)cancel;
func my2c2pSDKWillCloseWebViewWithCancel(cancel: Bool)
If user cancel the WebView page , cancel will YES (ObjC) or true (Swift).
When WebView ViewController did close, it will call
- (void)my2c2pSDKDidCloseWebViewWithCancel:(BOOL)cancel;
func my2c2pSDKDidCloseWebViewWithCancel(cancel: Bool)
If user cancel the WebView page , cancel will YES (Objc) or true (Swift).
Example
- (void)checkout
{
...
...
...
paymentSDK.delegate = self;
...
...
...
}
- (void)my2c2pSDKWillOpenWebView {
NSLog(@"WebView page will open");
}
- (void)my2c2pSDKDidOpenWebView {
NSLog(@"WebView page opened");
}
- (void)my2c2pSDKWillCloseWebViewWithCancel:(BOOL)cancel {
if(cancel) {
NSLog(@"user cancel the payment");
}
else {
NSLog(@"WebView page will close");
}
}
- (void)my2c2pSDKDidCloseWebViewWithCancel:(BOOL)cancel {
if(cancel) {
NSLog(@"user cancel the payment");
}
else {
NSLog(@"WebView page closed");
}
}
func checkout()
{
...
...
...
paymentSDK.delegate = self
...
...
...
}
func my2c2pSDKWillOpenWebView() {
print("WebView page will open")
}
func my2c2pSDKDidOpenWebView() {
print("WebView Page open")
}
func my2c2pSDKWillCloseWebViewWithCancel(cancel: Bool) {
if cancel == true {
print("user cancel the payment")
} else {
print("WebView page will close")
}
}
func my2c2pSDKDidCloseWebViewageWithCancel(cancel: Bool) {
if cancel == true {
print("user cancel the payment")
} else {
print("WebView page closed")
}
}