diff --git a/flutter_lyra/CHANGELOG.md b/flutter_lyra/CHANGELOG.md index d8d84c7..8e99131 100644 --- a/flutter_lyra/CHANGELOG.md +++ b/flutter_lyra/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.6.1 + +- **FEAT** Add process option to be able to set CUSTOM_PAY_BUTTON_LABEL, CUSTOM_HEADER_LABEL and CUSTOM_POPUP_LABEL + # 0.6.0 - **BREAKING CHANGE**: [Android] Update min and compile SDK versions to match Flutter's diff --git a/flutter_lyra/lib/lyra.dart b/flutter_lyra/lib/lyra.dart index 2c1b53a..6cd3855 100644 --- a/flutter_lyra/lib/lyra.dart +++ b/flutter_lyra/lib/lyra.dart @@ -52,11 +52,13 @@ class Lyra { Future process( String formToken, { Duration? timeout, + Map? options, }) async { try { final lyraResponse = await _platform.process( formToken, timeout: timeout, + options: options, ); return lyraResponse; diff --git a/flutter_lyra/pubspec.yaml b/flutter_lyra/pubspec.yaml index 9d5f2db..a061415 100644 --- a/flutter_lyra/pubspec.yaml +++ b/flutter_lyra/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_lyra description: This package allows you to use the methods from the lyra android and ios native sdks in Flutter -version: 0.6.0 +version: 0.6.1 homepage: https://github.com/bamlab/Flutter-Lyra repository: https://github.com/bamlab/Flutter-Lyra @@ -22,9 +22,9 @@ dependencies: equatable: ^2.0.5 flutter: sdk: flutter - flutter_lyra_android: ^0.6.0 - flutter_lyra_ios: ^0.6.0 - flutter_lyra_platform_interface: ^0.6.0 + flutter_lyra_android: ^0.6.1 + flutter_lyra_ios: ^0.6.1 + flutter_lyra_platform_interface: ^0.6.1 dev_dependencies: analyzer: ^4.7.0 flutter_test: diff --git a/flutter_lyra_android/CHANGELOG.md b/flutter_lyra_android/CHANGELOG.md index 065c70f..692ffa0 100644 --- a/flutter_lyra_android/CHANGELOG.md +++ b/flutter_lyra_android/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.6.1 + +- **FEAT** Add process option to be able to set CUSTOM_PAY_BUTTON_LABEL, CUSTOM_HEADER_LABEL and CUSTOM_POPUP_LABEL + # 0.6.0 - **BREAKING CHANGE**: [Android] Update min and compile SDK versions to match Flutter's diff --git a/flutter_lyra_android/android/build.gradle b/flutter_lyra_android/android/build.gradle index 74cfd95..86706e6 100644 --- a/flutter_lyra_android/android/build.gradle +++ b/flutter_lyra_android/android/build.gradle @@ -49,4 +49,4 @@ android { dependencies { implementation 'com.lyra:sdk:1.10.0' } -} \ No newline at end of file +} diff --git a/flutter_lyra_android/android/src/main/java/tech/bam/flutter_lyra/android/LyraApi.java b/flutter_lyra_android/android/src/main/java/tech/bam/flutter_lyra/android/LyraApi.java index 8c40952..b57c984 100644 --- a/flutter_lyra_android/android/src/main/java/tech/bam/flutter_lyra/android/LyraApi.java +++ b/flutter_lyra_android/android/src/main/java/tech/bam/flutter_lyra/android/LyraApi.java @@ -325,6 +325,19 @@ public void setTimeoutInSeconds(@Nullable Long setterArg) { this.timeoutInSeconds = setterArg; } + private @NonNull Map options; + + public @NonNull Map getOptions() { + return options; + } + + public void setOptions(@NonNull Map setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"options\" is null."); + } + this.options = setterArg; + } + /** Constructor is private to enforce null safety; use Builder. */ private ProcessRequestInterface() {} @@ -351,21 +364,30 @@ public static final class Builder { return this; } + private @Nullable Map options; + + public @NonNull Builder setOptions(@NonNull Map setterArg) { + this.options = setterArg; + return this; + } + public @NonNull ProcessRequestInterface build() { ProcessRequestInterface pigeonReturn = new ProcessRequestInterface(); pigeonReturn.setFormToken(formToken); pigeonReturn.setErrorCodes(errorCodes); pigeonReturn.setTimeoutInSeconds(timeoutInSeconds); + pigeonReturn.setOptions(options); return pigeonReturn; } } @NonNull ArrayList toList() { - ArrayList toListResult = new ArrayList(3); + ArrayList toListResult = new ArrayList(4); toListResult.add(formToken); toListResult.add((errorCodes == null) ? null : errorCodes.toList()); toListResult.add(timeoutInSeconds); + toListResult.add(options); return toListResult; } @@ -377,6 +399,8 @@ ArrayList toList() { pigeonResult.setErrorCodes((errorCodes == null) ? null : ErrorCodesInterface.fromList((ArrayList) errorCodes)); Object timeoutInSeconds = list.get(2); pigeonResult.setTimeoutInSeconds((timeoutInSeconds == null) ? null : ((timeoutInSeconds instanceof Integer) ? (Integer) timeoutInSeconds : (Long) timeoutInSeconds)); + Object options = list.get(3); + pigeonResult.setOptions((Map) options); return pigeonResult; } } diff --git a/flutter_lyra_android/android/src/main/kotlin/tech/bam/flutter_lyra/android/Converters.kt b/flutter_lyra_android/android/src/main/kotlin/tech/bam/flutter_lyra/android/Converters.kt index fd14d25..b330087 100644 --- a/flutter_lyra_android/android/src/main/kotlin/tech/bam/flutter_lyra/android/Converters.kt +++ b/flutter_lyra_android/android/src/main/kotlin/tech/bam/flutter_lyra/android/Converters.kt @@ -40,4 +40,4 @@ class Converters { return options } } -} \ No newline at end of file +} diff --git a/flutter_lyra_android/android/src/main/kotlin/tech/bam/flutter_lyra/android/FlutterLyraPlugin.kt b/flutter_lyra_android/android/src/main/kotlin/tech/bam/flutter_lyra/android/FlutterLyraPlugin.kt index 6cfb1b9..8157423 100644 --- a/flutter_lyra_android/android/src/main/kotlin/tech/bam/flutter_lyra/android/FlutterLyraPlugin.kt +++ b/flutter_lyra_android/android/src/main/kotlin/tech/bam/flutter_lyra/android/FlutterLyraPlugin.kt @@ -13,8 +13,7 @@ import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding import kotlinx.coroutines.* import java.util.concurrent.TimeUnit -class FlutterLyraPlugin : FlutterPlugin, ActivityAware, LyraApi.LyraHostApi -{ +class FlutterLyraPlugin : FlutterPlugin, ActivityAware, LyraApi.LyraHostApi { private var context: Context? = null private var activity: Activity? = null @@ -123,12 +122,18 @@ class FlutterLyraPlugin : FlutterPlugin, ActivityAware, LyraApi.LyraHostApi var cancelProcessJob: Job? = null if (timeout != null) { - cancelProcessJob = GlobalScope.launch { + cancelProcessJob = GlobalScope.launch { delay(TimeUnit.SECONDS.toMillis(timeout)) Lyra.cancelProcess() } } + val options = hashMapOf( + Lyra.CUSTOM_PAY_BUTTON_LABEL to request.options["CUSTOM_PAY_BUTTON_LABEL"], + Lyra.CUSTOM_HEADER_LABEL to request.options["CUSTOM_HEADER_LABEL"], + Lyra.CUSTOM_POPUP_LABEL to request.options["CUSTOM_POPUP_LABEL"] + ) + try { Lyra.process( fragmentManager = flutterActivity.supportFragmentManager, @@ -139,14 +144,17 @@ class FlutterLyraPlugin : FlutterPlugin, ActivityAware, LyraApi.LyraHostApi result.success(lyraResponse.toString()) } - override fun onError(lyraException: LyraException, lyraResponse: LyraResponse?) { + override fun onError( + lyraException: LyraException, + lyraResponse: LyraResponse? + ) { cancelProcessJob?.cancel() // We do not complete with error if errorCode is "MOB_013". // This error indicate that the payment process cannot be cancelled. // After this error, normal SDK behavior continues: // if the payment completes successfully then the onSuccess handler will be called. // if the payment is failed. Depending on the error, the payment form remains displayed or the onError handler will be called. - if(lyraException.errorCode != "MOB_013") { + if (lyraException.errorCode != "MOB_013") { result.error( Converters.parseError( lyraError = lyraException, @@ -160,7 +168,8 @@ class FlutterLyraPlugin : FlutterPlugin, ActivityAware, LyraApi.LyraHostApi ) } } - } + }, + options ) } catch (error: Throwable) { cancelProcessJob?.cancel() @@ -173,4 +182,4 @@ class FlutterLyraPlugin : FlutterPlugin, ActivityAware, LyraApi.LyraHostApi ) } } -} \ No newline at end of file +} diff --git a/flutter_lyra_android/pubspec.yaml b/flutter_lyra_android/pubspec.yaml index be2768b..995e144 100644 --- a/flutter_lyra_android/pubspec.yaml +++ b/flutter_lyra_android/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_lyra_android description: Android implementation of the flutter_lyra plugin -version: 0.6.0 +version: 0.6.1 homepage: https://github.com/bamlab/Flutter-Lyra repository: https://github.com/bamlab/Flutter-Lyra @@ -22,7 +22,7 @@ flutter: dependencies: flutter: sdk: flutter - flutter_lyra_platform_interface: ^0.6.0 + flutter_lyra_platform_interface: ^0.6.1 dev_dependencies: analyzer: ^5.13.0 flutter_test: diff --git a/flutter_lyra_ios/CHANGELOG.md b/flutter_lyra_ios/CHANGELOG.md index 7c18962..3a5b042 100644 --- a/flutter_lyra_ios/CHANGELOG.md +++ b/flutter_lyra_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.6.1 + +- **FEAT** Add process option to be able to set CUSTOM_PAY_BUTTON_LABEL, CUSTOM_HEADER_LABEL and CUSTOM_POPUP_LABEL + # 0.6.0 - **BREAKING CHANGE**: [Android] Update min and compile SDK versions to match Flutter's diff --git a/flutter_lyra_ios/ios/Classes/SwitfFlutterLyraPlugin.swift b/flutter_lyra_ios/ios/Classes/SwitfFlutterLyraPlugin.swift index 79f28d5..b85bdda 100644 --- a/flutter_lyra_ios/ios/Classes/SwitfFlutterLyraPlugin.swift +++ b/flutter_lyra_ios/ios/Classes/SwitfFlutterLyraPlugin.swift @@ -104,6 +104,12 @@ public class SwiftFlutterLyraPlugin: NSObject, FlutterPlugin, LyraHostApi { DispatchQueue.main.asyncAfter(deadline: dispatchTime, execute: cancelProcessWork!) } + let options = [ + LyraPaymentOptions.customPopupLabel: request.options["CUSTOM_POPUP_LABEL"], + LyraPaymentOptions.customHeaderLabel: request.options["CUSTOM_HEADER_LABEL"], + LyraPaymentOptions.customPayButtonLabel: request.options["CUSTOM_PAY_BUTTON_LABEL"] + ] + do { try Lyra.process( viewController!, @@ -136,7 +142,8 @@ public class SwiftFlutterLyraPlugin: NSObject, FlutterPlugin, LyraHostApi { ) ) } - } + }, + options ) } catch { diff --git a/flutter_lyra_ios/ios/Classes/lyra_api.h b/flutter_lyra_ios/ios/Classes/lyra_api.h index 1269e35..12a2437 100644 --- a/flutter_lyra_ios/ios/Classes/lyra_api.h +++ b/flutter_lyra_ios/ios/Classes/lyra_api.h @@ -51,10 +51,12 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithFormToken:(NSString *)formToken errorCodes:(ErrorCodesInterface *)errorCodes - timeoutInSeconds:(nullable NSNumber *)timeoutInSeconds; + timeoutInSeconds:(nullable NSNumber *)timeoutInSeconds + options:(NSDictionary *)options; @property(nonatomic, copy) NSString * formToken; @property(nonatomic, strong) ErrorCodesInterface * errorCodes; @property(nonatomic, strong, nullable) NSNumber * timeoutInSeconds; +@property(nonatomic, strong) NSDictionary * options; @end /// The codec used by LyraHostApi. diff --git a/flutter_lyra_ios/ios/Classes/lyra_api.m b/flutter_lyra_ios/ios/Classes/lyra_api.m index cb865d9..462f891 100644 --- a/flutter_lyra_ios/ios/Classes/lyra_api.m +++ b/flutter_lyra_ios/ios/Classes/lyra_api.m @@ -139,11 +139,13 @@ - (NSArray *)toList { @implementation ProcessRequestInterface + (instancetype)makeWithFormToken:(NSString *)formToken errorCodes:(ErrorCodesInterface *)errorCodes - timeoutInSeconds:(nullable NSNumber *)timeoutInSeconds { + timeoutInSeconds:(nullable NSNumber *)timeoutInSeconds + options:(NSDictionary *)options { ProcessRequestInterface* pigeonResult = [[ProcessRequestInterface alloc] init]; pigeonResult.formToken = formToken; pigeonResult.errorCodes = errorCodes; pigeonResult.timeoutInSeconds = timeoutInSeconds; + pigeonResult.options = options; return pigeonResult; } + (ProcessRequestInterface *)fromList:(NSArray *)list { @@ -153,6 +155,8 @@ + (ProcessRequestInterface *)fromList:(NSArray *)list { pigeonResult.errorCodes = [ErrorCodesInterface nullableFromList:(GetNullableObjectAtIndex(list, 1))]; NSAssert(pigeonResult.errorCodes != nil, @""); pigeonResult.timeoutInSeconds = GetNullableObjectAtIndex(list, 2); + pigeonResult.options = GetNullableObjectAtIndex(list, 3); + NSAssert(pigeonResult.options != nil, @""); return pigeonResult; } + (nullable ProcessRequestInterface *)nullableFromList:(NSArray *)list { @@ -163,6 +167,7 @@ - (NSArray *)toList { (self.formToken ?: [NSNull null]), (self.errorCodes ? [self.errorCodes toList] : [NSNull null]), (self.timeoutInSeconds ?: [NSNull null]), + (self.options ?: [NSNull null]), ]; } @end diff --git a/flutter_lyra_ios/ios/flutter_lyra_ios.podspec b/flutter_lyra_ios/ios/flutter_lyra_ios.podspec index a9f52c1..92839bb 100644 --- a/flutter_lyra_ios/ios/flutter_lyra_ios.podspec +++ b/flutter_lyra_ios/ios/flutter_lyra_ios.podspec @@ -20,6 +20,6 @@ Pod::Spec.new do |s| s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } s.swift_version = '5.0' - s.dependency 'LyraPaymentSDK', '~> 2.8.0' + s.dependency 'LyraPaymentSDK', '~> 2.8.6' s.dependency 'LyraCardsRecognizer', '~> 2.0.2' end diff --git a/flutter_lyra_ios/pubspec.yaml b/flutter_lyra_ios/pubspec.yaml index 20814af..27aa72e 100644 --- a/flutter_lyra_ios/pubspec.yaml +++ b/flutter_lyra_ios/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_lyra_ios description: iOS implementation of the flutter_lyra plugin -version: 0.6.0 +version: 0.6.1 homepage: https://github.com/bamlab/Flutter-Lyra repository: https://github.com/bamlab/Flutter-Lyra @@ -19,7 +19,7 @@ flutter: dependencies: flutter: sdk: flutter - flutter_lyra_platform_interface: ^0.6.0 + flutter_lyra_platform_interface: ^0.6.1 dev_dependencies: analyzer: ^4.7.0 flutter_test: diff --git a/flutter_lyra_platform_interface/CHANGELOG.md b/flutter_lyra_platform_interface/CHANGELOG.md index a1e29d8..cb8a77f 100644 --- a/flutter_lyra_platform_interface/CHANGELOG.md +++ b/flutter_lyra_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.6.1 + +- **FEAT** Add process option to be able to set CUSTOM_PAY_BUTTON_LABEL, CUSTOM_HEADER_LABEL and CUSTOM_POPUP_LABEL + # 0.6.0 - **BREAKING CHANGE**: [Android] Update min and compile SDK versions to match Flutter's diff --git a/flutter_lyra_platform_interface/lib/src/flutter_lyra_platform.dart b/flutter_lyra_platform_interface/lib/src/flutter_lyra_platform.dart index c327871..b82c67f 100644 --- a/flutter_lyra_platform_interface/lib/src/flutter_lyra_platform.dart +++ b/flutter_lyra_platform_interface/lib/src/flutter_lyra_platform.dart @@ -64,12 +64,14 @@ abstract class FlutterLyraPlatform extends PlatformInterface { Future process( String formToken, { Duration? timeout, + Map? options, }) => lyraHostApi.process( ProcessRequestInterface( formToken: formToken, errorCodes: errorCodesInterface, timeoutInSeconds: timeout?.inSeconds, + options: options ?? {}, ), ); } diff --git a/flutter_lyra_platform_interface/lib/src/lyra.g.dart b/flutter_lyra_platform_interface/lib/src/lyra.g.dart index fea23d1..f4b9368 100644 --- a/flutter_lyra_platform_interface/lib/src/lyra.g.dart +++ b/flutter_lyra_platform_interface/lib/src/lyra.g.dart @@ -91,8 +91,7 @@ class LyraKeyInterface { result as List; return LyraKeyInterface( publicKey: result[0]! as String, - options: - LyraInitializeOptionsInterface.decode(result[1]! as List), + options: LyraInitializeOptionsInterface.decode(result[1]! as List), ); } } @@ -102,6 +101,7 @@ class ProcessRequestInterface { required this.formToken, required this.errorCodes, this.timeoutInSeconds, + required this.options, }); String formToken; @@ -110,11 +110,14 @@ class ProcessRequestInterface { int? timeoutInSeconds; + Map options; + Object encode() { return [ formToken, errorCodes.encode(), timeoutInSeconds, + options, ]; } @@ -124,6 +127,7 @@ class ProcessRequestInterface { formToken: result[0]! as String, errorCodes: ErrorCodesInterface.decode(result[1]! as List), timeoutInSeconds: result[2] as int?, + options: (result[3] as Map?)!.cast(), ); } } @@ -152,13 +156,13 @@ class _LyraHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ErrorCodesInterface.decode(readValue(buffer)!); - case 129: + case 129: return LyraInitializeOptionsInterface.decode(readValue(buffer)!); - case 130: + case 130: return LyraKeyInterface.decode(readValue(buffer)!); - case 131: + case 131: return ProcessRequestInterface.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -207,7 +211,8 @@ class LyraHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.LyraHostApi.getFormTokenVersion', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel.send(null) as List?; + final List? replyList = + await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', diff --git a/flutter_lyra_platform_interface/pigeons/lyra.dart b/flutter_lyra_platform_interface/pigeons/lyra.dart index ef52b2b..59ecfc3 100644 --- a/flutter_lyra_platform_interface/pigeons/lyra.dart +++ b/flutter_lyra_platform_interface/pigeons/lyra.dart @@ -52,11 +52,13 @@ class ProcessRequestInterface { required this.formToken, required this.errorCodes, this.timeoutInSeconds, + this.options = const {}, }); final String formToken; final ErrorCodesInterface errorCodes; final int? timeoutInSeconds; + final Map options; } @HostApi() diff --git a/flutter_lyra_platform_interface/pubspec.yaml b/flutter_lyra_platform_interface/pubspec.yaml index 8009eff..5b94964 100644 --- a/flutter_lyra_platform_interface/pubspec.yaml +++ b/flutter_lyra_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_lyra_platform_interface description: A common platform interface for the flutter_lyra plugin. -version: 0.6.0 +version: 0.6.1 homepage: https://github.com/bamlab/Flutter-Lyra repository: https://github.com/bamlab/Flutter-Lyra diff --git a/flutter_lyra_platform_interface/test/src/flutter_lyra_platform_test.dart b/flutter_lyra_platform_interface/test/src/flutter_lyra_platform_test.dart index 4cacf83..48a0e8e 100644 --- a/flutter_lyra_platform_interface/test/src/flutter_lyra_platform_test.dart +++ b/flutter_lyra_platform_interface/test/src/flutter_lyra_platform_test.dart @@ -78,6 +78,7 @@ void main() { ProcessRequestInterface( formToken: formToken, errorCodes: errorCodesInterface, + options: {}, ), ); when(