用于WePay的Xamarin.iOS绑定

时间:2016-05-19 00:14:48

标签: ios objective-c xamarin xamarin.ios objective-sharpie

我正在使用Objective sharpie为WePay.iOS SDK创建一个Xamarin绑定。 https://github.com/wepay/wepay-ios

我已经设法构建了APIDefinition.cs和StructsAndEnums.cs文件。但是,当我创建绑定项目时,它不能成功编译。

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

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

我知道我需要将NSOBject更改为正确的数据类型。但是,当我查看Objective C文件时。我真的不知道我应该使用什么数据类型。如果有人能指导我,我感激不尽。

Objective-C Class

@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

2 个答案:

答案 0 :(得分:0)

swipedInfo和emvInfo在内部属于NSMutableDictionary类型。

请参阅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]; 
}

答案 1 :(得分:0)

@ y2chaits Xamarin在Mono之上运行,它是C#。 C#不允许使用相同的签名进行重载。因此,最好创建具体的数据类型。当你改变WPAddress时,你做了类似的想法。

在这种情况下,您可以将一个构造函数设置为NSObject,将第二个构造函数设置为NSDictionary(请参阅此处:https://github.com/dikoga/WePayBinding/blob/master/WePayBinding/ApiDefinition.cs)。而且你会很好。

但是,这个绑定已经完成了。它正在构建,但它有一个问题(http://forums.xamarin.com/discussion/66446/how-to-get-more-information-when-the-app-crashes)。也许你可以付出一些努力来帮助它起作用,因为它已经在github上了。