Xamarin.iOS binding for WePay



我正在使用objectivesharpie为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类

@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和emvInfo在内部属于NSMutableDictionary类型。

请参阅此处:

- (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运行在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上了。

最新更新