BreX900 / mek-packages

10 stars 13 forks source link

Resolve tap to pay connected account issue on iOS #62

Closed jermaine-uome closed 1 month ago

jermaine-uome commented 3 months ago

Description

This pull request contains the fix for the following related issue raised a couple of weeks ago: https://github.com/BreX900/mek-packages/issues/50

It appears that the reason why tap to pay wasn't working for connected accounts was due to not being able to set the connected account id when instantiating LocalMobileConnectionConfigurationBuilder in the onConnectMobileReader method in Terminal.swift.

The onConnectMobileReader method not accepts an onBehalfOf field which is sent to the configuration builder:

// stripe_terminal/ios/Classes/TerminalPlugin.swift

func onConnectMobileReader(
        _ serialNumber: String,
        _ locationId: String,
        _ autoReconnectOnUnexpectedDisconnect: Bool
        _ autoReconnectOnUnexpectedDisconnect: Bool,
        _ onBehalfOf: String? // <-----
    ) async throws -> ReaderApi {
        let config = LocalMobileConnectionConfigurationBuilder(locationId: locationId)
            .setOnBehalfOf(onBehalfOf) // <-----
            .setAutoReconnectOnUnexpectedDisconnect(autoReconnectOnUnexpectedDisconnect)
            .setAutoReconnectionDelegate(_readerReconnectionDelegate)
 ...
...

On the Flutter side the platform api method now looks like this:

// stripe_terminal/lib/src/platform/terminal_platform.dart

Future<Reader> connectMobileReader(
    String serialNumber, {
    required String locationId,
    required bool autoReconnectOnUnexpectedDisconnect,
    String? onBehalfOf, // <------
});

To confirm I did run the following command for generating the code to communicate between Flutter and Android/iOS platforms:

dart run tool/generate_api.dart
martinzuro commented 2 months ago

Any news on this? I need to send the "onBehalfOf" parameter. Thanks

BreX900 commented 1 month ago

@jermaine-uome Can you format dart files with 100 page width? Also for commits follow the convention: https://www.conventionalcommits.org/en/v1.0.0/

BreX900 commented 1 month ago

Closed in favour of #74