简体   繁体   English

Xamarin.iOS绑定到WePay

[英]Xamarin.iOS binding for WePay

I am creating a Xamarin binding for the WePay.iOS SDK using objective sharpie. 我正在使用客观的Sharpie为WePay.iOS SDK创建Xamarin绑定。 https://github.com/wepay/wepay-ios https://github.com/wepay/wepay-ios

I have managed to build the APIDefinition.cs and StructsAndEnums.cs files. 我已经成功构建了APIDefinition.cs和StructsAndEnums.cs文件。 However when I created the binding project, it does not compile successfully. 但是,当我创建绑定项目时,它不会成功编译。

[Export ("initWithSwipedInfo:")]
    IntPtr Constructor (NSObject swipedInfo);

    // -(instancetype)initWithEMVInfo:(id)emvInfo;
    [Export ("initWithEMVInfo:")]
    IntPtr Constructor (NSObject emvInfo);

I understand that I need to change the NSOBject to the correct datatype. 我了解我需要将NSOBject更改为正确的数据类型。 However, when I look into the Objective C file. 但是,当我查看Objective C文件时。 I cant really make sense of what datatype should I be using. 我真的不知道我应该使用哪种数据类型。 I appreciate if someone can guide me in it. 我很高兴有人可以指导我。

Objective-C Class Objective-C类

@interface WPPaymentInfo : NSObject
@property (nonatomic, strong, readonly) NSString *firstName;
@property (nonatomic, strong, readonly) NSString *lastName;
@property (nonatomic, strong, readonly) NSString *email;
@property (nonatomic, strong, readonly) NSString *paymentDescription;
@property (nonatomic, readonly) BOOL isVirtualTerminal;
@property (nonatomic, strong, readonly) WPAddress *billingAddress;
@property (nonatomic, strong, readonly) WPAddress *shippingAddress;
@property (nonatomic, strong, readonly) id paymentMethod;
@property (nonatomic, strong, readonly) id swiperInfo;
@property (nonatomic, strong, readonly) id manualInfo;
@property (nonatomic, strong, readonly) id emvInfo;

- (instancetype) initWithSwipedInfo:(id)swipedInfo;
- (instancetype) initWithEMVInfo:(id)emvInfo;
- (instancetype) initWithFirstName:(NSString *)firstName
                      lastName:(NSString *)lastName
                         email:(NSString *)email
                billingAddress:(WPAddress *)billingAddress
               shippingAddress:(WPAddress *)shippingAddress
                    cardNumber:(NSString *)cardNumber
                           cvv:(NSString *)cvv
                      expMonth:(NSString *)expMonth
                       expYear:(NSString *)expYear
               virtualTerminal:(BOOL)virtualTerminal;

- (void) addEmail:(NSString *)email;
@end

swipedInfo and emvInfo are internally of type NSMutableDictionary. swipedInfo和emvInfo在内部为NSMutableDictionary类型。

See here : 这里

- (void) handleSwipeResponse:(NSDictionary *) responseData 
{
    NSDictionary *info = @{@"firstName"         : [WPRoamHelper firstNameFromRUAData:responseData],
                           @"lastName"          : [WPRoamHelper lastNameFromRUAData:responseData],
                           @"paymentDescription": pan ? pan : @"",
                           @"swiperInfo"        : responseData
                        };

    WPPaymentInfo *paymentInfo = [[WPPaymentInfo alloc] initWithSwipedInfo:info]; 
}

@y2chaits Xamarin runs on top of Mono and it is C#. @ y2chaits Xamarin在Mono之上运行,它是C#。 C# does not allow overload with the same signature. C#不允许具有相同签名的重载。 So, it is good to create concrete datatype instead. 因此,最好创建具体的数据类型。 You did similar think when you've changed WPAddress. 更改WPAddress后,您也有类似的想法。

In this case you can set one constructor to NSObject and the second to NSDictionary (see here: https://github.com/dikoga/WePayBinding/blob/master/WePayBinding/ApiDefinition.cs ). 在这种情况下,您可以将一个构造函数设置为NSObject,将第二个构造函数设置为NSDictionary(请参见此处: https : //github.com/dikoga/WePayBinding/blob/master/WePayBinding/ApiDefinition.cs )。 And you will be good. 而且你会很好。

However, this bind is already done. 但是,此绑定已完成。 It is building but it has one issue ( http://forums.xamarin.com/discussion/66446/how-to-get-more-information-when-the-app-crashes ). 它正在构建中,但存在一个问题( http://forums.xamarin.com/discussion/66446/how-to-get-more-information-when-the-app-crashes )。 Maybe you can put some effort to help make it works since it is already on github. 由于它已经在github上,也许您可​​以付出一些努力来使其工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM