:drunk: Werid miniapp runtime

This commit is contained in:
2026-01-18 13:31:45 +08:00
parent fa0051b606
commit 639417e952
33 changed files with 6437 additions and 3 deletions

336
lib/modular/api/README.md Normal file
View File

@@ -0,0 +1,336 @@
# Payment API for Mini-Apps
## Overview
Payment API (`lib/modular/api/payment.dart`) provides a simple interface for mini-apps to process payments without needing access to Riverpod or Flutter widget trees.
## Usage
### Basic Setup
```dart
import 'package:island/modular/api/payment.dart';
// Get singleton instance
final paymentAPI = PaymentAPI.instance;
```
### Creating a Payment Order
```dart
final order = await paymentAPI.createOrder(
CreateOrderRequest(
amount: 1000, // $10.00 in cents
currency: 'USD',
remarks: 'Premium subscription',
payeeWalletId: 'wallet_123',
appIdentifier: 'my.miniapp',
),
);
// Use the order ID for payment
final orderId = order.id;
```
### Processing Payment with Overlay
```dart
final result = await paymentAPI.processPaymentWithOverlay(
context: context,
createOrderRequest: CreateOrderRequest(
amount: 1000,
currency: 'USD',
remarks: 'Premium subscription',
),
enableBiometric: true,
);
if (result.success) {
print('Payment successful: ${result.order}');
} else {
print('Payment failed: ${result.error}');
}
```
### Processing Existing Payment
```dart
final result = await paymentAPI.processPaymentWithOverlay(
context: context,
request: PaymentRequest(
orderId: 'order_123',
amount: 1000,
currency: 'USD',
pinCode: '123456',
enableBiometric: true,
showOverlay: true,
),
);
```
### Processing Payment Without Overlay (Direct)
```dart
final result = await paymentAPI.processDirectPayment(
PaymentRequest(
orderId: 'order_123',
amount: 1000,
currency: 'USD',
pinCode: '123456',
enableBiometric: false, // No biometric for direct
),
);
if (result.success) {
// Handle success
} else {
// Handle error
}
```
## API Methods
### `createOrder(CreateOrderRequest)`
Creates a new payment order on the server.
**Parameters:**
- `amount` (required): Amount in smallest currency unit (cents for USD, etc.)
- `currency` (required): Currency code (e.g., 'USD', 'EUR')
- `remarks` (optional): Payment description
- `payeeWalletId` (optional): Target wallet ID
- `appIdentifier` (optional): Mini-app identifier
- `meta` (optional): Additional metadata
**Returns:** `SnWalletOrder?` or throws exception
### `processPayment({String orderId, String pinCode, bool enableBiometric})`
Processes a payment for an existing order. Must be called from within mini-app context.
**Parameters:**
- `orderId` (required): Order ID to process
- `pinCode` (required): 6-digit PIN code
- `enableBiometric` (optional, default: true): Allow biometric authentication
**Returns:** `SnWalletOrder?` or throws exception
### `processPaymentWithOverlay({BuildContext, PaymentRequest?, CreateOrderRequest?, bool enableBiometric})`
Shows payment overlay UI and processes payment. Use this for user-facing payments.
**Parameters:**
- `context` (required): BuildContext for showing overlay
- `request` (optional): Existing payment request with orderId
- `createOrderRequest` (optional): New order request (must provide one)
- `enableBiometric` (optional, default: true): Enable biometric authentication
**Returns:** `PaymentResult`
### `processDirectPayment(PaymentRequest)`
Processes payment without showing UI overlay. Use for automatic/background payments.
**Parameters:**
- `request` (required): PaymentRequest with all details including pinCode
**Returns:** `PaymentResult`
## Data Types
### `PaymentRequest`
```dart
const factory PaymentRequest({
required String orderId,
required int amount,
required String currency,
String? remarks,
String? payeeWalletId,
String? pinCode,
@Default(true) bool showOverlay,
@Default(true) bool enableBiometric,
});
```
### `CreateOrderRequest`
```dart
const factory CreateOrderRequest({
required int amount,
required String currency,
String? remarks,
String? payeeWalletId,
String? appIdentifier,
@Default({}) Map<String, dynamic> meta,
});
```
### `PaymentResult`
```dart
const factory PaymentResult({
required bool success,
SnWalletOrder? order,
String? error,
String? errorCode,
});
```
## Error Handling
The API handles common error scenarios:
- **401/403**: Invalid PIN code
- **400**: Payment error with message
- **404**: Order not found
- **503**: Service unavailable/maintenance
- **Network errors**: Connection issues
## Internals
The API:
- Uses a singleton pattern (`PaymentAPI.instance`)
- Manages its own Dio instance with proper interceptors
- Reads server URL and token from SharedPreferences
- Handles authentication automatically
- Reuses existing `PaymentOverlay` widget for UI
## Complete Example
```dart
import 'package:flutter/material.dart';
import 'package:island/modular/api/payment.dart';
class MiniAppPayment extends StatelessWidget {
const MiniAppPayment({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Payment Example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () => _processWithOverlay(context),
child: const Text('Pay $10.00 (with overlay)'),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => _processDirect(context),
child: const Text('Pay $10.00 (direct)'),
),
],
),
),
);
}
Future<void> _processWithOverlay(BuildContext context) async {
final api = PaymentAPI.instance;
final result = await api.processPaymentWithOverlay(
context: context,
createOrderRequest: CreateOrderRequest(
amount: 1000, // $10.00
currency: 'USD',
remarks: 'Test payment from mini-app',
appIdentifier: 'com.example.miniapp',
),
enableBiometric: true,
);
if (!context.mounted) return;
if (result.success) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Payment successful!')),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Payment failed: ${result.error}'),
backgroundColor: Colors.red,
),
);
}
}
Future<void> _processDirect(BuildContext context) async {
final api = PaymentAPI.instance;
final result = await api.processDirectPayment(
PaymentRequest(
orderId: 'order_${DateTime.now().millisecondsSinceEpoch}',
amount: 1000,
currency: 'USD',
pinCode: '123456', // Should come from user input
enableBiometric: false,
),
);
if (!context.mounted) return;
if (result.success) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Payment successful!')),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Payment failed: ${result.error}'),
backgroundColor: Colors.red,
),
);
}
}
}
```
## Notes
- All methods are async and return Futures
- Errors are thrown as exceptions, catch and handle in your mini-app
- PIN codes must be 6 digits
- Amount is in smallest currency unit (cents for USD)
- Token is managed internally, no need to provide it
- Server URL is loaded from app preferences
## Integration with flutter_eval
To expose this API to mini-apps loaded via flutter_eval:
1. Add to plugin registry:
```dart
// In lib/modular/registry.dart
import 'package:island/modular/api/payment.dart';
Future<PluginLoadResult> loadMiniApp(...) async {
// ... existing code ...
final runtime = Runtime(ByteData.sublistView(bytecode));
runtime.addPlugin(flutterEvalPlugin);
// Register Payment API
final paymentAPI = PaymentAPI.instance;
// You'll need to create a bridge to expose this to eval
// ... rest of loading code
}
```
2. Mini-app can access API:
```dart
// mini_app/main.dart
final paymentAPI = PaymentAPI.instance; // Will be exposed via bridge
```
## Security Considerations
- **Never hardcode PIN codes**: Always get from user input
- **Use secure storage**: App manages PIN storage securely
- **Validate amounts**: Ensure amounts are reasonable
- **Handle errors gracefully**: Show user-friendly messages
- **Biometric is optional**: Some devices may not support it

View File

@@ -0,0 +1,284 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:island/models/auth.dart';
import 'package:island/models/wallet.dart';
import 'package:island/widgets/payment/payment_overlay.dart';
import 'package:island/pods/config.dart';
import 'package:island/pods/network.dart';
part 'payment.freezed.dart';
part 'payment.g.dart';
@freezed
sealed class PaymentRequest with _$PaymentRequest {
const factory PaymentRequest({
required String orderId,
required int amount,
required String currency,
String? remarks,
String? payeeWalletId,
String? pinCode,
@Default(true) bool showOverlay,
@Default(true) bool enableBiometric,
}) = _PaymentRequest;
factory PaymentRequest.fromJson(Map<String, dynamic> json) =>
_$PaymentRequestFromJson(json);
}
@freezed
sealed class PaymentResult with _$PaymentResult {
const factory PaymentResult({
required bool success,
SnWalletOrder? order,
String? error,
String? errorCode,
}) = _PaymentResult;
factory PaymentResult.fromJson(Map<String, dynamic> json) =>
_$PaymentResultFromJson(json);
}
@freezed
sealed class CreateOrderRequest with _$CreateOrderRequest {
const factory CreateOrderRequest({
required int amount,
required String currency,
String? remarks,
String? payeeWalletId,
String? appIdentifier,
@Default({}) Map<String, dynamic> meta,
}) = _CreateOrderRequest;
factory CreateOrderRequest.fromJson(Map<String, dynamic> json) =>
_$CreateOrderRequestFromJson(json);
}
class PaymentAPI {
static PaymentAPI? _instance;
late Dio _dio;
late String _serverUrl;
String? _token;
PaymentAPI._internal();
static PaymentAPI get instance {
_instance ??= PaymentAPI._internal();
return _instance!;
}
Future<void> _initialize() async {
if (_dio == null) {
final prefs = await SharedPreferences.getInstance();
_serverUrl =
prefs.getString(kNetworkServerStoreKey) ?? kNetworkServerDefault;
final tokenString = prefs.getString(kTokenPairStoreKey);
if (tokenString != null) {
final appToken = AppToken.fromJson(jsonDecode(tokenString!));
_token = await getToken(appToken);
}
_dio = Dio(
BaseOptions(
baseUrl: _serverUrl,
connectTimeout: const Duration(seconds: 10),
receiveTimeout: const Duration(seconds: 10),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
),
);
_dio.interceptors.add(
InterceptorsWrapper(
onRequest: (options, handler) async {
if (_token != null) {
options.headers['Authorization'] = 'AtField $_token';
}
return handler.next(options);
},
),
);
}
}
Future<SnWalletOrder?> createOrder(CreateOrderRequest request) async {
await _initialize();
try {
final response = await _dio.post('/pass/orders', data: request.toJson());
return SnWalletOrder.fromJson(response.data);
} catch (e) {
throw _parsePaymentError(e);
}
}
Future<SnWalletOrder?> processPayment({
required String orderId,
required String pinCode,
bool enableBiometric = true,
}) async {
await _initialize();
try {
final response = await _dio.post(
'/pass/orders/$orderId/pay',
data: {'pin_code': pinCode},
);
return SnWalletOrder.fromJson(response.data);
} catch (e) {
throw _parsePaymentError(e);
}
}
Future<PaymentResult> processPaymentWithOverlay({
required BuildContext context,
PaymentRequest? request,
CreateOrderRequest? createOrderRequest,
bool enableBiometric = true,
}) async {
try {
await _initialize();
SnWalletOrder order;
if (request == null && createOrderRequest == null) {
return PaymentResult(
success: false,
error: 'Either request or createOrderRequest must be provided',
);
}
if (request != null) {
order = (await createOrder(createOrderRequest!))!;
} else {
order = SnWalletOrder(
id: request!.orderId,
status: 0,
currency: request!.currency,
remarks: request!.remarks,
appIdentifier: 'mini-app',
meta: {},
amount: request!.amount,
expiredAt: DateTime.now().add(const Duration(hours: 1)),
payeeWalletId: request!.payeeWalletId,
transactionId: null,
issuerAppId: null,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
deletedAt: null,
);
}
final result = await PaymentOverlay.show(
context: context,
order: order,
enableBiometric: enableBiometric,
);
if (result != null) {
return PaymentResult(success: true, order: result);
} else {
return PaymentResult(
success: false,
error: 'Payment was cancelled by user',
);
}
} catch (e) {
final errorMessage = _parsePaymentError(e);
return PaymentResult(
success: false,
error: errorMessage,
errorCode: e is DioException
? (e as DioException).response?.statusCode.toString()
: null,
);
}
}
Future<PaymentResult> processDirectPayment(PaymentRequest request) async {
await _initialize();
try {
if (request.pinCode == null) {
return PaymentResult(
success: false,
error: 'PIN code is required for direct payment processing',
);
}
final result = await processPayment(
orderId: request.orderId,
pinCode: request.pinCode!,
enableBiometric: request.enableBiometric,
);
if (result != null) {
return PaymentResult(success: true, order: result);
} else {
return PaymentResult(success: false, error: 'Payment failed');
}
} catch (e) {
final errorMessage = _parsePaymentError(e);
return PaymentResult(
success: false,
error: errorMessage,
errorCode: e is DioException
? (e as DioException).response?.statusCode.toString()
: null,
);
}
}
String _parsePaymentError(dynamic error) {
if (error is DioException) {
final dioError = error as DioException;
if (dioError.response?.statusCode == 403 ||
dioError.response?.statusCode == 401) {
return 'invalidPin'.tr();
} else if (dioError.response?.statusCode == 400) {
return dioError.response?.data?['error'] ?? 'paymentFailed'.tr();
} else if (dioError.response?.statusCode == 503) {
return 'serviceUnavailable'.tr();
} else if (dioError.response?.statusCode == 404) {
return 'orderNotFound'.tr();
}
return 'networkError'.tr();
}
return error.toString();
}
Future<void> updateServerUrl() async {
final prefs = await SharedPreferences.getInstance();
_serverUrl =
prefs.getString(kNetworkServerStoreKey) ?? kNetworkServerDefault;
_dio.options.baseUrl = _serverUrl;
}
Future<void> updateToken() async {
final prefs = await SharedPreferences.getInstance();
final tokenString = prefs.getString(kTokenPairStoreKey);
if (tokenString != null) {
final appToken = AppToken.fromJson(jsonDecode(tokenString!));
_token = await getToken(appToken);
} else {
_token = null;
}
}
void dispose() {
_dio.close();
}
}

View File

@@ -0,0 +1,860 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'payment.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$PaymentRequest {
String get orderId; int get amount; String get currency; String? get remarks; String? get payeeWalletId; String? get pinCode; bool get showOverlay; bool get enableBiometric;
/// Create a copy of PaymentRequest
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$PaymentRequestCopyWith<PaymentRequest> get copyWith => _$PaymentRequestCopyWithImpl<PaymentRequest>(this as PaymentRequest, _$identity);
/// Serializes this PaymentRequest to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is PaymentRequest&&(identical(other.orderId, orderId) || other.orderId == orderId)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.remarks, remarks) || other.remarks == remarks)&&(identical(other.payeeWalletId, payeeWalletId) || other.payeeWalletId == payeeWalletId)&&(identical(other.pinCode, pinCode) || other.pinCode == pinCode)&&(identical(other.showOverlay, showOverlay) || other.showOverlay == showOverlay)&&(identical(other.enableBiometric, enableBiometric) || other.enableBiometric == enableBiometric));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,orderId,amount,currency,remarks,payeeWalletId,pinCode,showOverlay,enableBiometric);
@override
String toString() {
return 'PaymentRequest(orderId: $orderId, amount: $amount, currency: $currency, remarks: $remarks, payeeWalletId: $payeeWalletId, pinCode: $pinCode, showOverlay: $showOverlay, enableBiometric: $enableBiometric)';
}
}
/// @nodoc
abstract mixin class $PaymentRequestCopyWith<$Res> {
factory $PaymentRequestCopyWith(PaymentRequest value, $Res Function(PaymentRequest) _then) = _$PaymentRequestCopyWithImpl;
@useResult
$Res call({
String orderId, int amount, String currency, String? remarks, String? payeeWalletId, String? pinCode, bool showOverlay, bool enableBiometric
});
}
/// @nodoc
class _$PaymentRequestCopyWithImpl<$Res>
implements $PaymentRequestCopyWith<$Res> {
_$PaymentRequestCopyWithImpl(this._self, this._then);
final PaymentRequest _self;
final $Res Function(PaymentRequest) _then;
/// Create a copy of PaymentRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? orderId = null,Object? amount = null,Object? currency = null,Object? remarks = freezed,Object? payeeWalletId = freezed,Object? pinCode = freezed,Object? showOverlay = null,Object? enableBiometric = null,}) {
return _then(_self.copyWith(
orderId: null == orderId ? _self.orderId : orderId // ignore: cast_nullable_to_non_nullable
as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
as int,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
as String,remarks: freezed == remarks ? _self.remarks : remarks // ignore: cast_nullable_to_non_nullable
as String?,payeeWalletId: freezed == payeeWalletId ? _self.payeeWalletId : payeeWalletId // ignore: cast_nullable_to_non_nullable
as String?,pinCode: freezed == pinCode ? _self.pinCode : pinCode // ignore: cast_nullable_to_non_nullable
as String?,showOverlay: null == showOverlay ? _self.showOverlay : showOverlay // ignore: cast_nullable_to_non_nullable
as bool,enableBiometric: null == enableBiometric ? _self.enableBiometric : enableBiometric // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// Adds pattern-matching-related methods to [PaymentRequest].
extension PaymentRequestPatterns on PaymentRequest {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _PaymentRequest value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _PaymentRequest() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _PaymentRequest value) $default,){
final _that = this;
switch (_that) {
case _PaymentRequest():
return $default(_that);}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _PaymentRequest value)? $default,){
final _that = this;
switch (_that) {
case _PaymentRequest() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String orderId, int amount, String currency, String? remarks, String? payeeWalletId, String? pinCode, bool showOverlay, bool enableBiometric)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PaymentRequest() when $default != null:
return $default(_that.orderId,_that.amount,_that.currency,_that.remarks,_that.payeeWalletId,_that.pinCode,_that.showOverlay,_that.enableBiometric);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String orderId, int amount, String currency, String? remarks, String? payeeWalletId, String? pinCode, bool showOverlay, bool enableBiometric) $default,) {final _that = this;
switch (_that) {
case _PaymentRequest():
return $default(_that.orderId,_that.amount,_that.currency,_that.remarks,_that.payeeWalletId,_that.pinCode,_that.showOverlay,_that.enableBiometric);}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String orderId, int amount, String currency, String? remarks, String? payeeWalletId, String? pinCode, bool showOverlay, bool enableBiometric)? $default,) {final _that = this;
switch (_that) {
case _PaymentRequest() when $default != null:
return $default(_that.orderId,_that.amount,_that.currency,_that.remarks,_that.payeeWalletId,_that.pinCode,_that.showOverlay,_that.enableBiometric);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _PaymentRequest implements PaymentRequest {
const _PaymentRequest({required this.orderId, required this.amount, required this.currency, this.remarks, this.payeeWalletId, this.pinCode, this.showOverlay = true, this.enableBiometric = true});
factory _PaymentRequest.fromJson(Map<String, dynamic> json) => _$PaymentRequestFromJson(json);
@override final String orderId;
@override final int amount;
@override final String currency;
@override final String? remarks;
@override final String? payeeWalletId;
@override final String? pinCode;
@override@JsonKey() final bool showOverlay;
@override@JsonKey() final bool enableBiometric;
/// Create a copy of PaymentRequest
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$PaymentRequestCopyWith<_PaymentRequest> get copyWith => __$PaymentRequestCopyWithImpl<_PaymentRequest>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$PaymentRequestToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentRequest&&(identical(other.orderId, orderId) || other.orderId == orderId)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.remarks, remarks) || other.remarks == remarks)&&(identical(other.payeeWalletId, payeeWalletId) || other.payeeWalletId == payeeWalletId)&&(identical(other.pinCode, pinCode) || other.pinCode == pinCode)&&(identical(other.showOverlay, showOverlay) || other.showOverlay == showOverlay)&&(identical(other.enableBiometric, enableBiometric) || other.enableBiometric == enableBiometric));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,orderId,amount,currency,remarks,payeeWalletId,pinCode,showOverlay,enableBiometric);
@override
String toString() {
return 'PaymentRequest(orderId: $orderId, amount: $amount, currency: $currency, remarks: $remarks, payeeWalletId: $payeeWalletId, pinCode: $pinCode, showOverlay: $showOverlay, enableBiometric: $enableBiometric)';
}
}
/// @nodoc
abstract mixin class _$PaymentRequestCopyWith<$Res> implements $PaymentRequestCopyWith<$Res> {
factory _$PaymentRequestCopyWith(_PaymentRequest value, $Res Function(_PaymentRequest) _then) = __$PaymentRequestCopyWithImpl;
@override @useResult
$Res call({
String orderId, int amount, String currency, String? remarks, String? payeeWalletId, String? pinCode, bool showOverlay, bool enableBiometric
});
}
/// @nodoc
class __$PaymentRequestCopyWithImpl<$Res>
implements _$PaymentRequestCopyWith<$Res> {
__$PaymentRequestCopyWithImpl(this._self, this._then);
final _PaymentRequest _self;
final $Res Function(_PaymentRequest) _then;
/// Create a copy of PaymentRequest
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? orderId = null,Object? amount = null,Object? currency = null,Object? remarks = freezed,Object? payeeWalletId = freezed,Object? pinCode = freezed,Object? showOverlay = null,Object? enableBiometric = null,}) {
return _then(_PaymentRequest(
orderId: null == orderId ? _self.orderId : orderId // ignore: cast_nullable_to_non_nullable
as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
as int,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
as String,remarks: freezed == remarks ? _self.remarks : remarks // ignore: cast_nullable_to_non_nullable
as String?,payeeWalletId: freezed == payeeWalletId ? _self.payeeWalletId : payeeWalletId // ignore: cast_nullable_to_non_nullable
as String?,pinCode: freezed == pinCode ? _self.pinCode : pinCode // ignore: cast_nullable_to_non_nullable
as String?,showOverlay: null == showOverlay ? _self.showOverlay : showOverlay // ignore: cast_nullable_to_non_nullable
as bool,enableBiometric: null == enableBiometric ? _self.enableBiometric : enableBiometric // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
mixin _$PaymentResult {
bool get success; SnWalletOrder? get order; String? get error; String? get errorCode;
/// Create a copy of PaymentResult
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$PaymentResultCopyWith<PaymentResult> get copyWith => _$PaymentResultCopyWithImpl<PaymentResult>(this as PaymentResult, _$identity);
/// Serializes this PaymentResult to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is PaymentResult&&(identical(other.success, success) || other.success == success)&&(identical(other.order, order) || other.order == order)&&(identical(other.error, error) || other.error == error)&&(identical(other.errorCode, errorCode) || other.errorCode == errorCode));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,success,order,error,errorCode);
@override
String toString() {
return 'PaymentResult(success: $success, order: $order, error: $error, errorCode: $errorCode)';
}
}
/// @nodoc
abstract mixin class $PaymentResultCopyWith<$Res> {
factory $PaymentResultCopyWith(PaymentResult value, $Res Function(PaymentResult) _then) = _$PaymentResultCopyWithImpl;
@useResult
$Res call({
bool success, SnWalletOrder? order, String? error, String? errorCode
});
$SnWalletOrderCopyWith<$Res>? get order;
}
/// @nodoc
class _$PaymentResultCopyWithImpl<$Res>
implements $PaymentResultCopyWith<$Res> {
_$PaymentResultCopyWithImpl(this._self, this._then);
final PaymentResult _self;
final $Res Function(PaymentResult) _then;
/// Create a copy of PaymentResult
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? success = null,Object? order = freezed,Object? error = freezed,Object? errorCode = freezed,}) {
return _then(_self.copyWith(
success: null == success ? _self.success : success // ignore: cast_nullable_to_non_nullable
as bool,order: freezed == order ? _self.order : order // ignore: cast_nullable_to_non_nullable
as SnWalletOrder?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as String?,errorCode: freezed == errorCode ? _self.errorCode : errorCode // ignore: cast_nullable_to_non_nullable
as String?,
));
}
/// Create a copy of PaymentResult
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnWalletOrderCopyWith<$Res>? get order {
if (_self.order == null) {
return null;
}
return $SnWalletOrderCopyWith<$Res>(_self.order!, (value) {
return _then(_self.copyWith(order: value));
});
}
}
/// Adds pattern-matching-related methods to [PaymentResult].
extension PaymentResultPatterns on PaymentResult {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _PaymentResult value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _PaymentResult() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _PaymentResult value) $default,){
final _that = this;
switch (_that) {
case _PaymentResult():
return $default(_that);}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _PaymentResult value)? $default,){
final _that = this;
switch (_that) {
case _PaymentResult() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool success, SnWalletOrder? order, String? error, String? errorCode)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PaymentResult() when $default != null:
return $default(_that.success,_that.order,_that.error,_that.errorCode);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool success, SnWalletOrder? order, String? error, String? errorCode) $default,) {final _that = this;
switch (_that) {
case _PaymentResult():
return $default(_that.success,_that.order,_that.error,_that.errorCode);}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool success, SnWalletOrder? order, String? error, String? errorCode)? $default,) {final _that = this;
switch (_that) {
case _PaymentResult() when $default != null:
return $default(_that.success,_that.order,_that.error,_that.errorCode);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _PaymentResult implements PaymentResult {
const _PaymentResult({required this.success, this.order, this.error, this.errorCode});
factory _PaymentResult.fromJson(Map<String, dynamic> json) => _$PaymentResultFromJson(json);
@override final bool success;
@override final SnWalletOrder? order;
@override final String? error;
@override final String? errorCode;
/// Create a copy of PaymentResult
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$PaymentResultCopyWith<_PaymentResult> get copyWith => __$PaymentResultCopyWithImpl<_PaymentResult>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$PaymentResultToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentResult&&(identical(other.success, success) || other.success == success)&&(identical(other.order, order) || other.order == order)&&(identical(other.error, error) || other.error == error)&&(identical(other.errorCode, errorCode) || other.errorCode == errorCode));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,success,order,error,errorCode);
@override
String toString() {
return 'PaymentResult(success: $success, order: $order, error: $error, errorCode: $errorCode)';
}
}
/// @nodoc
abstract mixin class _$PaymentResultCopyWith<$Res> implements $PaymentResultCopyWith<$Res> {
factory _$PaymentResultCopyWith(_PaymentResult value, $Res Function(_PaymentResult) _then) = __$PaymentResultCopyWithImpl;
@override @useResult
$Res call({
bool success, SnWalletOrder? order, String? error, String? errorCode
});
@override $SnWalletOrderCopyWith<$Res>? get order;
}
/// @nodoc
class __$PaymentResultCopyWithImpl<$Res>
implements _$PaymentResultCopyWith<$Res> {
__$PaymentResultCopyWithImpl(this._self, this._then);
final _PaymentResult _self;
final $Res Function(_PaymentResult) _then;
/// Create a copy of PaymentResult
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? success = null,Object? order = freezed,Object? error = freezed,Object? errorCode = freezed,}) {
return _then(_PaymentResult(
success: null == success ? _self.success : success // ignore: cast_nullable_to_non_nullable
as bool,order: freezed == order ? _self.order : order // ignore: cast_nullable_to_non_nullable
as SnWalletOrder?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as String?,errorCode: freezed == errorCode ? _self.errorCode : errorCode // ignore: cast_nullable_to_non_nullable
as String?,
));
}
/// Create a copy of PaymentResult
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SnWalletOrderCopyWith<$Res>? get order {
if (_self.order == null) {
return null;
}
return $SnWalletOrderCopyWith<$Res>(_self.order!, (value) {
return _then(_self.copyWith(order: value));
});
}
}
/// @nodoc
mixin _$CreateOrderRequest {
int get amount; String get currency; String? get remarks; String? get payeeWalletId; String? get appIdentifier; Map<String, dynamic> get meta;
/// Create a copy of CreateOrderRequest
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$CreateOrderRequestCopyWith<CreateOrderRequest> get copyWith => _$CreateOrderRequestCopyWithImpl<CreateOrderRequest>(this as CreateOrderRequest, _$identity);
/// Serializes this CreateOrderRequest to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is CreateOrderRequest&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.remarks, remarks) || other.remarks == remarks)&&(identical(other.payeeWalletId, payeeWalletId) || other.payeeWalletId == payeeWalletId)&&(identical(other.appIdentifier, appIdentifier) || other.appIdentifier == appIdentifier)&&const DeepCollectionEquality().equals(other.meta, meta));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,amount,currency,remarks,payeeWalletId,appIdentifier,const DeepCollectionEquality().hash(meta));
@override
String toString() {
return 'CreateOrderRequest(amount: $amount, currency: $currency, remarks: $remarks, payeeWalletId: $payeeWalletId, appIdentifier: $appIdentifier, meta: $meta)';
}
}
/// @nodoc
abstract mixin class $CreateOrderRequestCopyWith<$Res> {
factory $CreateOrderRequestCopyWith(CreateOrderRequest value, $Res Function(CreateOrderRequest) _then) = _$CreateOrderRequestCopyWithImpl;
@useResult
$Res call({
int amount, String currency, String? remarks, String? payeeWalletId, String? appIdentifier, Map<String, dynamic> meta
});
}
/// @nodoc
class _$CreateOrderRequestCopyWithImpl<$Res>
implements $CreateOrderRequestCopyWith<$Res> {
_$CreateOrderRequestCopyWithImpl(this._self, this._then);
final CreateOrderRequest _self;
final $Res Function(CreateOrderRequest) _then;
/// Create a copy of CreateOrderRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? amount = null,Object? currency = null,Object? remarks = freezed,Object? payeeWalletId = freezed,Object? appIdentifier = freezed,Object? meta = null,}) {
return _then(_self.copyWith(
amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
as int,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
as String,remarks: freezed == remarks ? _self.remarks : remarks // ignore: cast_nullable_to_non_nullable
as String?,payeeWalletId: freezed == payeeWalletId ? _self.payeeWalletId : payeeWalletId // ignore: cast_nullable_to_non_nullable
as String?,appIdentifier: freezed == appIdentifier ? _self.appIdentifier : appIdentifier // ignore: cast_nullable_to_non_nullable
as String?,meta: null == meta ? _self.meta : meta // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
));
}
}
/// Adds pattern-matching-related methods to [CreateOrderRequest].
extension CreateOrderRequestPatterns on CreateOrderRequest {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _CreateOrderRequest value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _CreateOrderRequest() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _CreateOrderRequest value) $default,){
final _that = this;
switch (_that) {
case _CreateOrderRequest():
return $default(_that);}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _CreateOrderRequest value)? $default,){
final _that = this;
switch (_that) {
case _CreateOrderRequest() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int amount, String currency, String? remarks, String? payeeWalletId, String? appIdentifier, Map<String, dynamic> meta)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _CreateOrderRequest() when $default != null:
return $default(_that.amount,_that.currency,_that.remarks,_that.payeeWalletId,_that.appIdentifier,_that.meta);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int amount, String currency, String? remarks, String? payeeWalletId, String? appIdentifier, Map<String, dynamic> meta) $default,) {final _that = this;
switch (_that) {
case _CreateOrderRequest():
return $default(_that.amount,_that.currency,_that.remarks,_that.payeeWalletId,_that.appIdentifier,_that.meta);}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int amount, String currency, String? remarks, String? payeeWalletId, String? appIdentifier, Map<String, dynamic> meta)? $default,) {final _that = this;
switch (_that) {
case _CreateOrderRequest() when $default != null:
return $default(_that.amount,_that.currency,_that.remarks,_that.payeeWalletId,_that.appIdentifier,_that.meta);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _CreateOrderRequest implements CreateOrderRequest {
const _CreateOrderRequest({required this.amount, required this.currency, this.remarks, this.payeeWalletId, this.appIdentifier, final Map<String, dynamic> meta = const {}}): _meta = meta;
factory _CreateOrderRequest.fromJson(Map<String, dynamic> json) => _$CreateOrderRequestFromJson(json);
@override final int amount;
@override final String currency;
@override final String? remarks;
@override final String? payeeWalletId;
@override final String? appIdentifier;
final Map<String, dynamic> _meta;
@override@JsonKey() Map<String, dynamic> get meta {
if (_meta is EqualUnmodifiableMapView) return _meta;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_meta);
}
/// Create a copy of CreateOrderRequest
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$CreateOrderRequestCopyWith<_CreateOrderRequest> get copyWith => __$CreateOrderRequestCopyWithImpl<_CreateOrderRequest>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$CreateOrderRequestToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CreateOrderRequest&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.remarks, remarks) || other.remarks == remarks)&&(identical(other.payeeWalletId, payeeWalletId) || other.payeeWalletId == payeeWalletId)&&(identical(other.appIdentifier, appIdentifier) || other.appIdentifier == appIdentifier)&&const DeepCollectionEquality().equals(other._meta, _meta));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,amount,currency,remarks,payeeWalletId,appIdentifier,const DeepCollectionEquality().hash(_meta));
@override
String toString() {
return 'CreateOrderRequest(amount: $amount, currency: $currency, remarks: $remarks, payeeWalletId: $payeeWalletId, appIdentifier: $appIdentifier, meta: $meta)';
}
}
/// @nodoc
abstract mixin class _$CreateOrderRequestCopyWith<$Res> implements $CreateOrderRequestCopyWith<$Res> {
factory _$CreateOrderRequestCopyWith(_CreateOrderRequest value, $Res Function(_CreateOrderRequest) _then) = __$CreateOrderRequestCopyWithImpl;
@override @useResult
$Res call({
int amount, String currency, String? remarks, String? payeeWalletId, String? appIdentifier, Map<String, dynamic> meta
});
}
/// @nodoc
class __$CreateOrderRequestCopyWithImpl<$Res>
implements _$CreateOrderRequestCopyWith<$Res> {
__$CreateOrderRequestCopyWithImpl(this._self, this._then);
final _CreateOrderRequest _self;
final $Res Function(_CreateOrderRequest) _then;
/// Create a copy of CreateOrderRequest
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? amount = null,Object? currency = null,Object? remarks = freezed,Object? payeeWalletId = freezed,Object? appIdentifier = freezed,Object? meta = null,}) {
return _then(_CreateOrderRequest(
amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
as int,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
as String,remarks: freezed == remarks ? _self.remarks : remarks // ignore: cast_nullable_to_non_nullable
as String?,payeeWalletId: freezed == payeeWalletId ? _self.payeeWalletId : payeeWalletId // ignore: cast_nullable_to_non_nullable
as String?,appIdentifier: freezed == appIdentifier ? _self.appIdentifier : appIdentifier // ignore: cast_nullable_to_non_nullable
as String?,meta: null == meta ? _self._meta : meta // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,
));
}
}
// dart format on

View File

@@ -0,0 +1,69 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'payment.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_PaymentRequest _$PaymentRequestFromJson(Map<String, dynamic> json) =>
_PaymentRequest(
orderId: json['order_id'] as String,
amount: (json['amount'] as num).toInt(),
currency: json['currency'] as String,
remarks: json['remarks'] as String?,
payeeWalletId: json['payee_wallet_id'] as String?,
pinCode: json['pin_code'] as String?,
showOverlay: json['show_overlay'] as bool? ?? true,
enableBiometric: json['enable_biometric'] as bool? ?? true,
);
Map<String, dynamic> _$PaymentRequestToJson(_PaymentRequest instance) =>
<String, dynamic>{
'order_id': instance.orderId,
'amount': instance.amount,
'currency': instance.currency,
'remarks': instance.remarks,
'payee_wallet_id': instance.payeeWalletId,
'pin_code': instance.pinCode,
'show_overlay': instance.showOverlay,
'enable_biometric': instance.enableBiometric,
};
_PaymentResult _$PaymentResultFromJson(Map<String, dynamic> json) =>
_PaymentResult(
success: json['success'] as bool,
order: json['order'] == null
? null
: SnWalletOrder.fromJson(json['order'] as Map<String, dynamic>),
error: json['error'] as String?,
errorCode: json['error_code'] as String?,
);
Map<String, dynamic> _$PaymentResultToJson(_PaymentResult instance) =>
<String, dynamic>{
'success': instance.success,
'order': instance.order?.toJson(),
'error': instance.error,
'error_code': instance.errorCode,
};
_CreateOrderRequest _$CreateOrderRequestFromJson(Map<String, dynamic> json) =>
_CreateOrderRequest(
amount: (json['amount'] as num).toInt(),
currency: json['currency'] as String,
remarks: json['remarks'] as String?,
payeeWalletId: json['payee_wallet_id'] as String?,
appIdentifier: json['app_identifier'] as String?,
meta: json['meta'] as Map<String, dynamic>? ?? const {},
);
Map<String, dynamic> _$CreateOrderRequestToJson(_CreateOrderRequest instance) =>
<String, dynamic>{
'amount': instance.amount,
'currency': instance.currency,
'remarks': instance.remarks,
'payee_wallet_id': instance.payeeWalletId,
'app_identifier': instance.appIdentifier,
'meta': instance.meta,
};