Hello, I am new to Xamarin. I am trying to integrate Payment gateway in my xamarin forms app. Payment gateway provider has provided the Swift framework. I tried to create a binding library using sharpie but couldn't implement.
here is ApiDefinitions.cs generated by sharpie.
using System;
using Foundation;
using UIKit;
using WebKit;
namespace CFSDK
{
// @interface CFViewController : UIViewController
[BaseType (typeof(UIViewController), Name = "_TtC5CFSDK16CFViewController")]
interface CFViewController
{
// -(void)viewDidLoad;
[Export ("viewDidLoad")]
void ViewDidLoad ();
}
// @interface CFSDK_Swift_204 (CFViewController) <WKNavigationDelegate> [Category] [BaseType (typeof(CFViewController))] interface CFViewController_CFSDK_Swift_204 : IWKNavigationDelegate { // -(void)webView:(WKWebView * _Nonnull)webView decidePolicyForNavigationAction:(WKNavigationAction * _Nonnull)navigationAction decisionHandler:(void (^ _Nonnull)(WKNavigationActionPolicy))decisionHandler; [Export ("webView:decidePolicyForNavigationAction:decisionHandler:")] void WebView (WKWebView webView, WKNavigationAction navigationAction, Action<WKNavigationActionPolicy> decisionHandler); // -(void)webView:(WKWebView * _Nonnull)webView didFinishNavigation:(WKNavigation * _Null_unspecified)navigation; [Export ("webView:didFinishNavigation:")] void WebView (WKWebView webView, WKNavigation navigation); } [Static] [Verify (ConstantsInterfaceAssociation)] partial interface Constants { // extern double CFSDKVersionNumber; [Field ("CFSDKVersionNumber", "__Internal")] double CFSDKVersionNumber { get; } // extern const unsigned char [] CFSDKVersionString; [Field ("CFSDKVersionString", "__Internal")] byte[] CFSDKVersionString { get; } }
}
When i compile this i get the errors. Please help.
I checked all the method in CFSDK-Swift.h class , CFViewController has no constructor which takes 4 parameters .
@ColeX - I really appreciate your help. Here is sample IOS code on github. If you look in to this sample app its calling the CFViewController with 4 parameters in the framework but the header files don't have that.
Answers
Here is sample project link
gofile.io/?c=LrKPK8
The link is broken , could you attach the error message here?
@ColeX - please add https:// in beginning of the link
gofile.io/?c=LrKPK8
@ColeX - I am not sure whats wrong with the upload but i am able to download using the link. I will try to explain you here as much as possible about my problem.
I am trying to implement a payment gateway in the xamarin forms application. So i downloaded the payment gateway sdk from their site.
https://docs.cashfree.com/docs/ios/guide/
Now i am trying to convert the framework file to a binding library. Here is what i am getting in the Apidefination file.
using System;
using Foundation;
using UIKit;
using WebKit;
namespace CFSDK
{
// @interface CFViewController : UIViewController
[BaseType (typeof(UIViewController), Name = "_TtC5CFSDK16CFViewController")]
interface CFViewController
{
// -(void)viewDidLoad;
[Export ("viewDidLoad")]
void ViewDidLoad ();
}
}
I need to use the CFViewController from the framework same way i used in the swift project. Can you please help. You can download the framework and sample swift project from the gateway site.
@IBAction func payButton(_ sender: Any) {
// Use below code If you need WEBVIEW CHECKOUT
let cfViewController = CFViewController (
params: getPaymentParams(),
appId: self.appId,
env: self.environment,
callBack: self)
self.navigationController?.pushViewController (cfViewController, animated: true);
Could you attach the exact error message here ?
Could you build the binding library successfully ?
I am able to build the binding library only if i remove the second interface and keep only this one
interface CFViewController
{
// -(void)viewDidLoad;
[Export ("viewDidLoad")]
void ViewDidLoad ();
}
In this interface we have only one method.
When i access the binding library i don't have any constructor which takes 4 parameters where as the class CFViewController
has a constructor with 4 parameters when i use it from swift.
let cfViewController = CFViewController (
params: getPaymentParams(),
appId: self.appId,
env: self.environment,
callBack: self)
self.navigationController?.pushViewController (cfViewController, animated: true);
I checked all the method in CFSDK-Swift.h class , CFViewController has no constructor which takes 4 parameters .
@ColeX - I really appreciate your help. Here is sample IOS code on github. If you look in to this sample app its calling the CFViewController with 4 parameters in the framework but the header files don't have that.
https://github.com/cashfree/ios-CFWebSDK