0

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

@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
4

2 回答 2

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 上。

于 2016-06-02T17:57:59.877 回答
0

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]; 
}
于 2016-05-19T00:49:56.320 回答