Forum Xamarin Xamarin.iOS

Help with binding PaymentEngineMiddleware

DeanCleaverDeanCleaver USMember ✭✭✭

I'm trying to get this to work, but I must have made a mistake somewhere. This is the Delegate class (snipped down) as per the C headers:

@protocol PaymentEngineMiddlewareDelegate <NSObject>

@required

/*!
    @brief Delegate method for startTransaction. 
    @param transResponse - Contains all the transaction response info from the gateway
 */
-(void)transactionComplete :(PaymentEngineTransactionResponse *)transResponse;
@optional

/*!
    @brief Delegate method for device connected. The method gets called when the device is connected
 */
-(void)deviceConnected;

/*!
  @brief Delegate method for device disconnected. The method gets called when the device is disconnected
 */
-(void)deviceDisconnected;

@end

For this, I have:

    // @interface PaymentEngineMiddlewareDelegate : NSObject
    [BaseType(typeof(NSObject))]
    [Model]
    [Protocol]
    interface PaymentEngineMiddlewareDelegate
    {
        [Abstract]
        [Export("transactionComplete:")]
        void TransactionComplete(PaymentEngineTransactionResponse transactionResponse);

        [Export("deviceConnected")]
        void DeviceConnected();

        [Export("deviceDisconnected")]
        void DeviceDisconnected();
    }

Then for the PaymentEngineMiddleware class, the header has this:

@interface PaymentEngineMiddleware : NSObject

+ (PaymentEngineMiddleware *) getInstance;

@property(nonatomic, strong) id<PaymentEngineMiddlewareDelegate> delegate;

//------------------------------Device Methods------------------------------

/*!
    @brief This method must be called before starting any transaction. Use it to connect to a device.
    @param deviceName The name of the device such as icmp or castle
    @param setDelegate Sets to self

 */
-(void)setDevice :(NSString *)deviceName :(id)setDelegate;

@end

And for that, I have:

    // @interface PaymentEngineMiddleware : NSObject
    [BaseType(typeof(NSObject))]
    interface PaymentEngineMiddleware
    {
        // +(id)getInstance;
        [Static]
        [Export("getInstance")]
        PaymentEngineMiddleware GetInstance { get; }

        [Export("delegate", ArgumentSemantic.Retain)]
        PaymentEngineMiddlewareDelegate Delegate { get; set; }

        [Export("setDevice:setDelegate:")]
        void SetDevice(string deviceName, PaymentEngineMiddlewareDelegate setDelegate);
    }

Is there anything obvious that I missed or got wrong?

Sign In or Register to comment.