簡體   English   中英

Xamarin.iOS綁定到WePay

[英]Xamarin.iOS binding for WePay

我正在使用客觀的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

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上,也許您可​​以付出一些努力來使其工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM