Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions flutter_lyra/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions flutter_lyra/lib/lyra.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ class Lyra {
Future<String> process(
String formToken, {
Duration? timeout,
Map<String?, String?>? options,
}) async {
try {
final lyraResponse = await _platform.process(
formToken,
timeout: timeout,
options: options,
);

return lyraResponse;
Expand Down
8 changes: 4 additions & 4 deletions flutter_lyra/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions flutter_lyra_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion flutter_lyra_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ android {
dependencies {
implementation 'com.lyra:sdk:1.10.0'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,19 @@ public void setTimeoutInSeconds(@Nullable Long setterArg) {
this.timeoutInSeconds = setterArg;
}

private @NonNull Map<String, String> options;

public @NonNull Map<String, String> getOptions() {
return options;
}

public void setOptions(@NonNull Map<String, String> 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() {}

Expand All @@ -351,21 +364,30 @@ public static final class Builder {
return this;
}

private @Nullable Map<String, String> options;

public @NonNull Builder setOptions(@NonNull Map<String, String> 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<Object> toList() {
ArrayList<Object> toListResult = new ArrayList<Object>(3);
ArrayList<Object> toListResult = new ArrayList<Object>(4);
toListResult.add(formToken);
toListResult.add((errorCodes == null) ? null : errorCodes.toList());
toListResult.add(timeoutInSeconds);
toListResult.add(options);
return toListResult;
}

Expand All @@ -377,6 +399,8 @@ ArrayList<Object> toList() {
pigeonResult.setErrorCodes((errorCodes == null) ? null : ErrorCodesInterface.fromList((ArrayList<Object>) 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<String, String>) options);
return pigeonResult;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ class Converters {
return options
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<String, Any?>(
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,
Expand All @@ -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,
Expand All @@ -160,7 +168,8 @@ class FlutterLyraPlugin : FlutterPlugin, ActivityAware, LyraApi.LyraHostApi
)
}
}
}
},
options
)
} catch (error: Throwable) {
cancelProcessJob?.cancel()
Expand All @@ -173,4 +182,4 @@ class FlutterLyraPlugin : FlutterPlugin, ActivityAware, LyraApi.LyraHostApi
)
}
}
}
}
4 changes: 2 additions & 2 deletions flutter_lyra_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions flutter_lyra_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 8 additions & 1 deletion flutter_lyra_ios/ios/Classes/SwitfFlutterLyraPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!,
Expand Down Expand Up @@ -136,7 +142,8 @@ public class SwiftFlutterLyraPlugin: NSObject, FlutterPlugin, LyraHostApi {
)
)
}
}
},
options
)

} catch {
Expand Down
4 changes: 3 additions & 1 deletion flutter_lyra_ios/ios/Classes/lyra_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSString *, NSString *> *)options;
@property(nonatomic, copy) NSString * formToken;
@property(nonatomic, strong) ErrorCodesInterface * errorCodes;
@property(nonatomic, strong, nullable) NSNumber * timeoutInSeconds;
@property(nonatomic, strong) NSDictionary<NSString *, NSString *> * options;
@end

/// The codec used by LyraHostApi.
Expand Down
7 changes: 6 additions & 1 deletion flutter_lyra_ios/ios/Classes/lyra_api.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSString *, NSString *> *)options {
ProcessRequestInterface* pigeonResult = [[ProcessRequestInterface alloc] init];
pigeonResult.formToken = formToken;
pigeonResult.errorCodes = errorCodes;
pigeonResult.timeoutInSeconds = timeoutInSeconds;
pigeonResult.options = options;
return pigeonResult;
}
+ (ProcessRequestInterface *)fromList:(NSArray *)list {
Expand All @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion flutter_lyra_ios/ios/flutter_lyra_ios.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions flutter_lyra_ios/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions flutter_lyra_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ abstract class FlutterLyraPlatform extends PlatformInterface {
Future<String> process(
String formToken, {
Duration? timeout,
Map<String?, String?>? options,
}) =>
lyraHostApi.process(
ProcessRequestInterface(
formToken: formToken,
errorCodes: errorCodesInterface,
timeoutInSeconds: timeout?.inSeconds,
options: options ?? {},
),
);
}
Loading