1

I'm building a NativeScript plugin for iOS to integrate a card payment terminal as an external accessory. It is almost done, and working, but I have problem with passing one argument called "optionals". This is the whole code I'm trying to implement. It's the payworks framework for a Miura terminal. http://www.payworks.mpymnt.com/node/143

MPTransactionParameters *tp = [MPTransactionParameters chargeWithAmount:[NSDecimalNumber decimalNumberWithString:@"5.00"]
                                                               currency:MPCurrencyEUR
                                                              optionals:^(id<MPTransactionParametersOptionals>  _Nonnull optionals) {
                                                                  optionals.subject = @"Bouquet of Flowers";
                                                                  optionals.customIdentifier = @"yourReferenceForTheTransaction";
                                                              }];

I cannot find a way of sending this "optionals" function.

In the generate typing metadata I see the MPTransactionParametersOptionals is a @protocol, but still don't know how to use it here as a parameter.

This is my current javascript code for the block

const tp = MPTransactionParameters.chargeWithAmountCurrencyOptionals(
    amount,
    MPCurrencyEUR,
    function (optionals) {
        console.log(optionals); //logs the newly created MPTransactionParameters instance, with set amount and currency properties, but cannot touch or set the optional properties.
    }
  );

The 3rd parameter of chargeWithAmountCurrencyOptionals() should be a function, but I'm doing it wrong, and searched everywhere in google how to do it but no success. I'm already trying for 2 days.

It is working, when the 3rd parameter is null, but I need the set the optional properties.

EDIT: adding the metadata. There are a lot of typings for MPtransactionParameters, so I decided to give you the whole file so you can search.

https://drive.google.com/open?id=1kvDoXtGbCoeCT20b9_t2stc2Qts3VyQx

EDIT2: Adding the typings:

https://drive.google.com/open?id=1lZ3ULYHbX7DXdUQMPoZeSfyEZrjItSOS

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Did you try generating typings, that might give you some clarity on what data type the parameter is expecting. – Manoj Feb 20 '20 at 16:11
  • Yes, please edit the question to share the typings. A function seems logical (as the Obj-C function takes a block), but, seeing that it's not working, I do wonder whether you need to pass it a selector instead. – Jamie Birch Feb 20 '20 at 16:17
  • Updated the post with the typings yaml file. – Georgi Ivanov Feb 20 '20 at 17:11
  • Can you please check the tns-ios version of yours and check if it's 6.4.1? As I was having a similar kind of problem in marshaling and I was not getting the method. Typings were okay and showing the method but my javascript code can't get it. You can refer the issue raised on Github here if it can help you. [ios-runtime](https://github.com/NativeScript/ios-runtime/issues/1251) – Heena Vora Feb 21 '20 at 06:30
  • Mine is currently 6.3.3, should I update? – Georgi Ivanov Feb 21 '20 at 07:28

0 Answers0