├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── ci.md │ ├── build.md │ ├── chore.md │ ├── documentation.md │ ├── style.md │ ├── test.md │ ├── refactor.md │ ├── performance.md │ ├── revert.md │ ├── feature_request.md │ └── bug_report.md ├── dependabot.yaml ├── cspell.json ├── workflows │ └── main.yaml └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── lib ├── pesepay.dart └── src │ ├── utils │ ├── utils.dart │ ├── _api.dart │ ├── pesepay_exception.dart │ ├── dio_error_to_pesepay_exception.dart │ └── transaction_response_stream_manager.dart │ ├── models │ ├── models.dart │ ├── amount.g.dart │ ├── customer.g.dart │ ├── required_field.dart │ ├── customer.dart │ ├── amount.dart │ ├── required_field.g.dart │ ├── currency.g.dart │ ├── payment_method.dart │ ├── transaction_status.dart │ ├── transaction.g.dart │ ├── transaction_response.dart │ ├── seamless_transaction.g.dart │ ├── currency.dart │ ├── transaction.dart │ ├── seamless_transaction.dart │ ├── payment_method.g.dart │ ├── transaction_response.g.dart │ ├── amount.freezed.dart │ ├── customer.freezed.dart │ ├── required_field.freezed.dart │ ├── currency.freezed.dart │ ├── transaction_response.freezed.dart │ ├── transaction.freezed.dart │ ├── seamless_transaction.freezed.dart │ └── payment_method.freezed.dart │ └── pesepay.dart ├── test └── src │ └── pesepay_test.dart ├── pubspec.yaml ├── analysis_options.yaml ├── CHANGELOG.md ├── LICENSE ├── coverage_badge.svg └── README.md /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://www.dartlang.org/guides/libraries/private-files 2 | 3 | # Files and directories created by pub 4 | .dart_tool/ 5 | .packages 6 | build/ 7 | pubspec.lock 8 | 9 | # IDE files 10 | .idea/ 11 | .keys -------------------------------------------------------------------------------- /lib/pesepay.dart: -------------------------------------------------------------------------------- 1 | /// Pesepay helps businesses in Africa get paid by anyone, anywhere in the world 2 | library pesepay; 3 | 4 | export 'src/models/models.dart'; 5 | export 'src/pesepay.dart'; 6 | export 'src/utils/utils.dart'; 7 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | enable-beta-ecosystems: true 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | - package-ecosystem: "pub" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/ci.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Continuous Integration 3 | about: Changes to the CI configuration files and scripts 4 | title: "ci: " 5 | labels: ci 6 | --- 7 | 8 | **Description** 9 | 10 | Describe what changes need to be done to the ci/cd system and why. 11 | 12 | **Requirements** 13 | 14 | - [ ] The ci system is passing 15 | -------------------------------------------------------------------------------- /lib/src/utils/utils.dart: -------------------------------------------------------------------------------- 1 | // 2 | // utils 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 10/3/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | export '_api.dart'; 10 | export 'dio_error_to_pesepay_exception.dart'; 11 | export 'pesepay_exception.dart'; 12 | export 'transaction_response_stream_manager.dart'; 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/build.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Build System 3 | about: Changes that affect the build system or external dependencies 4 | title: "build: " 5 | labels: build 6 | --- 7 | 8 | **Description** 9 | 10 | Describe what changes need to be done to the build system and why. 11 | 12 | **Requirements** 13 | 14 | - [ ] The build system is passing 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/chore.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Chore 3 | about: Other changes that don't modify src or test files 4 | title: "chore: " 5 | labels: chore 6 | --- 7 | 8 | **Description** 9 | 10 | Clearly describe what change is needed and why. If this changes code then please use another issue type. 11 | 12 | **Requirements** 13 | 14 | - [ ] No functional changes to the code 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation 3 | about: Improve the documentation so all collaborators have a common understanding 4 | title: "docs: " 5 | labels: documentation 6 | --- 7 | 8 | **Description** 9 | 10 | Clearly describe what documentation you are looking to add or improve. 11 | 12 | **Requirements** 13 | 14 | - [ ] Requirements go here 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/style.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Style Changes 3 | about: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc) 4 | title: "style: " 5 | labels: style 6 | --- 7 | 8 | **Description** 9 | 10 | Clearly describe what you are looking to change and why. 11 | 12 | **Requirements** 13 | 14 | - [ ] There is no drop in test coverage. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/test.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Test 3 | about: Adding missing tests or correcting existing tests 4 | title: "test: " 5 | labels: test 6 | --- 7 | 8 | **Description** 9 | 10 | List out the tests that need to be added or changed. Please also include any information as to why this was not covered in the past. 11 | 12 | **Requirements** 13 | 14 | - [ ] There is no drop in test coverage. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/refactor.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Refactor 3 | about: A code change that neither fixes a bug nor adds a feature 4 | title: "refactor: " 5 | labels: refactor 6 | --- 7 | 8 | **Description** 9 | 10 | Clearly describe what needs to be refactored and why. Please provide links to related issues (bugs or upcoming features) in order to help prioritize. 11 | 12 | **Requirements** 13 | 14 | - [ ] There is no drop in test coverage. 15 | -------------------------------------------------------------------------------- /lib/src/models/models.dart: -------------------------------------------------------------------------------- 1 | // 2 | // models 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 10/3/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | export 'amount.dart'; 10 | export 'currency.dart'; 11 | export 'customer.dart'; 12 | export 'payment_method.dart'; 13 | export 'required_field.dart'; 14 | export 'seamless_transaction.dart'; 15 | export 'transaction.dart'; 16 | export 'transaction_response.dart'; 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/performance.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Performance Update 3 | about: A code change that improves performance 4 | title: "perf: " 5 | labels: performance 6 | --- 7 | 8 | **Description** 9 | 10 | Clearly describe what code needs to be changed and what the performance impact is going to be. Bonus point's if you can tie this directly to user experience. 11 | 12 | **Requirements** 13 | 14 | - [ ] There is no drop in test coverage. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/revert.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Revert Commit 3 | about: Reverts a previous commit 4 | title: "revert: " 5 | labels: revert 6 | --- 7 | 8 | **Description** 9 | 10 | Provide a link to a PR/Commit that you are looking to revert and why. 11 | 12 | **Requirements** 13 | 14 | - [ ] Change has been reverted 15 | - [ ] No change in test coverage has happened 16 | - [ ] A new ticket is created for any follow on work that needs to happen 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: A new feature to be added to the project 4 | title: "feat: " 5 | labels: feature 6 | --- 7 | 8 | **Description** 9 | 10 | Clearly describe what you are looking to add. The more context the better. 11 | 12 | **Requirements** 13 | 14 | - [ ] Checklist of requirements to be fulfilled 15 | 16 | **Additional Context** 17 | 18 | Add any other context or screenshots about the feature request go here. 19 | -------------------------------------------------------------------------------- /test/src/pesepay_test.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: prefer_const_constructors 2 | import 'package:pesepay/pesepay.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | void main() async { 6 | group('Pesepay', () { 7 | test('can be instantiated', () { 8 | expect( 9 | Pesepay( 10 | integrationKey: '30452e8b-89ca-4817-9bb2-dbde61dceded', 11 | encryptionKey: '0799d47ea28b45829bbf784abe0b31c7', 12 | ), 13 | isNotNull, 14 | ); 15 | }); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /lib/src/utils/_api.dart: -------------------------------------------------------------------------------- 1 | // 2 | // _api 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 10/3/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | class ApiConfig { 10 | static const String baseUrl = 'https://api.pesepay.com/api/payments-engine'; 11 | static const String checkoutPaymentStatusUrl = 12 | '$baseUrl/v1/payments/check-payment'; 13 | static const String seamlessPaymentUrl = '$baseUrl/v2/payments/make-payment'; 14 | static const String initiatePaymentUrl = '$baseUrl/v1/payments/initiate'; 15 | } 16 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pesepay 2 | description: Pesepay helps businesses in Africa get paid by anyone, anywhere in the world 3 | version: 0.4.1 4 | homepage: https://github.com/iamngoni/pesepay 5 | 6 | environment: 7 | sdk: ">=3.8.0 <4.0.0" 8 | 9 | dependencies: 10 | dio: ^5.0.1 11 | encrypt: ^5.0.1 12 | freezed_annotation: ^3.1.0 13 | json_annotation: ^4.9.0 14 | localregex: ^4.0.5 15 | 16 | dev_dependencies: 17 | build_runner: ^2.3.3 18 | freezed: ^3.2.0 19 | json_serializable: ^6.10.0 20 | test: ^1.19.2 21 | very_good_analysis: ^4.0.0 22 | -------------------------------------------------------------------------------- /lib/src/models/amount.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'amount.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _Amount _$AmountFromJson(Map json) => _Amount( 10 | amount: (json['amount'] as num).toDouble(), 11 | currency: json['currencyCode'] as String, 12 | ); 13 | 14 | Map _$AmountToJson(_Amount instance) => { 15 | 'amount': instance.amount, 16 | 'currencyCode': instance.currency, 17 | }; 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: "fix: " 5 | labels: bug 6 | --- 7 | 8 | **Description** 9 | 10 | A clear and concise description of what the bug is. 11 | 12 | **Steps To Reproduce** 13 | 14 | 1. Go to '...' 15 | 2. Click on '....' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected Behavior** 20 | 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | 25 | If applicable, add screenshots to help explain your problem. 26 | 27 | **Additional Context** 28 | 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /lib/src/models/customer.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'customer.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _Customer _$CustomerFromJson(Map json) => _Customer( 10 | email: json['email'] as String, 11 | phoneNumber: json['phoneNumber'] as String, 12 | name: json['name'] as String, 13 | ); 14 | 15 | Map _$CustomerToJson(_Customer instance) => { 16 | 'email': instance.email, 17 | 'phoneNumber': instance.phoneNumber, 18 | 'name': instance.name, 19 | }; 20 | -------------------------------------------------------------------------------- /lib/src/utils/pesepay_exception.dart: -------------------------------------------------------------------------------- 1 | // 2 | // pesepay_exception 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 10/3/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | class PesepayException implements Exception { 10 | const PesepayException(this.message, {this.stackTrace}); 11 | 12 | factory PesepayException.unknown(Object? e) => 13 | PesepayException('Unknown Exception: $e'); 14 | 15 | final String message; 16 | final StackTrace? stackTrace; 17 | 18 | @override 19 | String toString() { 20 | return 'PesepayException: $message'; 21 | } 22 | } 23 | 24 | class InvalidRequestException extends PesepayException { 25 | InvalidRequestException(super.message); 26 | } 27 | -------------------------------------------------------------------------------- /lib/src/models/required_field.dart: -------------------------------------------------------------------------------- 1 | // 2 | // required_field 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 20/4/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | part 'required_field.freezed.dart'; 12 | part 'required_field.g.dart'; 13 | 14 | @freezed 15 | abstract class RequiredField with _$RequiredField { 16 | const factory RequiredField({ 17 | required String displayName, 18 | required String fieldType, 19 | required String name, 20 | required bool optional, 21 | }) = _RequiredField; 22 | 23 | factory RequiredField.fromJson(Map json) => 24 | _$RequiredFieldFromJson(json); 25 | } 26 | -------------------------------------------------------------------------------- /.github/cspell.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2", 3 | "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", 4 | "dictionaries": ["vgv_allowed", "vgv_forbidden"], 5 | "dictionaryDefinitions": [ 6 | { 7 | "name": "vgv_allowed", 8 | "path": "https://raw.githubusercontent.com/verygoodopensource/very_good_dictionaries/main/allowed.txt", 9 | "description": "Allowed VGV Spellings" 10 | }, 11 | { 12 | "name": "vgv_forbidden", 13 | "path": "https://raw.githubusercontent.com/verygoodopensource/very_good_dictionaries/main/forbidden.txt", 14 | "description": "Forbidden VGV Spellings" 15 | } 16 | ], 17 | "useGitignore": true, 18 | "words": [ 19 | "pesepay" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:very_good_analysis/analysis_options.4.0.0.yaml 2 | 3 | analyzer: 4 | exclude: [lib/**.freezed.dart, lib/**.g.dart] 5 | 6 | language: 7 | strict-casts: true 8 | strict-raw-types: true 9 | 10 | enable-experiment: 11 | - null-aware-elements 12 | 13 | linter: 14 | rules: 15 | use_null_aware_elements: true 16 | avoid_relative_lib_imports: false 17 | lines_longer_than_80_chars: true 18 | avoid_dynamic_calls: true 19 | avoid_type_to_string: true 20 | always_declare_return_types: true 21 | always_specify_types: false 22 | omit_local_variable_types: false 23 | prefer_relative_imports: true 24 | always_use_package_imports: false 25 | avoid_setters_without_getters: false 26 | public_member_api_docs: false 27 | -------------------------------------------------------------------------------- /lib/src/models/customer.dart: -------------------------------------------------------------------------------- 1 | // 2 | // customer 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 19/4/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | part 'customer.freezed.dart'; 12 | part 'customer.g.dart'; 13 | 14 | @freezed 15 | abstract class Customer with _$Customer { 16 | /// Create customer instance 17 | const factory Customer({ 18 | /// Customer email 19 | required String email, 20 | 21 | /// Customer phone number 22 | required String phoneNumber, 23 | 24 | /// Customer name 25 | required String name, 26 | }) = _Customer; 27 | 28 | const Customer._(); 29 | 30 | factory Customer.fromJson(Map json) => 31 | _$CustomerFromJson(json); 32 | } 33 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | concurrency: 4 | group: ${{ github.workflow }}-${{ github.ref }} 5 | cancel-in-progress: true 6 | 7 | on: 8 | push: 9 | branches: 10 | - main 11 | pull_request: 12 | branches: 13 | - main 14 | 15 | jobs: 16 | semantic_pull_request: 17 | uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1 18 | 19 | spell-check: 20 | uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/spell_check.yml@v1 21 | with: 22 | includes: "**/*.md" 23 | modified_files_only: false 24 | 25 | build: 26 | uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1 27 | 28 | pana: 29 | uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/pana.yml@v1 30 | 31 | -------------------------------------------------------------------------------- /lib/src/models/amount.dart: -------------------------------------------------------------------------------- 1 | // 2 | // amount 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 10/3/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | part 'amount.freezed.dart'; 12 | part 'amount.g.dart'; 13 | 14 | @freezed 15 | abstract class Amount with _$Amount { 16 | /// Create amount details instance 17 | const factory Amount({ 18 | /// The amount figure in dollars 19 | required double amount, 20 | 21 | /// Currency specification e.g. ZWL 22 | // ignore: invalid_annotation_target 23 | @JsonKey(name: 'currencyCode') required String currency, 24 | }) = _Amount; 25 | 26 | const Amount._(); 27 | 28 | factory Amount.fromJson(Map json) => _$AmountFromJson(json); 29 | } 30 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | ## Status 10 | 11 | **READY/IN DEVELOPMENT/HOLD** 12 | 13 | ## Description 14 | 15 | 16 | 17 | ## Type of Change 18 | 19 | 20 | 21 | - [ ] ✨ New feature (non-breaking change which adds functionality) 22 | - [ ] 🛠️ Bug fix (non-breaking change which fixes an issue) 23 | - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change) 24 | - [ ] 🧹 Code refactor 25 | - [ ] ✅ Build configuration change 26 | - [ ] 📝 Documentation 27 | - [ ] 🗑️ Chore 28 | -------------------------------------------------------------------------------- /lib/src/models/required_field.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'required_field.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _RequiredField _$RequiredFieldFromJson(Map json) => 10 | _RequiredField( 11 | displayName: json['displayName'] as String, 12 | fieldType: json['fieldType'] as String, 13 | name: json['name'] as String, 14 | optional: json['optional'] as bool, 15 | ); 16 | 17 | Map _$RequiredFieldToJson(_RequiredField instance) => 18 | { 19 | 'displayName': instance.displayName, 20 | 'fieldType': instance.fieldType, 21 | 'name': instance.name, 22 | 'optional': instance.optional, 23 | }; 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.4.1 2 | - Updated minimum Dart SDK requirement to 3.8.0 for null-aware elements support 3 | 4 | # 0.4.0 5 | 6 | - **BREAKING**: Updated to Freezed 3.2.0 - added `abstract` modifier to all model classes 7 | - Updated minimum Dart SDK requirement to 3.0.0 8 | - Fixed code generation issues with json_serializable 9 | - Resolved all diagnostic errors and warnings 10 | - Updated dependency constraints for better compatibility 11 | 12 | # 0.3.1 13 | 14 | - add `TransactionStatus` enum to better handling of transaction statuses 15 | - refactor `Dio` error handler for bad responses 16 | 17 | # 0.3.0 18 | 19 | - fix `Pesepay.getActiveCurrencies` error handling 20 | - fix `Pesepay.getPaymentMethodsByCurrency` error handling 21 | 22 | # 0.2.0 23 | 24 | - initiate web transaction 25 | - initiate seamless transaction 26 | - check transaction status 27 | - stream transaction status 28 | 29 | # 0.1.0+1 30 | 31 | - feat: initial commit 🎉 32 | -------------------------------------------------------------------------------- /lib/src/models/currency.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'currency.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _Currency _$CurrencyFromJson(Map json) => _Currency( 10 | name: json['name'] as String, 11 | description: json['description'] as String, 12 | code: json['code'] as String, 13 | defaultCurrency: json['defaultCurrency'] as bool, 14 | rateToDefault: (json['rateToDefault'] as num).toDouble(), 15 | active: json['active'] as bool, 16 | ); 17 | 18 | Map _$CurrencyToJson(_Currency instance) => { 19 | 'name': instance.name, 20 | 'description': instance.description, 21 | 'code': instance.code, 22 | 'defaultCurrency': instance.defaultCurrency, 23 | 'rateToDefault': instance.rateToDefault, 24 | 'active': instance.active, 25 | }; 26 | -------------------------------------------------------------------------------- /lib/src/models/payment_method.dart: -------------------------------------------------------------------------------- 1 | // 2 | // payment_method 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 20/4/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | import 'required_field.dart'; 12 | 13 | part 'payment_method.freezed.dart'; 14 | part 'payment_method.g.dart'; 15 | 16 | @freezed 17 | abstract class PaymentMethod with _$PaymentMethod { 18 | const factory PaymentMethod({ 19 | required bool active, 20 | required String code, 21 | required List currencies, 22 | required String description, 23 | required int id, 24 | required double maximumAmount, 25 | required double minimumAmount, 26 | required String name, 27 | required String processingPaymentMessage, 28 | required bool redirectRequired, 29 | String? redirectURL, 30 | List? requiredFields, 31 | }) = _PaymentMethod; 32 | 33 | const PaymentMethod._(); 34 | 35 | factory PaymentMethod.fromJson(Map json) => 36 | _$PaymentMethodFromJson(json); 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ModestNerd Developers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /coverage_badge.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | coverage 16 | coverage 17 | 100% 18 | 100% 19 | 20 | 21 | -------------------------------------------------------------------------------- /lib/src/models/transaction_status.dart: -------------------------------------------------------------------------------- 1 | // 2 | // transaction_status 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 21/4/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | enum TransactionStatus { 12 | @JsonValue('AUTHORIZATION_FAILED') 13 | authorizationFailed, 14 | @JsonValue('CANCELLED') 15 | cancelled, 16 | @JsonValue('CLOSED') 17 | closed, 18 | @JsonValue('CLOSED_PERIOD_ELAPSED') 19 | closedPeriodElapsed, 20 | @JsonValue('DECLINED') 21 | declined, 22 | @JsonValue('ERROR') 23 | error, 24 | @JsonValue('FAILED') 25 | failed, 26 | @JsonValue('INITIATED') 27 | initiated, 28 | @JsonValue('INSUFFICIENT_FUNDS') 29 | insufficientFunds, 30 | @JsonValue('PARTIALLY_PAID') 31 | partiallyPaid, 32 | @JsonValue('PENDING') 33 | pending, 34 | @JsonValue('PROCESSING') 35 | processing, 36 | @JsonValue('REVERSED') 37 | reversed, 38 | @JsonValue('SERVICE_UNAVAILABLE') 39 | serviceUnavailable, 40 | @JsonValue('SUCCESS') 41 | success, 42 | @JsonValue('TERMINATED') 43 | terminated, 44 | @JsonValue('TIME_OUT') 45 | timeOut, 46 | } 47 | -------------------------------------------------------------------------------- /lib/src/models/transaction.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'transaction.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _Transaction _$TransactionFromJson(Map json) => _Transaction( 10 | amount: Amount.fromJson(json['amountDetails'] as Map), 11 | description: json['reasonForPayment'] as String, 12 | reference: json['merchantReference'] as String?, 13 | transactionType: json['transactionType'] as String? ?? 'BASIC', 14 | resultUrl: json['resultUrl'] as String? ?? '', 15 | returnUrl: json['returnUrl'] as String? ?? '', 16 | ); 17 | 18 | Map _$TransactionToJson(_Transaction instance) => 19 | { 20 | 'amountDetails': instance.amount.toJson(), 21 | 'reasonForPayment': instance.description, 22 | 'merchantReference': ?instance.reference, 23 | 'transactionType': instance.transactionType, 24 | 'resultUrl': instance.resultUrl, 25 | 'returnUrl': instance.returnUrl, 26 | }; 27 | -------------------------------------------------------------------------------- /lib/src/models/transaction_response.dart: -------------------------------------------------------------------------------- 1 | // 2 | // transaction_response 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 19/4/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | import 'transaction_status.dart'; 12 | 13 | part 'transaction_response.freezed.dart'; 14 | part 'transaction_response.g.dart'; 15 | 16 | @freezed 17 | abstract class TransactionResponse with _$TransactionResponse { 18 | const factory TransactionResponse({ 19 | /// Reference Number 20 | required String referenceNumber, 21 | 22 | /// Poll Url 23 | required String? pollUrl, 24 | 25 | /// Transaction Status 26 | TransactionStatus? transactionStatus, 27 | 28 | // TODO(iamngoni): check if this is necessary 'cause it doesn't seem like it 29 | /// Redirect URL 30 | String? redirectUrl, 31 | }) = _TransactionResponse; 32 | 33 | const TransactionResponse._(); 34 | 35 | factory TransactionResponse.fromJson(Map json) => 36 | _$TransactionResponseFromJson(json); 37 | 38 | /// Checks whether transaction was successful or not 39 | bool get paid => transactionStatus == TransactionStatus.success; 40 | } 41 | -------------------------------------------------------------------------------- /lib/src/models/seamless_transaction.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'seamless_transaction.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _SeamlessTransaction _$SeamlessTransactionFromJson(Map json) => 10 | _SeamlessTransaction( 11 | amount: Amount.fromJson(json['amountDetails'] as Map), 12 | description: json['reasonForPayment'] as String, 13 | reference: json['merchantReference'] as String, 14 | paymentMethodCode: json['paymentMethodCode'] as String, 15 | customer: Customer.fromJson(json['customer'] as Map), 16 | returnUrl: json['returnUrl'] as String? ?? '', 17 | resultUrl: json['resultUrl'] as String? ?? '', 18 | ); 19 | 20 | Map _$SeamlessTransactionToJson( 21 | _SeamlessTransaction instance, 22 | ) => { 23 | 'amountDetails': instance.amount.toJson(), 24 | 'reasonForPayment': instance.description, 25 | 'merchantReference': instance.reference, 26 | 'paymentMethodCode': instance.paymentMethodCode, 27 | 'customer': instance.customer.toJson(), 28 | 'returnUrl': instance.returnUrl, 29 | 'resultUrl': instance.resultUrl, 30 | }; 31 | -------------------------------------------------------------------------------- /lib/src/models/currency.dart: -------------------------------------------------------------------------------- 1 | // 2 | // currency 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 10/3/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | part 'currency.freezed.dart'; 12 | part 'currency.g.dart'; 13 | 14 | @freezed 15 | abstract class Currency with _$Currency { 16 | /// Currency Constructor 17 | const factory Currency({ 18 | /// The name of the currency. 19 | required String name, 20 | 21 | /// Description of the currency 22 | required String description, 23 | 24 | /// The unique code assigned to each currency. 25 | required String code, 26 | 27 | /// Flag to indicate the default currency of the system 28 | required bool defaultCurrency, 29 | 30 | /// Rate of the currency to the currency set as default. 31 | required double rateToDefault, 32 | 33 | /// Flag to indicate currency status 34 | required bool active, 35 | }) = _Currency; 36 | 37 | const Currency._(); 38 | 39 | /// Create currency instance from Map object or JSON data. 40 | factory Currency.fromJson(Map json) => 41 | _$CurrencyFromJson(json); 42 | 43 | @override 44 | String toString() { 45 | return 'Currency(name: $name, description: $description,' 46 | ' code: $code, defaultCurrency: $defaultCurrency, ' 47 | 'rateToDefault: $rateToDefault, active: $active)'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/src/models/transaction.dart: -------------------------------------------------------------------------------- 1 | // 2 | // transaction 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 10/3/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | import 'amount.dart'; 12 | 13 | part 'transaction.freezed.dart'; 14 | part 'transaction.g.dart'; 15 | 16 | @freezed 17 | abstract class Transaction with _$Transaction { 18 | /// Create transaction instance 19 | const factory Transaction({ 20 | /// Amount in value and currency 21 | // ignore: invalid_annotation_target 22 | @JsonKey(name: 'amountDetails') required Amount amount, 23 | 24 | /// Reason for payment 25 | // ignore: invalid_annotation_target 26 | @JsonKey(name: 'reasonForPayment') required String description, 27 | 28 | /// Reference from the merchant system 29 | // ignore: invalid_annotation_target 30 | @JsonKey(name: 'merchantReference') String? reference, 31 | 32 | /// Type of transaction 33 | @Default('BASIC') String transactionType, 34 | 35 | /// Result URL - HTTP callback endpoint on your server for receiving event 36 | /// notifications 37 | @Default('') String resultUrl, 38 | 39 | /// Return URL redirects users back to the originating page during a 40 | /// checkout flow 41 | @Default('') String returnUrl, 42 | }) = _Transaction; 43 | 44 | const Transaction._(); 45 | 46 | factory Transaction.fromJson(Map json) => 47 | _$TransactionFromJson(json); 48 | } 49 | -------------------------------------------------------------------------------- /lib/src/models/seamless_transaction.dart: -------------------------------------------------------------------------------- 1 | // 2 | // seamless_transaction.dart 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 19/4/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | 11 | import 'amount.dart'; 12 | import 'customer.dart'; 13 | 14 | part 'seamless_transaction.freezed.dart'; 15 | part 'seamless_transaction.g.dart'; 16 | 17 | @freezed 18 | abstract class SeamlessTransaction with _$SeamlessTransaction { 19 | const factory SeamlessTransaction({ 20 | /// Amount in value and currency 21 | // ignore: invalid_annotation_target 22 | @JsonKey(name: 'amountDetails') required Amount amount, 23 | 24 | /// Reason for payment 25 | // ignore: invalid_annotation_target 26 | @JsonKey(name: 'reasonForPayment') required String description, 27 | 28 | /// Reference from merchant system 29 | // ignore: invalid_annotation_target 30 | @JsonKey(name: 'merchantReference') required String reference, 31 | 32 | /// Payment method code 33 | required String paymentMethodCode, 34 | 35 | /// Customer details i.e. name, email and phone number 36 | required Customer customer, 37 | 38 | /// Return URL redirects users back to the originating page during a 39 | /// checkout flow 40 | @Default('') String returnUrl, 41 | 42 | /// Result URL - HTTP callback endpoint on your server for receiving event 43 | /// notifications 44 | @Default('') String resultUrl, 45 | }) = _SeamlessTransaction; 46 | 47 | const SeamlessTransaction._(); 48 | 49 | factory SeamlessTransaction.fromJson(Map json) => 50 | _$SeamlessTransactionFromJson(json); 51 | } 52 | -------------------------------------------------------------------------------- /lib/src/utils/dio_error_to_pesepay_exception.dart: -------------------------------------------------------------------------------- 1 | // 2 | // dio_error_to_pesepay_exception 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 14/4/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'package:dio/dio.dart'; 10 | 11 | import 'pesepay_exception.dart'; 12 | 13 | PesepayException dioErrorToPesepayException( 14 | DioError error, 15 | StackTrace stackTrace, 16 | ) { 17 | late PesepayException exception; 18 | switch (error.type) { 19 | case DioErrorType.connectionTimeout: 20 | exception = 21 | PesepayException('Connection Timeout', stackTrace: stackTrace); 22 | break; 23 | case DioErrorType.sendTimeout: 24 | exception = PesepayException('Send Timeout', stackTrace: stackTrace); 25 | break; 26 | case DioErrorType.receiveTimeout: 27 | exception = PesepayException('Receive Timeout', stackTrace: stackTrace); 28 | break; 29 | case DioErrorType.badResponse: 30 | exception = PesepayException( 31 | 'Bad Response' 32 | ' (${error.response?.statusCode}):${error.response?.statusMessage}', 33 | stackTrace: stackTrace, 34 | ); 35 | break; 36 | case DioErrorType.unknown: 37 | exception = PesepayException( 38 | 'Pesepay services are unavailable at the moment', 39 | stackTrace: stackTrace, 40 | ); 41 | break; 42 | case DioErrorType.cancel: 43 | exception = PesepayException('Request Cancelled', stackTrace: stackTrace); 44 | break; 45 | case DioErrorType.badCertificate: 46 | exception = PesepayException('Bad Certificate', stackTrace: stackTrace); 47 | break; 48 | case DioErrorType.connectionError: 49 | exception = PesepayException('Connection Error', stackTrace: stackTrace); 50 | break; 51 | } 52 | 53 | return exception; 54 | } 55 | -------------------------------------------------------------------------------- /lib/src/models/payment_method.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'payment_method.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _PaymentMethod _$PaymentMethodFromJson(Map json) => 10 | _PaymentMethod( 11 | active: json['active'] as bool, 12 | code: json['code'] as String, 13 | currencies: (json['currencies'] as List) 14 | .map((e) => e as String) 15 | .toList(), 16 | description: json['description'] as String, 17 | id: (json['id'] as num).toInt(), 18 | maximumAmount: (json['maximumAmount'] as num).toDouble(), 19 | minimumAmount: (json['minimumAmount'] as num).toDouble(), 20 | name: json['name'] as String, 21 | processingPaymentMessage: json['processingPaymentMessage'] as String, 22 | redirectRequired: json['redirectRequired'] as bool, 23 | redirectURL: json['redirectURL'] as String?, 24 | requiredFields: (json['requiredFields'] as List?) 25 | ?.map((e) => RequiredField.fromJson(e as Map)) 26 | .toList(), 27 | ); 28 | 29 | Map _$PaymentMethodToJson( 30 | _PaymentMethod instance, 31 | ) => { 32 | 'active': instance.active, 33 | 'code': instance.code, 34 | 'currencies': instance.currencies, 35 | 'description': instance.description, 36 | 'id': instance.id, 37 | 'maximumAmount': instance.maximumAmount, 38 | 'minimumAmount': instance.minimumAmount, 39 | 'name': instance.name, 40 | 'processingPaymentMessage': instance.processingPaymentMessage, 41 | 'redirectRequired': instance.redirectRequired, 42 | 'redirectURL': ?instance.redirectURL, 43 | 'requiredFields': ?instance.requiredFields?.map((e) => e.toJson()).toList(), 44 | }; 45 | -------------------------------------------------------------------------------- /lib/src/models/transaction_response.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'transaction_response.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _TransactionResponse _$TransactionResponseFromJson(Map json) => 10 | _TransactionResponse( 11 | referenceNumber: json['referenceNumber'] as String, 12 | pollUrl: json['pollUrl'] as String?, 13 | transactionStatus: $enumDecodeNullable( 14 | _$TransactionStatusEnumMap, 15 | json['transactionStatus'], 16 | ), 17 | redirectUrl: json['redirectUrl'] as String?, 18 | ); 19 | 20 | Map _$TransactionResponseToJson( 21 | _TransactionResponse instance, 22 | ) => { 23 | 'referenceNumber': instance.referenceNumber, 24 | 'pollUrl': ?instance.pollUrl, 25 | 'transactionStatus': ?_$TransactionStatusEnumMap[instance.transactionStatus], 26 | 'redirectUrl': ?instance.redirectUrl, 27 | }; 28 | 29 | const _$TransactionStatusEnumMap = { 30 | TransactionStatus.authorizationFailed: 'AUTHORIZATION_FAILED', 31 | TransactionStatus.cancelled: 'CANCELLED', 32 | TransactionStatus.closed: 'CLOSED', 33 | TransactionStatus.closedPeriodElapsed: 'CLOSED_PERIOD_ELAPSED', 34 | TransactionStatus.declined: 'DECLINED', 35 | TransactionStatus.error: 'ERROR', 36 | TransactionStatus.failed: 'FAILED', 37 | TransactionStatus.initiated: 'INITIATED', 38 | TransactionStatus.insufficientFunds: 'INSUFFICIENT_FUNDS', 39 | TransactionStatus.partiallyPaid: 'PARTIALLY_PAID', 40 | TransactionStatus.pending: 'PENDING', 41 | TransactionStatus.processing: 'PROCESSING', 42 | TransactionStatus.reversed: 'REVERSED', 43 | TransactionStatus.serviceUnavailable: 'SERVICE_UNAVAILABLE', 44 | TransactionStatus.success: 'SUCCESS', 45 | TransactionStatus.terminated: 'TERMINATED', 46 | TransactionStatus.timeOut: 'TIME_OUT', 47 | }; 48 | -------------------------------------------------------------------------------- /lib/src/utils/transaction_response_stream_manager.dart: -------------------------------------------------------------------------------- 1 | // 2 | // transaction_status_stream_manager 3 | // pesepay 4 | // 5 | // Created by Ngonidzashe Mangudya on 19/4/2023. 6 | // Copyright (c) 2023 ModestNerds, Co 7 | // 8 | 9 | import 'dart:async'; 10 | 11 | import '../models/models.dart'; 12 | import '../pesepay.dart'; 13 | 14 | /// Transaction Status Stream Manager 15 | /// Inspired by [paynow](https://pub.dev/packages/paynow) 16 | class TransactionResponseStreamManager { 17 | TransactionResponseStreamManager._({ 18 | required Pesepay pesepay, 19 | required String pollUrl, 20 | this.streamInterval = 20, 21 | }) : _pesepay = pesepay, 22 | _pollUrl = pollUrl { 23 | _stream(streamInterval); 24 | } 25 | 26 | factory TransactionResponseStreamManager.fromPesePay( 27 | Pesepay pesepay, { 28 | required String pollUrl, 29 | int streamInterval = 20, 30 | }) { 31 | return TransactionResponseStreamManager._( 32 | pesepay: pesepay, 33 | pollUrl: pollUrl, 34 | streamInterval: streamInterval, 35 | ); 36 | } 37 | 38 | final Pesepay _pesepay; 39 | final String _pollUrl; 40 | final int streamInterval; 41 | 42 | late final Timer _timer; 43 | 44 | final StreamController _transactionStatusController = 45 | StreamController(); 46 | 47 | Stream get stream => _transactionStatusController.stream; 48 | 49 | void _stream(int streamInterval) { 50 | _timer = Timer.periodic( 51 | Duration(seconds: streamInterval), 52 | (timer) async { 53 | // poll transaction poll-url 54 | final TransactionResponse transactionResponse = 55 | await _pesepay.checkTransactionStatus(_pollUrl); 56 | 57 | // update stream with latest poll url result 58 | _transactionStatusController.sink.add(transactionResponse); 59 | }, 60 | ); 61 | } 62 | 63 | /// close timer and stream controller 64 | void dispose() { 65 | _timer.cancel(); 66 | _transactionStatusController.close(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pesepay 2 | 3 | [![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link] 4 | [![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason) 5 | [![License: MIT][license_badge]][license_link] 6 | 7 | 8 | 9 | 10 | Pesepay helps businesses in Africa get paid by anyone, anywhere in the world 11 | 12 | > This is still WIP! Try out and contribute where you can. 13 | 14 | ## Installation 💻 15 | 16 | **❗ In order to start using Pesepay you must have the [Dart SDK][dart_install_link] installed on your machine.** 17 | 18 | Add `pesepay` to your `pubspec.yaml`: 19 | 20 | ```yaml 21 | dependencies: 22 | pesepay: 23 | ``` 24 | 25 | Install it: 26 | 27 | ```sh 28 | dart pub get 29 | ``` 30 | 31 | --- 32 | 33 | ## Usage 🔥 34 | 35 | ### Import package 36 | 37 | ```dart 38 | import 'package:pesepay/pesepay.dart'; 39 | ``` 40 | 41 | ### Declare and initialize 42 | 43 | ```dart 44 | final pesepay = Pesepay( 45 | integrationKey: '', 46 | encryptionKey: '', 47 | resultUrl: '', 48 | returnUrl: '', 49 | ); 50 | ``` 51 | 52 | ### Get list of active currencies 53 | ```dart 54 | final List currencies = await Pesepay.getActiveCurrencies(); 55 | ``` 56 | Sample Currency 57 | ```dart 58 | Currency( 59 | name: Zimbabwe Dollar, 60 | description: Zimbabwe Dollar, 61 | code: ZWL, 62 | defaultCurrency: false, 63 | rateToDefault: 604.25, 64 | active: true 65 | ) 66 | ``` 67 | 68 | ### Get list of payment methods for selected currency 69 | ```dart 70 | final List methods = await Pesepay.getPaymentMethodsByCurrency(currency); 71 | ``` 72 | 73 | Sample PaymentMethod 74 | ```dart 75 | PaymentMethod( 76 | active: true, 77 | code: PZW201, 78 | currencies: [ZWL], 79 | description: Make payment directly from your mobile phone., 80 | id: 1, 81 | maximumAmount: 50000.0, 82 | minimumAmount: 2.0, 83 | name: Ecocash, 84 | processingPaymentMessage: Please enter PIN on the phone that is making the payment., 85 | redirectRequired: false, 86 | redirectURL: null, 87 | requiredFields: [ 88 | RequiredField( 89 | displayName: Phone Number, 90 | fieldType: TEXT, 91 | name: customerPhoneNumber, 92 | optional: false 93 | ) 94 | ] 95 | ) 96 | ``` 97 | 98 | ### Perform Web Transaction 99 | This relies on the returned web `redirectUrl` that customers can use to complete the transaction 100 | 101 | First step would be to create the transaction: 102 | ```dart 103 | final Transaction transaction = pesepay.createTransaction( 104 | amount: 1, 105 | currencyCode: 'ZWL', 106 | transactionDescription: 'Bag of potatoes', 107 | transactionReference: '111-222-333' 108 | ) 109 | ``` 110 | 111 | Then process the transaction: 112 | ```dart 113 | final TransactionResponse response = await pesepay.initiateWebTransaction(transaction); 114 | ``` 115 | 116 | If the above execution results in any error either within the package itself or from the Pesepay server side you should except a `PesepayException`. So it would be helpful to handle that. 117 | 118 | ### Perform Seamless Transaction 119 | First step here would be to create the transaction: 120 | ```dart 121 | final SeamlessTransaction seamlessTransaction = pesepay.createSeamlessTransaction( 122 | customerName: 'Cool Name', 123 | customerEmail: 'yourmail@email.com', 124 | customerPhone: '0777111111', 125 | amount: 1, 126 | currencyCode: 'ZWL', 127 | transactionDescription: 'Banana Peel', 128 | transactionReference: '111-222-333', 129 | paymentMethodCode: paymentMethodCode, 130 | ); 131 | ``` 132 | 133 | Process the seamless transaction: 134 | ```dart 135 | final TransactionResponse response = await pesepay.initiateSeamlessTransaction(transaction); 136 | ``` 137 | 138 | ### Check transaction status 139 | ```dart 140 | final TransactionResponse response = await pesepay.checkTransactionStatus(pollUrl); 141 | ``` 142 | 143 | ### Serverless Checkout ? 144 | Instead of using delays to check transaction status you can also `stream` the `TransactionResponse` using the poll url. 145 | 146 | - `pesepay.streamTransactionResponse(..)` takes a required `pollUrl` string and optional `streamInterval` in seconds which is the interval to poll the url, default to `20` sec 147 | - You can stream status and show current transaction status on UI to user with a `StreamBuilder(..)` like below: 148 | 149 | ```dart 150 | final String pollUrl = response.pollUrl; 151 | 152 | // in Widget build(..) method 153 | // you can do something like 154 | StreamBuilder( 155 | stream: pesepay.streamTransactionResponse(pollUrl), 156 | builder: (context, AsyncSnapshot snapshot) { 157 | if(snapshot.hasData) { 158 | final TransactionResponse response = snapshot.data!; 159 | return response.paid ? SuccessWidget() : OtherWidgetsForErrorOrWaiting(); 160 | } else { 161 | return CircularProgressIndicator(); 162 | } 163 | } 164 | ) 165 | ``` 166 | 167 | ### Full Usage Example 168 | ```dart 169 | void main() async { 170 | try { 171 | final pesepay = Pesepay( 172 | integrationKey: '', 173 | encryptionKey: '', 174 | resultUrl: '', 175 | returnUrl: '', 176 | ); 177 | 178 | final Transaction transaction = pesepay.createTransaction( 179 | amount: 1, 180 | currencyCode: 'ZWL', 181 | transactionDescription: 'Bag of potatoes', 182 | transactionReference: '111-222-333' 183 | ); 184 | 185 | final TransactionResponse response = await pesepay.initiateWebTransaction(transaction); 186 | 187 | // Add a delay before checking status, maybe 20-30 seconds 188 | await Future.delayed(const Duration(seconds: 30)) 189 | 190 | // Check status 191 | final TransactionResponse pollResponse = await pesepay.checkTransactionStatus(response.pollUrl); 192 | 193 | if (pollResponse.paid) { 194 | // well you've done it 195 | print('I deserve drinks 🍻'); 196 | } else { 197 | // not yet pal 198 | print('👎🏿') 199 | } 200 | 201 | } on PesepayException catch (e) { 202 | print(e.message); 203 | } catch (e) { 204 | // hell 205 | } 206 | } 207 | ``` 208 | 209 | --- 210 | [dart_install_link]: https://dart.dev/get-dart 211 | [github_actions_link]: https://docs.github.com/en/actions/learn-github-actions 212 | [license_badge]: https://img.shields.io/badge/license-MIT-blue.svg 213 | [license_link]: https://opensource.org/licenses/MIT 214 | [logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only 215 | [logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only 216 | [mason_link]: https://github.com/felangel/mason 217 | [very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg 218 | [very_good_analysis_link]: https://pub.dev/packages/very_good_analysis 219 | [very_good_coverage_link]: https://github.com/marketplace/actions/very-good-coverage 220 | [very_good_ventures_link]: https://verygood.ventures 221 | [very_good_ventures_link_light]: https://verygood.ventures#gh-light-mode-only 222 | [very_good_ventures_link_dark]: https://verygood.ventures#gh-dark-mode-only 223 | [very_good_workflows_link]: https://github.com/VeryGoodOpenSource/very_good_workflows -------------------------------------------------------------------------------- /lib/src/models/amount.freezed.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // coverage:ignore-file 3 | // ignore_for_file: type=lint 4 | // 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 5 | 6 | part of 'amount.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | // dart format off 13 | T _$identity(T value) => value; 14 | 15 | /// @nodoc 16 | mixin _$Amount { 17 | 18 | /// The amount figure in dollars 19 | double get amount;/// Currency specification e.g. ZWL 20 | // ignore: invalid_annotation_target 21 | @JsonKey(name: 'currencyCode') String get currency; 22 | /// Create a copy of Amount 23 | /// with the given fields replaced by the non-null parameter values. 24 | @JsonKey(includeFromJson: false, includeToJson: false) 25 | @pragma('vm:prefer-inline') 26 | $AmountCopyWith get copyWith => _$AmountCopyWithImpl(this as Amount, _$identity); 27 | 28 | /// Serializes this Amount to a JSON map. 29 | Map toJson(); 30 | 31 | 32 | @override 33 | bool operator ==(Object other) { 34 | return identical(this, other) || (other.runtimeType == runtimeType&&other is Amount&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.currency, currency) || other.currency == currency)); 35 | } 36 | 37 | @JsonKey(includeFromJson: false, includeToJson: false) 38 | @override 39 | int get hashCode => Object.hash(runtimeType,amount,currency); 40 | 41 | @override 42 | String toString() { 43 | return 'Amount(amount: $amount, currency: $currency)'; 44 | } 45 | 46 | 47 | } 48 | 49 | /// @nodoc 50 | abstract mixin class $AmountCopyWith<$Res> { 51 | factory $AmountCopyWith(Amount value, $Res Function(Amount) _then) = _$AmountCopyWithImpl; 52 | @useResult 53 | $Res call({ 54 | double amount,@JsonKey(name: 'currencyCode') String currency 55 | }); 56 | 57 | 58 | 59 | 60 | } 61 | /// @nodoc 62 | class _$AmountCopyWithImpl<$Res> 63 | implements $AmountCopyWith<$Res> { 64 | _$AmountCopyWithImpl(this._self, this._then); 65 | 66 | final Amount _self; 67 | final $Res Function(Amount) _then; 68 | 69 | /// Create a copy of Amount 70 | /// with the given fields replaced by the non-null parameter values. 71 | @pragma('vm:prefer-inline') @override $Res call({Object? amount = null,Object? currency = null,}) { 72 | return _then(_self.copyWith( 73 | amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable 74 | as double,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable 75 | as String, 76 | )); 77 | } 78 | 79 | } 80 | 81 | 82 | /// Adds pattern-matching-related methods to [Amount]. 83 | extension AmountPatterns on Amount { 84 | /// A variant of `map` that fallback to returning `orElse`. 85 | /// 86 | /// It is equivalent to doing: 87 | /// ```dart 88 | /// switch (sealedClass) { 89 | /// case final Subclass value: 90 | /// return ...; 91 | /// case _: 92 | /// return orElse(); 93 | /// } 94 | /// ``` 95 | 96 | @optionalTypeArgs TResult maybeMap(TResult Function( _Amount value)? $default,{required TResult orElse(),}){ 97 | final _that = this; 98 | switch (_that) { 99 | case _Amount() when $default != null: 100 | return $default(_that);case _: 101 | return orElse(); 102 | 103 | } 104 | } 105 | /// A `switch`-like method, using callbacks. 106 | /// 107 | /// Callbacks receives the raw object, upcasted. 108 | /// It is equivalent to doing: 109 | /// ```dart 110 | /// switch (sealedClass) { 111 | /// case final Subclass value: 112 | /// return ...; 113 | /// case final Subclass2 value: 114 | /// return ...; 115 | /// } 116 | /// ``` 117 | 118 | @optionalTypeArgs TResult map(TResult Function( _Amount value) $default,){ 119 | final _that = this; 120 | switch (_that) { 121 | case _Amount(): 122 | return $default(_that);case _: 123 | throw StateError('Unexpected subclass'); 124 | 125 | } 126 | } 127 | /// A variant of `map` that fallback to returning `null`. 128 | /// 129 | /// It is equivalent to doing: 130 | /// ```dart 131 | /// switch (sealedClass) { 132 | /// case final Subclass value: 133 | /// return ...; 134 | /// case _: 135 | /// return null; 136 | /// } 137 | /// ``` 138 | 139 | @optionalTypeArgs TResult? mapOrNull(TResult? Function( _Amount value)? $default,){ 140 | final _that = this; 141 | switch (_that) { 142 | case _Amount() when $default != null: 143 | return $default(_that);case _: 144 | return null; 145 | 146 | } 147 | } 148 | /// A variant of `when` that fallback to an `orElse` callback. 149 | /// 150 | /// It is equivalent to doing: 151 | /// ```dart 152 | /// switch (sealedClass) { 153 | /// case Subclass(:final field): 154 | /// return ...; 155 | /// case _: 156 | /// return orElse(); 157 | /// } 158 | /// ``` 159 | 160 | @optionalTypeArgs TResult maybeWhen(TResult Function( double amount, @JsonKey(name: 'currencyCode') String currency)? $default,{required TResult orElse(),}) {final _that = this; 161 | switch (_that) { 162 | case _Amount() when $default != null: 163 | return $default(_that.amount,_that.currency);case _: 164 | return orElse(); 165 | 166 | } 167 | } 168 | /// A `switch`-like method, using callbacks. 169 | /// 170 | /// As opposed to `map`, this offers destructuring. 171 | /// It is equivalent to doing: 172 | /// ```dart 173 | /// switch (sealedClass) { 174 | /// case Subclass(:final field): 175 | /// return ...; 176 | /// case Subclass2(:final field2): 177 | /// return ...; 178 | /// } 179 | /// ``` 180 | 181 | @optionalTypeArgs TResult when(TResult Function( double amount, @JsonKey(name: 'currencyCode') String currency) $default,) {final _that = this; 182 | switch (_that) { 183 | case _Amount(): 184 | return $default(_that.amount,_that.currency);case _: 185 | throw StateError('Unexpected subclass'); 186 | 187 | } 188 | } 189 | /// A variant of `when` that fallback to returning `null` 190 | /// 191 | /// It is equivalent to doing: 192 | /// ```dart 193 | /// switch (sealedClass) { 194 | /// case Subclass(:final field): 195 | /// return ...; 196 | /// case _: 197 | /// return null; 198 | /// } 199 | /// ``` 200 | 201 | @optionalTypeArgs TResult? whenOrNull(TResult? Function( double amount, @JsonKey(name: 'currencyCode') String currency)? $default,) {final _that = this; 202 | switch (_that) { 203 | case _Amount() when $default != null: 204 | return $default(_that.amount,_that.currency);case _: 205 | return null; 206 | 207 | } 208 | } 209 | 210 | } 211 | 212 | /// @nodoc 213 | @JsonSerializable() 214 | 215 | class _Amount extends Amount { 216 | const _Amount({required this.amount, @JsonKey(name: 'currencyCode') required this.currency}): super._(); 217 | factory _Amount.fromJson(Map json) => _$AmountFromJson(json); 218 | 219 | /// The amount figure in dollars 220 | @override final double amount; 221 | /// Currency specification e.g. ZWL 222 | // ignore: invalid_annotation_target 223 | @override@JsonKey(name: 'currencyCode') final String currency; 224 | 225 | /// Create a copy of Amount 226 | /// with the given fields replaced by the non-null parameter values. 227 | @override @JsonKey(includeFromJson: false, includeToJson: false) 228 | @pragma('vm:prefer-inline') 229 | _$AmountCopyWith<_Amount> get copyWith => __$AmountCopyWithImpl<_Amount>(this, _$identity); 230 | 231 | @override 232 | Map toJson() { 233 | return _$AmountToJson(this, ); 234 | } 235 | 236 | @override 237 | bool operator ==(Object other) { 238 | return identical(this, other) || (other.runtimeType == runtimeType&&other is _Amount&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.currency, currency) || other.currency == currency)); 239 | } 240 | 241 | @JsonKey(includeFromJson: false, includeToJson: false) 242 | @override 243 | int get hashCode => Object.hash(runtimeType,amount,currency); 244 | 245 | @override 246 | String toString() { 247 | return 'Amount(amount: $amount, currency: $currency)'; 248 | } 249 | 250 | 251 | } 252 | 253 | /// @nodoc 254 | abstract mixin class _$AmountCopyWith<$Res> implements $AmountCopyWith<$Res> { 255 | factory _$AmountCopyWith(_Amount value, $Res Function(_Amount) _then) = __$AmountCopyWithImpl; 256 | @override @useResult 257 | $Res call({ 258 | double amount,@JsonKey(name: 'currencyCode') String currency 259 | }); 260 | 261 | 262 | 263 | 264 | } 265 | /// @nodoc 266 | class __$AmountCopyWithImpl<$Res> 267 | implements _$AmountCopyWith<$Res> { 268 | __$AmountCopyWithImpl(this._self, this._then); 269 | 270 | final _Amount _self; 271 | final $Res Function(_Amount) _then; 272 | 273 | /// Create a copy of Amount 274 | /// with the given fields replaced by the non-null parameter values. 275 | @override @pragma('vm:prefer-inline') $Res call({Object? amount = null,Object? currency = null,}) { 276 | return _then(_Amount( 277 | amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable 278 | as double,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable 279 | as String, 280 | )); 281 | } 282 | 283 | 284 | } 285 | 286 | // dart format on 287 | -------------------------------------------------------------------------------- /lib/src/models/customer.freezed.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // coverage:ignore-file 3 | // ignore_for_file: type=lint 4 | // 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 5 | 6 | part of 'customer.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | // dart format off 13 | T _$identity(T value) => value; 14 | 15 | /// @nodoc 16 | mixin _$Customer { 17 | 18 | /// Customer email 19 | String get email;/// Customer phone number 20 | String get phoneNumber;/// Customer name 21 | String get name; 22 | /// Create a copy of Customer 23 | /// with the given fields replaced by the non-null parameter values. 24 | @JsonKey(includeFromJson: false, includeToJson: false) 25 | @pragma('vm:prefer-inline') 26 | $CustomerCopyWith get copyWith => _$CustomerCopyWithImpl(this as Customer, _$identity); 27 | 28 | /// Serializes this Customer to a JSON map. 29 | Map toJson(); 30 | 31 | 32 | @override 33 | bool operator ==(Object other) { 34 | return identical(this, other) || (other.runtimeType == runtimeType&&other is Customer&&(identical(other.email, email) || other.email == email)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.name, name) || other.name == name)); 35 | } 36 | 37 | @JsonKey(includeFromJson: false, includeToJson: false) 38 | @override 39 | int get hashCode => Object.hash(runtimeType,email,phoneNumber,name); 40 | 41 | @override 42 | String toString() { 43 | return 'Customer(email: $email, phoneNumber: $phoneNumber, name: $name)'; 44 | } 45 | 46 | 47 | } 48 | 49 | /// @nodoc 50 | abstract mixin class $CustomerCopyWith<$Res> { 51 | factory $CustomerCopyWith(Customer value, $Res Function(Customer) _then) = _$CustomerCopyWithImpl; 52 | @useResult 53 | $Res call({ 54 | String email, String phoneNumber, String name 55 | }); 56 | 57 | 58 | 59 | 60 | } 61 | /// @nodoc 62 | class _$CustomerCopyWithImpl<$Res> 63 | implements $CustomerCopyWith<$Res> { 64 | _$CustomerCopyWithImpl(this._self, this._then); 65 | 66 | final Customer _self; 67 | final $Res Function(Customer) _then; 68 | 69 | /// Create a copy of Customer 70 | /// with the given fields replaced by the non-null parameter values. 71 | @pragma('vm:prefer-inline') @override $Res call({Object? email = null,Object? phoneNumber = null,Object? name = null,}) { 72 | return _then(_self.copyWith( 73 | email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable 74 | as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable 75 | as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable 76 | as String, 77 | )); 78 | } 79 | 80 | } 81 | 82 | 83 | /// Adds pattern-matching-related methods to [Customer]. 84 | extension CustomerPatterns on Customer { 85 | /// A variant of `map` that fallback to returning `orElse`. 86 | /// 87 | /// It is equivalent to doing: 88 | /// ```dart 89 | /// switch (sealedClass) { 90 | /// case final Subclass value: 91 | /// return ...; 92 | /// case _: 93 | /// return orElse(); 94 | /// } 95 | /// ``` 96 | 97 | @optionalTypeArgs TResult maybeMap(TResult Function( _Customer value)? $default,{required TResult orElse(),}){ 98 | final _that = this; 99 | switch (_that) { 100 | case _Customer() when $default != null: 101 | return $default(_that);case _: 102 | return orElse(); 103 | 104 | } 105 | } 106 | /// A `switch`-like method, using callbacks. 107 | /// 108 | /// Callbacks receives the raw object, upcasted. 109 | /// It is equivalent to doing: 110 | /// ```dart 111 | /// switch (sealedClass) { 112 | /// case final Subclass value: 113 | /// return ...; 114 | /// case final Subclass2 value: 115 | /// return ...; 116 | /// } 117 | /// ``` 118 | 119 | @optionalTypeArgs TResult map(TResult Function( _Customer value) $default,){ 120 | final _that = this; 121 | switch (_that) { 122 | case _Customer(): 123 | return $default(_that);case _: 124 | throw StateError('Unexpected subclass'); 125 | 126 | } 127 | } 128 | /// A variant of `map` that fallback to returning `null`. 129 | /// 130 | /// It is equivalent to doing: 131 | /// ```dart 132 | /// switch (sealedClass) { 133 | /// case final Subclass value: 134 | /// return ...; 135 | /// case _: 136 | /// return null; 137 | /// } 138 | /// ``` 139 | 140 | @optionalTypeArgs TResult? mapOrNull(TResult? Function( _Customer value)? $default,){ 141 | final _that = this; 142 | switch (_that) { 143 | case _Customer() when $default != null: 144 | return $default(_that);case _: 145 | return null; 146 | 147 | } 148 | } 149 | /// A variant of `when` that fallback to an `orElse` callback. 150 | /// 151 | /// It is equivalent to doing: 152 | /// ```dart 153 | /// switch (sealedClass) { 154 | /// case Subclass(:final field): 155 | /// return ...; 156 | /// case _: 157 | /// return orElse(); 158 | /// } 159 | /// ``` 160 | 161 | @optionalTypeArgs TResult maybeWhen(TResult Function( String email, String phoneNumber, String name)? $default,{required TResult orElse(),}) {final _that = this; 162 | switch (_that) { 163 | case _Customer() when $default != null: 164 | return $default(_that.email,_that.phoneNumber,_that.name);case _: 165 | return orElse(); 166 | 167 | } 168 | } 169 | /// A `switch`-like method, using callbacks. 170 | /// 171 | /// As opposed to `map`, this offers destructuring. 172 | /// It is equivalent to doing: 173 | /// ```dart 174 | /// switch (sealedClass) { 175 | /// case Subclass(:final field): 176 | /// return ...; 177 | /// case Subclass2(:final field2): 178 | /// return ...; 179 | /// } 180 | /// ``` 181 | 182 | @optionalTypeArgs TResult when(TResult Function( String email, String phoneNumber, String name) $default,) {final _that = this; 183 | switch (_that) { 184 | case _Customer(): 185 | return $default(_that.email,_that.phoneNumber,_that.name);case _: 186 | throw StateError('Unexpected subclass'); 187 | 188 | } 189 | } 190 | /// A variant of `when` that fallback to returning `null` 191 | /// 192 | /// It is equivalent to doing: 193 | /// ```dart 194 | /// switch (sealedClass) { 195 | /// case Subclass(:final field): 196 | /// return ...; 197 | /// case _: 198 | /// return null; 199 | /// } 200 | /// ``` 201 | 202 | @optionalTypeArgs TResult? whenOrNull(TResult? Function( String email, String phoneNumber, String name)? $default,) {final _that = this; 203 | switch (_that) { 204 | case _Customer() when $default != null: 205 | return $default(_that.email,_that.phoneNumber,_that.name);case _: 206 | return null; 207 | 208 | } 209 | } 210 | 211 | } 212 | 213 | /// @nodoc 214 | @JsonSerializable() 215 | 216 | class _Customer extends Customer { 217 | const _Customer({required this.email, required this.phoneNumber, required this.name}): super._(); 218 | factory _Customer.fromJson(Map json) => _$CustomerFromJson(json); 219 | 220 | /// Customer email 221 | @override final String email; 222 | /// Customer phone number 223 | @override final String phoneNumber; 224 | /// Customer name 225 | @override final String name; 226 | 227 | /// Create a copy of Customer 228 | /// with the given fields replaced by the non-null parameter values. 229 | @override @JsonKey(includeFromJson: false, includeToJson: false) 230 | @pragma('vm:prefer-inline') 231 | _$CustomerCopyWith<_Customer> get copyWith => __$CustomerCopyWithImpl<_Customer>(this, _$identity); 232 | 233 | @override 234 | Map toJson() { 235 | return _$CustomerToJson(this, ); 236 | } 237 | 238 | @override 239 | bool operator ==(Object other) { 240 | return identical(this, other) || (other.runtimeType == runtimeType&&other is _Customer&&(identical(other.email, email) || other.email == email)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.name, name) || other.name == name)); 241 | } 242 | 243 | @JsonKey(includeFromJson: false, includeToJson: false) 244 | @override 245 | int get hashCode => Object.hash(runtimeType,email,phoneNumber,name); 246 | 247 | @override 248 | String toString() { 249 | return 'Customer(email: $email, phoneNumber: $phoneNumber, name: $name)'; 250 | } 251 | 252 | 253 | } 254 | 255 | /// @nodoc 256 | abstract mixin class _$CustomerCopyWith<$Res> implements $CustomerCopyWith<$Res> { 257 | factory _$CustomerCopyWith(_Customer value, $Res Function(_Customer) _then) = __$CustomerCopyWithImpl; 258 | @override @useResult 259 | $Res call({ 260 | String email, String phoneNumber, String name 261 | }); 262 | 263 | 264 | 265 | 266 | } 267 | /// @nodoc 268 | class __$CustomerCopyWithImpl<$Res> 269 | implements _$CustomerCopyWith<$Res> { 270 | __$CustomerCopyWithImpl(this._self, this._then); 271 | 272 | final _Customer _self; 273 | final $Res Function(_Customer) _then; 274 | 275 | /// Create a copy of Customer 276 | /// with the given fields replaced by the non-null parameter values. 277 | @override @pragma('vm:prefer-inline') $Res call({Object? email = null,Object? phoneNumber = null,Object? name = null,}) { 278 | return _then(_Customer( 279 | email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable 280 | as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable 281 | as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable 282 | as String, 283 | )); 284 | } 285 | 286 | 287 | } 288 | 289 | // dart format on 290 | -------------------------------------------------------------------------------- /lib/src/models/required_field.freezed.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // coverage:ignore-file 3 | // ignore_for_file: type=lint 4 | // 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 5 | 6 | part of 'required_field.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | // dart format off 13 | T _$identity(T value) => value; 14 | 15 | /// @nodoc 16 | mixin _$RequiredField { 17 | 18 | String get displayName; String get fieldType; String get name; bool get optional; 19 | /// Create a copy of RequiredField 20 | /// with the given fields replaced by the non-null parameter values. 21 | @JsonKey(includeFromJson: false, includeToJson: false) 22 | @pragma('vm:prefer-inline') 23 | $RequiredFieldCopyWith get copyWith => _$RequiredFieldCopyWithImpl(this as RequiredField, _$identity); 24 | 25 | /// Serializes this RequiredField to a JSON map. 26 | Map toJson(); 27 | 28 | 29 | @override 30 | bool operator ==(Object other) { 31 | return identical(this, other) || (other.runtimeType == runtimeType&&other is RequiredField&&(identical(other.displayName, displayName) || other.displayName == displayName)&&(identical(other.fieldType, fieldType) || other.fieldType == fieldType)&&(identical(other.name, name) || other.name == name)&&(identical(other.optional, optional) || other.optional == optional)); 32 | } 33 | 34 | @JsonKey(includeFromJson: false, includeToJson: false) 35 | @override 36 | int get hashCode => Object.hash(runtimeType,displayName,fieldType,name,optional); 37 | 38 | @override 39 | String toString() { 40 | return 'RequiredField(displayName: $displayName, fieldType: $fieldType, name: $name, optional: $optional)'; 41 | } 42 | 43 | 44 | } 45 | 46 | /// @nodoc 47 | abstract mixin class $RequiredFieldCopyWith<$Res> { 48 | factory $RequiredFieldCopyWith(RequiredField value, $Res Function(RequiredField) _then) = _$RequiredFieldCopyWithImpl; 49 | @useResult 50 | $Res call({ 51 | String displayName, String fieldType, String name, bool optional 52 | }); 53 | 54 | 55 | 56 | 57 | } 58 | /// @nodoc 59 | class _$RequiredFieldCopyWithImpl<$Res> 60 | implements $RequiredFieldCopyWith<$Res> { 61 | _$RequiredFieldCopyWithImpl(this._self, this._then); 62 | 63 | final RequiredField _self; 64 | final $Res Function(RequiredField) _then; 65 | 66 | /// Create a copy of RequiredField 67 | /// with the given fields replaced by the non-null parameter values. 68 | @pragma('vm:prefer-inline') @override $Res call({Object? displayName = null,Object? fieldType = null,Object? name = null,Object? optional = null,}) { 69 | return _then(_self.copyWith( 70 | displayName: null == displayName ? _self.displayName : displayName // ignore: cast_nullable_to_non_nullable 71 | as String,fieldType: null == fieldType ? _self.fieldType : fieldType // ignore: cast_nullable_to_non_nullable 72 | as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable 73 | as String,optional: null == optional ? _self.optional : optional // ignore: cast_nullable_to_non_nullable 74 | as bool, 75 | )); 76 | } 77 | 78 | } 79 | 80 | 81 | /// Adds pattern-matching-related methods to [RequiredField]. 82 | extension RequiredFieldPatterns on RequiredField { 83 | /// A variant of `map` that fallback to returning `orElse`. 84 | /// 85 | /// It is equivalent to doing: 86 | /// ```dart 87 | /// switch (sealedClass) { 88 | /// case final Subclass value: 89 | /// return ...; 90 | /// case _: 91 | /// return orElse(); 92 | /// } 93 | /// ``` 94 | 95 | @optionalTypeArgs TResult maybeMap(TResult Function( _RequiredField value)? $default,{required TResult orElse(),}){ 96 | final _that = this; 97 | switch (_that) { 98 | case _RequiredField() when $default != null: 99 | return $default(_that);case _: 100 | return orElse(); 101 | 102 | } 103 | } 104 | /// A `switch`-like method, using callbacks. 105 | /// 106 | /// Callbacks receives the raw object, upcasted. 107 | /// It is equivalent to doing: 108 | /// ```dart 109 | /// switch (sealedClass) { 110 | /// case final Subclass value: 111 | /// return ...; 112 | /// case final Subclass2 value: 113 | /// return ...; 114 | /// } 115 | /// ``` 116 | 117 | @optionalTypeArgs TResult map(TResult Function( _RequiredField value) $default,){ 118 | final _that = this; 119 | switch (_that) { 120 | case _RequiredField(): 121 | return $default(_that);case _: 122 | throw StateError('Unexpected subclass'); 123 | 124 | } 125 | } 126 | /// A variant of `map` that fallback to returning `null`. 127 | /// 128 | /// It is equivalent to doing: 129 | /// ```dart 130 | /// switch (sealedClass) { 131 | /// case final Subclass value: 132 | /// return ...; 133 | /// case _: 134 | /// return null; 135 | /// } 136 | /// ``` 137 | 138 | @optionalTypeArgs TResult? mapOrNull(TResult? Function( _RequiredField value)? $default,){ 139 | final _that = this; 140 | switch (_that) { 141 | case _RequiredField() when $default != null: 142 | return $default(_that);case _: 143 | return null; 144 | 145 | } 146 | } 147 | /// A variant of `when` that fallback to an `orElse` callback. 148 | /// 149 | /// It is equivalent to doing: 150 | /// ```dart 151 | /// switch (sealedClass) { 152 | /// case Subclass(:final field): 153 | /// return ...; 154 | /// case _: 155 | /// return orElse(); 156 | /// } 157 | /// ``` 158 | 159 | @optionalTypeArgs TResult maybeWhen(TResult Function( String displayName, String fieldType, String name, bool optional)? $default,{required TResult orElse(),}) {final _that = this; 160 | switch (_that) { 161 | case _RequiredField() when $default != null: 162 | return $default(_that.displayName,_that.fieldType,_that.name,_that.optional);case _: 163 | return orElse(); 164 | 165 | } 166 | } 167 | /// A `switch`-like method, using callbacks. 168 | /// 169 | /// As opposed to `map`, this offers destructuring. 170 | /// It is equivalent to doing: 171 | /// ```dart 172 | /// switch (sealedClass) { 173 | /// case Subclass(:final field): 174 | /// return ...; 175 | /// case Subclass2(:final field2): 176 | /// return ...; 177 | /// } 178 | /// ``` 179 | 180 | @optionalTypeArgs TResult when(TResult Function( String displayName, String fieldType, String name, bool optional) $default,) {final _that = this; 181 | switch (_that) { 182 | case _RequiredField(): 183 | return $default(_that.displayName,_that.fieldType,_that.name,_that.optional);case _: 184 | throw StateError('Unexpected subclass'); 185 | 186 | } 187 | } 188 | /// A variant of `when` that fallback to returning `null` 189 | /// 190 | /// It is equivalent to doing: 191 | /// ```dart 192 | /// switch (sealedClass) { 193 | /// case Subclass(:final field): 194 | /// return ...; 195 | /// case _: 196 | /// return null; 197 | /// } 198 | /// ``` 199 | 200 | @optionalTypeArgs TResult? whenOrNull(TResult? Function( String displayName, String fieldType, String name, bool optional)? $default,) {final _that = this; 201 | switch (_that) { 202 | case _RequiredField() when $default != null: 203 | return $default(_that.displayName,_that.fieldType,_that.name,_that.optional);case _: 204 | return null; 205 | 206 | } 207 | } 208 | 209 | } 210 | 211 | /// @nodoc 212 | @JsonSerializable() 213 | 214 | class _RequiredField implements RequiredField { 215 | const _RequiredField({required this.displayName, required this.fieldType, required this.name, required this.optional}); 216 | factory _RequiredField.fromJson(Map json) => _$RequiredFieldFromJson(json); 217 | 218 | @override final String displayName; 219 | @override final String fieldType; 220 | @override final String name; 221 | @override final bool optional; 222 | 223 | /// Create a copy of RequiredField 224 | /// with the given fields replaced by the non-null parameter values. 225 | @override @JsonKey(includeFromJson: false, includeToJson: false) 226 | @pragma('vm:prefer-inline') 227 | _$RequiredFieldCopyWith<_RequiredField> get copyWith => __$RequiredFieldCopyWithImpl<_RequiredField>(this, _$identity); 228 | 229 | @override 230 | Map toJson() { 231 | return _$RequiredFieldToJson(this, ); 232 | } 233 | 234 | @override 235 | bool operator ==(Object other) { 236 | return identical(this, other) || (other.runtimeType == runtimeType&&other is _RequiredField&&(identical(other.displayName, displayName) || other.displayName == displayName)&&(identical(other.fieldType, fieldType) || other.fieldType == fieldType)&&(identical(other.name, name) || other.name == name)&&(identical(other.optional, optional) || other.optional == optional)); 237 | } 238 | 239 | @JsonKey(includeFromJson: false, includeToJson: false) 240 | @override 241 | int get hashCode => Object.hash(runtimeType,displayName,fieldType,name,optional); 242 | 243 | @override 244 | String toString() { 245 | return 'RequiredField(displayName: $displayName, fieldType: $fieldType, name: $name, optional: $optional)'; 246 | } 247 | 248 | 249 | } 250 | 251 | /// @nodoc 252 | abstract mixin class _$RequiredFieldCopyWith<$Res> implements $RequiredFieldCopyWith<$Res> { 253 | factory _$RequiredFieldCopyWith(_RequiredField value, $Res Function(_RequiredField) _then) = __$RequiredFieldCopyWithImpl; 254 | @override @useResult 255 | $Res call({ 256 | String displayName, String fieldType, String name, bool optional 257 | }); 258 | 259 | 260 | 261 | 262 | } 263 | /// @nodoc 264 | class __$RequiredFieldCopyWithImpl<$Res> 265 | implements _$RequiredFieldCopyWith<$Res> { 266 | __$RequiredFieldCopyWithImpl(this._self, this._then); 267 | 268 | final _RequiredField _self; 269 | final $Res Function(_RequiredField) _then; 270 | 271 | /// Create a copy of RequiredField 272 | /// with the given fields replaced by the non-null parameter values. 273 | @override @pragma('vm:prefer-inline') $Res call({Object? displayName = null,Object? fieldType = null,Object? name = null,Object? optional = null,}) { 274 | return _then(_RequiredField( 275 | displayName: null == displayName ? _self.displayName : displayName // ignore: cast_nullable_to_non_nullable 276 | as String,fieldType: null == fieldType ? _self.fieldType : fieldType // ignore: cast_nullable_to_non_nullable 277 | as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable 278 | as String,optional: null == optional ? _self.optional : optional // ignore: cast_nullable_to_non_nullable 279 | as bool, 280 | )); 281 | } 282 | 283 | 284 | } 285 | 286 | // dart format on 287 | -------------------------------------------------------------------------------- /lib/src/pesepay.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:developer'; 3 | 4 | import 'package:dio/dio.dart'; 5 | import 'package:encrypt/encrypt.dart'; 6 | import 'package:localregex/localregex.dart'; 7 | 8 | import 'models/models.dart'; 9 | import 'utils/utils.dart'; 10 | 11 | /// A simple library that wraps Pesepay payment gateway functionalities for 12 | /// the purposes of simplicity and accessibility for developers. 13 | /// 14 | /// Pesepay is a payment service provider with a focus on Africa, allowing 15 | /// payments to be made through the internet 16 | 17 | class Pesepay { 18 | /// Instantiate the Pesepay class that can be used to perform transactions 19 | /// and other functionalities offered by Pesepay (https://pesepay.com) 20 | /// 21 | /// It can be instantiated in this way: 22 | /// 23 | /// ```dart 24 | /// final pesepay = Pesepay( 25 | /// integrationKey: '', 26 | /// encryptionKey: '', 27 | /// resultUrl: '', 28 | /// returnUrl: '' 29 | /// ) 30 | /// ``` 31 | Pesepay({ 32 | required this.integrationKey, 33 | required this.encryptionKey, 34 | this.resultUrl, 35 | this.returnUrl, 36 | }) : _dio = Dio() 37 | ..interceptors.add( 38 | LogInterceptor( 39 | responseBody: true, 40 | requestBody: true, 41 | ), 42 | ); 43 | 44 | /// This can be retrieved from the Pesepay Dashboard 45 | /// http://dashboard.pesepay.com/ 46 | final String integrationKey; 47 | 48 | /// This can be retrieved from the Pesepay Dashboard 49 | /// http://dashboard.pesepay.com/ 50 | final String encryptionKey; 51 | 52 | /// Result URL - HTTP callback endpoint on your server for receiving event 53 | /// notifications 54 | final String? resultUrl; 55 | 56 | /// Return URL redirects users back to the originating page during a checkout 57 | /// flow 58 | final String? returnUrl; 59 | 60 | /// [TransactionResponse] stream manager 61 | TransactionResponseStreamManager? _transactionResponseStreamManager; 62 | 63 | final Dio _dio; 64 | 65 | /// Initiate web based payment 66 | Future initiateWebTransaction( 67 | Transaction transaction, 68 | ) async { 69 | if (resultUrl == null) { 70 | throw InvalidRequestException('Result URL has not been specified'); 71 | } 72 | 73 | if (returnUrl == null) { 74 | throw InvalidRequestException('Return URL has not been specified'); 75 | } 76 | 77 | return _initWebTransaction(transaction); 78 | } 79 | 80 | /// Returns [TransactionResponse] 81 | Future _initWebTransaction( 82 | Transaction transaction, 83 | ) async { 84 | final Transaction t = transaction.copyWith( 85 | resultUrl: '$resultUrl', 86 | returnUrl: '$returnUrl', 87 | ); 88 | 89 | final Map paymentData = t.toJson(); 90 | 91 | final String data = _encrypt(encryptionKey, json.encode(paymentData)); 92 | 93 | try { 94 | final Response> response = await _dio.post( 95 | ApiConfig.initiatePaymentUrl, 96 | data: {'payload': data}, 97 | options: Options( 98 | headers: { 99 | 'Content-Type': 'application/json', 100 | 'key': integrationKey, 101 | }, 102 | ), 103 | ); 104 | 105 | final String payload = response.data!['payload'] as String; 106 | // ignore: no_leading_underscores_for_local_identifiers 107 | final String _payload = _decrypt(encryptionKey, payload); 108 | 109 | return TransactionResponse.fromJson( 110 | json.decode(_payload) as Map, 111 | ); 112 | } on DioError catch (e, s) { 113 | throw dioErrorToPesepayException(e, s); 114 | } catch (e, s) { 115 | throw PesepayException(e.toString(), stackTrace: s); 116 | } 117 | } 118 | 119 | /// Initiate mobile based payment 120 | Future initiateSeamlessTransaction( 121 | SeamlessTransaction transaction, 122 | ) async { 123 | if (returnUrl == null) { 124 | throw InvalidRequestException('Return URL has not been specified'); 125 | } 126 | 127 | return _initSeamlessTransaction(transaction); 128 | } 129 | 130 | /// Returns [TransactionResponse] 131 | Future _initSeamlessTransaction( 132 | SeamlessTransaction transaction, 133 | ) async { 134 | final SeamlessTransaction t = transaction.copyWith( 135 | resultUrl: resultUrl ?? '', 136 | returnUrl: returnUrl ?? '', 137 | ); 138 | 139 | final Map paymentData = t.toJson(); 140 | 141 | final String data = _encrypt(encryptionKey, json.encode(paymentData)); 142 | 143 | try { 144 | final Response> response = await _dio.post( 145 | ApiConfig.seamlessPaymentUrl, 146 | data: {'payload': data}, 147 | options: Options( 148 | headers: { 149 | 'Content-Type': 'application/json', 150 | 'key': integrationKey, 151 | }, 152 | ), 153 | ); 154 | 155 | final String payload = response.data!['payload'] as String; 156 | // ignore: no_leading_underscores_for_local_identifiers 157 | final String _payload = _decrypt(encryptionKey, payload); 158 | 159 | return TransactionResponse.fromJson( 160 | json.decode(_payload) as Map, 161 | ); 162 | } on DioError catch (e, s) { 163 | throw dioErrorToPesepayException(e, s); 164 | } catch (e, s) { 165 | throw PesepayException(e.toString(), stackTrace: s); 166 | } 167 | } 168 | 169 | SeamlessTransaction createSeamlessTransaction({ 170 | required String customerName, 171 | required String customerEmail, 172 | required String customerPhone, 173 | required double amount, 174 | required String currencyCode, 175 | required String transactionDescription, 176 | required String transactionReference, 177 | required String paymentMethodCode, 178 | }) { 179 | if (!LocalRegex.isEmail(customerEmail)) { 180 | throw const PesepayException('Customer email is invalid'); 181 | } 182 | 183 | if (!LocalRegex.isZimMobile(customerPhone)) { 184 | throw const PesepayException( 185 | 'Customer phone is not a valid Zim mobile number', 186 | ); 187 | } 188 | 189 | // ignore: no_leading_underscores_for_local_identifiers 190 | final Amount _amount = Amount( 191 | amount: amount, 192 | currency: currencyCode, 193 | ); 194 | 195 | final Customer customer = Customer( 196 | name: customerName, 197 | email: customerEmail, 198 | phoneNumber: customerPhone, 199 | ); 200 | 201 | return SeamlessTransaction( 202 | amount: _amount, 203 | description: transactionDescription, 204 | reference: transactionReference, 205 | paymentMethodCode: paymentMethodCode, 206 | customer: customer, 207 | ); 208 | } 209 | 210 | Transaction createTransaction({ 211 | required double amount, 212 | required String currencyCode, 213 | required String transactionDescription, 214 | required String transactionReference, 215 | }) { 216 | // ignore: no_leading_underscores_for_local_identifiers 217 | final Amount _amount = Amount( 218 | amount: amount, 219 | currency: currencyCode, 220 | ); 221 | 222 | return Transaction( 223 | amount: _amount, 224 | description: transactionDescription, 225 | reference: transactionReference, 226 | ); 227 | } 228 | 229 | Future checkTransactionStatus(String pollUrl) async { 230 | try { 231 | final Response> response = await _dio.get( 232 | pollUrl, 233 | options: Options( 234 | headers: { 235 | 'Content-Type': 'application/json', 236 | 'key': integrationKey, 237 | }, 238 | ), 239 | ); 240 | 241 | final String payload = response.data!['payload'] as String; 242 | // ignore: no_leading_underscores_for_local_identifiers 243 | final String _payload = _decrypt(encryptionKey, payload); 244 | 245 | return TransactionResponse.fromJson( 246 | json.decode(_payload) as Map, 247 | ); 248 | } on DioError catch (e, s) { 249 | throw dioErrorToPesepayException(e, s); 250 | } catch (e, s) { 251 | throw PesepayException(e.toString(), stackTrace: s); 252 | } 253 | } 254 | 255 | /// Get the list of active currencies 256 | /// Returns a list of [Currency] 257 | static Future> getActiveCurrencies() async { 258 | try { 259 | log('Fetching active currencies ...'); 260 | final Dio dio = Dio()..options.baseUrl = ApiConfig.baseUrl; 261 | final Response> response = 262 | await dio.get('/v1/currencies/active'); 263 | final List currencies = (response.data!) 264 | .map( 265 | (json) => Currency.fromJson(json as Map), 266 | ) 267 | .toList(); 268 | 269 | return currencies; 270 | } on DioError catch (e, s) { 271 | throw dioErrorToPesepayException(e, s); 272 | } catch (e, s) { 273 | throw PesepayException('Pesepay runtime exception', stackTrace: s); 274 | } 275 | } 276 | 277 | /// Get the list of payment methods by currency 278 | /// Returns a list of [Currency] 279 | static Future> getPaymentMethodsByCurrency( 280 | Currency currency, 281 | ) async { 282 | try { 283 | log('Fetching active currencies ...'); 284 | final Dio dio = Dio()..options.baseUrl = ApiConfig.baseUrl; 285 | final Response> response = await dio.get( 286 | '/v1/payment-methods/for-currency', 287 | queryParameters: { 288 | 'currencyCode': currency.code, 289 | }, 290 | ); 291 | final List methods = (response.data!) 292 | .map( 293 | (json) => PaymentMethod.fromJson(json as Map), 294 | ) 295 | .toList(); 296 | 297 | return methods; 298 | } on DioError catch (e, s) { 299 | throw dioErrorToPesepayException(e, s); 300 | } catch (e, s) { 301 | throw PesepayException('Pesepay runtime exception', stackTrace: s); 302 | } 303 | } 304 | 305 | /// Stream Transaction Response, 306 | /// streamInterval shows the number of seconds to wait for next polling in the 307 | /// stream 308 | /// returns a [Stream] of [TransactionResponse] 309 | Stream streamTransactionResponse( 310 | String pollUrl, { 311 | int streamInterval = 20, 312 | }) { 313 | _transactionResponseStreamManager = 314 | TransactionResponseStreamManager.fromPesePay( 315 | this, 316 | streamInterval: streamInterval, 317 | pollUrl: pollUrl, 318 | ); 319 | 320 | return _transactionResponseStreamManager!.stream; 321 | } 322 | 323 | /// close [_transactionResponseStreamManager] stream 324 | void closeStream() { 325 | if (_transactionResponseStreamManager != null) { 326 | _transactionResponseStreamManager!.dispose(); 327 | } 328 | } 329 | 330 | /// Encrypt the payload 331 | String _encrypt(String encryptionKey, String payload) { 332 | final Key key = Key.fromUtf8(encryptionKey); 333 | final IV iv = IV.fromUtf8(encryptionKey.substring(0, 16)); 334 | final Encrypter encrypter = Encrypter(AES(key, mode: AESMode.cbc)); 335 | return encrypter.encrypt(payload, iv: iv).base64; 336 | } 337 | 338 | /// Decrypt the payload 339 | String _decrypt(String encryptionKey, String payload) { 340 | final Key key = Key.fromUtf8(encryptionKey); 341 | final IV iv = IV.fromUtf8(encryptionKey.substring(0, 16)); 342 | final Encrypter encrypter = Encrypter(AES(key, mode: AESMode.cbc)); 343 | return encrypter.decrypt(Encrypted.fromBase64(payload), iv: iv); 344 | } 345 | } 346 | -------------------------------------------------------------------------------- /lib/src/models/currency.freezed.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // coverage:ignore-file 3 | // ignore_for_file: type=lint 4 | // 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 5 | 6 | part of 'currency.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | // dart format off 13 | T _$identity(T value) => value; 14 | 15 | /// @nodoc 16 | mixin _$Currency { 17 | 18 | /// The name of the currency. 19 | String get name;/// Description of the currency 20 | String get description;/// The unique code assigned to each currency. 21 | String get code;/// Flag to indicate the default currency of the system 22 | bool get defaultCurrency;/// Rate of the currency to the currency set as default. 23 | double get rateToDefault;/// Flag to indicate currency status 24 | bool get active; 25 | /// Create a copy of Currency 26 | /// with the given fields replaced by the non-null parameter values. 27 | @JsonKey(includeFromJson: false, includeToJson: false) 28 | @pragma('vm:prefer-inline') 29 | $CurrencyCopyWith get copyWith => _$CurrencyCopyWithImpl(this as Currency, _$identity); 30 | 31 | /// Serializes this Currency to a JSON map. 32 | Map toJson(); 33 | 34 | 35 | @override 36 | bool operator ==(Object other) { 37 | return identical(this, other) || (other.runtimeType == runtimeType&&other is Currency&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.code, code) || other.code == code)&&(identical(other.defaultCurrency, defaultCurrency) || other.defaultCurrency == defaultCurrency)&&(identical(other.rateToDefault, rateToDefault) || other.rateToDefault == rateToDefault)&&(identical(other.active, active) || other.active == active)); 38 | } 39 | 40 | @JsonKey(includeFromJson: false, includeToJson: false) 41 | @override 42 | int get hashCode => Object.hash(runtimeType,name,description,code,defaultCurrency,rateToDefault,active); 43 | 44 | 45 | 46 | } 47 | 48 | /// @nodoc 49 | abstract mixin class $CurrencyCopyWith<$Res> { 50 | factory $CurrencyCopyWith(Currency value, $Res Function(Currency) _then) = _$CurrencyCopyWithImpl; 51 | @useResult 52 | $Res call({ 53 | String name, String description, String code, bool defaultCurrency, double rateToDefault, bool active 54 | }); 55 | 56 | 57 | 58 | 59 | } 60 | /// @nodoc 61 | class _$CurrencyCopyWithImpl<$Res> 62 | implements $CurrencyCopyWith<$Res> { 63 | _$CurrencyCopyWithImpl(this._self, this._then); 64 | 65 | final Currency _self; 66 | final $Res Function(Currency) _then; 67 | 68 | /// Create a copy of Currency 69 | /// with the given fields replaced by the non-null parameter values. 70 | @pragma('vm:prefer-inline') @override $Res call({Object? name = null,Object? description = null,Object? code = null,Object? defaultCurrency = null,Object? rateToDefault = null,Object? active = null,}) { 71 | return _then(_self.copyWith( 72 | name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable 73 | as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable 74 | as String,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable 75 | as String,defaultCurrency: null == defaultCurrency ? _self.defaultCurrency : defaultCurrency // ignore: cast_nullable_to_non_nullable 76 | as bool,rateToDefault: null == rateToDefault ? _self.rateToDefault : rateToDefault // ignore: cast_nullable_to_non_nullable 77 | as double,active: null == active ? _self.active : active // ignore: cast_nullable_to_non_nullable 78 | as bool, 79 | )); 80 | } 81 | 82 | } 83 | 84 | 85 | /// Adds pattern-matching-related methods to [Currency]. 86 | extension CurrencyPatterns on Currency { 87 | /// A variant of `map` that fallback to returning `orElse`. 88 | /// 89 | /// It is equivalent to doing: 90 | /// ```dart 91 | /// switch (sealedClass) { 92 | /// case final Subclass value: 93 | /// return ...; 94 | /// case _: 95 | /// return orElse(); 96 | /// } 97 | /// ``` 98 | 99 | @optionalTypeArgs TResult maybeMap(TResult Function( _Currency value)? $default,{required TResult orElse(),}){ 100 | final _that = this; 101 | switch (_that) { 102 | case _Currency() when $default != null: 103 | return $default(_that);case _: 104 | return orElse(); 105 | 106 | } 107 | } 108 | /// A `switch`-like method, using callbacks. 109 | /// 110 | /// Callbacks receives the raw object, upcasted. 111 | /// It is equivalent to doing: 112 | /// ```dart 113 | /// switch (sealedClass) { 114 | /// case final Subclass value: 115 | /// return ...; 116 | /// case final Subclass2 value: 117 | /// return ...; 118 | /// } 119 | /// ``` 120 | 121 | @optionalTypeArgs TResult map(TResult Function( _Currency value) $default,){ 122 | final _that = this; 123 | switch (_that) { 124 | case _Currency(): 125 | return $default(_that);case _: 126 | throw StateError('Unexpected subclass'); 127 | 128 | } 129 | } 130 | /// A variant of `map` that fallback to returning `null`. 131 | /// 132 | /// It is equivalent to doing: 133 | /// ```dart 134 | /// switch (sealedClass) { 135 | /// case final Subclass value: 136 | /// return ...; 137 | /// case _: 138 | /// return null; 139 | /// } 140 | /// ``` 141 | 142 | @optionalTypeArgs TResult? mapOrNull(TResult? Function( _Currency value)? $default,){ 143 | final _that = this; 144 | switch (_that) { 145 | case _Currency() when $default != null: 146 | return $default(_that);case _: 147 | return null; 148 | 149 | } 150 | } 151 | /// A variant of `when` that fallback to an `orElse` callback. 152 | /// 153 | /// It is equivalent to doing: 154 | /// ```dart 155 | /// switch (sealedClass) { 156 | /// case Subclass(:final field): 157 | /// return ...; 158 | /// case _: 159 | /// return orElse(); 160 | /// } 161 | /// ``` 162 | 163 | @optionalTypeArgs TResult maybeWhen(TResult Function( String name, String description, String code, bool defaultCurrency, double rateToDefault, bool active)? $default,{required TResult orElse(),}) {final _that = this; 164 | switch (_that) { 165 | case _Currency() when $default != null: 166 | return $default(_that.name,_that.description,_that.code,_that.defaultCurrency,_that.rateToDefault,_that.active);case _: 167 | return orElse(); 168 | 169 | } 170 | } 171 | /// A `switch`-like method, using callbacks. 172 | /// 173 | /// As opposed to `map`, this offers destructuring. 174 | /// It is equivalent to doing: 175 | /// ```dart 176 | /// switch (sealedClass) { 177 | /// case Subclass(:final field): 178 | /// return ...; 179 | /// case Subclass2(:final field2): 180 | /// return ...; 181 | /// } 182 | /// ``` 183 | 184 | @optionalTypeArgs TResult when(TResult Function( String name, String description, String code, bool defaultCurrency, double rateToDefault, bool active) $default,) {final _that = this; 185 | switch (_that) { 186 | case _Currency(): 187 | return $default(_that.name,_that.description,_that.code,_that.defaultCurrency,_that.rateToDefault,_that.active);case _: 188 | throw StateError('Unexpected subclass'); 189 | 190 | } 191 | } 192 | /// A variant of `when` that fallback to returning `null` 193 | /// 194 | /// It is equivalent to doing: 195 | /// ```dart 196 | /// switch (sealedClass) { 197 | /// case Subclass(:final field): 198 | /// return ...; 199 | /// case _: 200 | /// return null; 201 | /// } 202 | /// ``` 203 | 204 | @optionalTypeArgs TResult? whenOrNull(TResult? Function( String name, String description, String code, bool defaultCurrency, double rateToDefault, bool active)? $default,) {final _that = this; 205 | switch (_that) { 206 | case _Currency() when $default != null: 207 | return $default(_that.name,_that.description,_that.code,_that.defaultCurrency,_that.rateToDefault,_that.active);case _: 208 | return null; 209 | 210 | } 211 | } 212 | 213 | } 214 | 215 | /// @nodoc 216 | @JsonSerializable() 217 | 218 | class _Currency extends Currency { 219 | const _Currency({required this.name, required this.description, required this.code, required this.defaultCurrency, required this.rateToDefault, required this.active}): super._(); 220 | factory _Currency.fromJson(Map json) => _$CurrencyFromJson(json); 221 | 222 | /// The name of the currency. 223 | @override final String name; 224 | /// Description of the currency 225 | @override final String description; 226 | /// The unique code assigned to each currency. 227 | @override final String code; 228 | /// Flag to indicate the default currency of the system 229 | @override final bool defaultCurrency; 230 | /// Rate of the currency to the currency set as default. 231 | @override final double rateToDefault; 232 | /// Flag to indicate currency status 233 | @override final bool active; 234 | 235 | /// Create a copy of Currency 236 | /// with the given fields replaced by the non-null parameter values. 237 | @override @JsonKey(includeFromJson: false, includeToJson: false) 238 | @pragma('vm:prefer-inline') 239 | _$CurrencyCopyWith<_Currency> get copyWith => __$CurrencyCopyWithImpl<_Currency>(this, _$identity); 240 | 241 | @override 242 | Map toJson() { 243 | return _$CurrencyToJson(this, ); 244 | } 245 | 246 | @override 247 | bool operator ==(Object other) { 248 | return identical(this, other) || (other.runtimeType == runtimeType&&other is _Currency&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.code, code) || other.code == code)&&(identical(other.defaultCurrency, defaultCurrency) || other.defaultCurrency == defaultCurrency)&&(identical(other.rateToDefault, rateToDefault) || other.rateToDefault == rateToDefault)&&(identical(other.active, active) || other.active == active)); 249 | } 250 | 251 | @JsonKey(includeFromJson: false, includeToJson: false) 252 | @override 253 | int get hashCode => Object.hash(runtimeType,name,description,code,defaultCurrency,rateToDefault,active); 254 | 255 | 256 | 257 | } 258 | 259 | /// @nodoc 260 | abstract mixin class _$CurrencyCopyWith<$Res> implements $CurrencyCopyWith<$Res> { 261 | factory _$CurrencyCopyWith(_Currency value, $Res Function(_Currency) _then) = __$CurrencyCopyWithImpl; 262 | @override @useResult 263 | $Res call({ 264 | String name, String description, String code, bool defaultCurrency, double rateToDefault, bool active 265 | }); 266 | 267 | 268 | 269 | 270 | } 271 | /// @nodoc 272 | class __$CurrencyCopyWithImpl<$Res> 273 | implements _$CurrencyCopyWith<$Res> { 274 | __$CurrencyCopyWithImpl(this._self, this._then); 275 | 276 | final _Currency _self; 277 | final $Res Function(_Currency) _then; 278 | 279 | /// Create a copy of Currency 280 | /// with the given fields replaced by the non-null parameter values. 281 | @override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? description = null,Object? code = null,Object? defaultCurrency = null,Object? rateToDefault = null,Object? active = null,}) { 282 | return _then(_Currency( 283 | name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable 284 | as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable 285 | as String,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable 286 | as String,defaultCurrency: null == defaultCurrency ? _self.defaultCurrency : defaultCurrency // ignore: cast_nullable_to_non_nullable 287 | as bool,rateToDefault: null == rateToDefault ? _self.rateToDefault : rateToDefault // ignore: cast_nullable_to_non_nullable 288 | as double,active: null == active ? _self.active : active // ignore: cast_nullable_to_non_nullable 289 | as bool, 290 | )); 291 | } 292 | 293 | 294 | } 295 | 296 | // dart format on 297 | -------------------------------------------------------------------------------- /lib/src/models/transaction_response.freezed.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // coverage:ignore-file 3 | // ignore_for_file: type=lint 4 | // 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 5 | 6 | part of 'transaction_response.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | // dart format off 13 | T _$identity(T value) => value; 14 | 15 | /// @nodoc 16 | mixin _$TransactionResponse { 17 | 18 | /// Reference Number 19 | String get referenceNumber;/// Poll Url 20 | String? get pollUrl;/// Transaction Status 21 | TransactionStatus? get transactionStatus;// TODO(iamngoni): check if this is necessary 'cause it doesn't seem like it 22 | /// Redirect URL 23 | String? get redirectUrl; 24 | /// Create a copy of TransactionResponse 25 | /// with the given fields replaced by the non-null parameter values. 26 | @JsonKey(includeFromJson: false, includeToJson: false) 27 | @pragma('vm:prefer-inline') 28 | $TransactionResponseCopyWith get copyWith => _$TransactionResponseCopyWithImpl(this as TransactionResponse, _$identity); 29 | 30 | /// Serializes this TransactionResponse to a JSON map. 31 | Map toJson(); 32 | 33 | 34 | @override 35 | bool operator ==(Object other) { 36 | return identical(this, other) || (other.runtimeType == runtimeType&&other is TransactionResponse&&(identical(other.referenceNumber, referenceNumber) || other.referenceNumber == referenceNumber)&&(identical(other.pollUrl, pollUrl) || other.pollUrl == pollUrl)&&(identical(other.transactionStatus, transactionStatus) || other.transactionStatus == transactionStatus)&&(identical(other.redirectUrl, redirectUrl) || other.redirectUrl == redirectUrl)); 37 | } 38 | 39 | @JsonKey(includeFromJson: false, includeToJson: false) 40 | @override 41 | int get hashCode => Object.hash(runtimeType,referenceNumber,pollUrl,transactionStatus,redirectUrl); 42 | 43 | @override 44 | String toString() { 45 | return 'TransactionResponse(referenceNumber: $referenceNumber, pollUrl: $pollUrl, transactionStatus: $transactionStatus, redirectUrl: $redirectUrl)'; 46 | } 47 | 48 | 49 | } 50 | 51 | /// @nodoc 52 | abstract mixin class $TransactionResponseCopyWith<$Res> { 53 | factory $TransactionResponseCopyWith(TransactionResponse value, $Res Function(TransactionResponse) _then) = _$TransactionResponseCopyWithImpl; 54 | @useResult 55 | $Res call({ 56 | String referenceNumber, String? pollUrl, TransactionStatus? transactionStatus, String? redirectUrl 57 | }); 58 | 59 | 60 | 61 | 62 | } 63 | /// @nodoc 64 | class _$TransactionResponseCopyWithImpl<$Res> 65 | implements $TransactionResponseCopyWith<$Res> { 66 | _$TransactionResponseCopyWithImpl(this._self, this._then); 67 | 68 | final TransactionResponse _self; 69 | final $Res Function(TransactionResponse) _then; 70 | 71 | /// Create a copy of TransactionResponse 72 | /// with the given fields replaced by the non-null parameter values. 73 | @pragma('vm:prefer-inline') @override $Res call({Object? referenceNumber = null,Object? pollUrl = freezed,Object? transactionStatus = freezed,Object? redirectUrl = freezed,}) { 74 | return _then(_self.copyWith( 75 | referenceNumber: null == referenceNumber ? _self.referenceNumber : referenceNumber // ignore: cast_nullable_to_non_nullable 76 | as String,pollUrl: freezed == pollUrl ? _self.pollUrl : pollUrl // ignore: cast_nullable_to_non_nullable 77 | as String?,transactionStatus: freezed == transactionStatus ? _self.transactionStatus : transactionStatus // ignore: cast_nullable_to_non_nullable 78 | as TransactionStatus?,redirectUrl: freezed == redirectUrl ? _self.redirectUrl : redirectUrl // ignore: cast_nullable_to_non_nullable 79 | as String?, 80 | )); 81 | } 82 | 83 | } 84 | 85 | 86 | /// Adds pattern-matching-related methods to [TransactionResponse]. 87 | extension TransactionResponsePatterns on TransactionResponse { 88 | /// A variant of `map` that fallback to returning `orElse`. 89 | /// 90 | /// It is equivalent to doing: 91 | /// ```dart 92 | /// switch (sealedClass) { 93 | /// case final Subclass value: 94 | /// return ...; 95 | /// case _: 96 | /// return orElse(); 97 | /// } 98 | /// ``` 99 | 100 | @optionalTypeArgs TResult maybeMap(TResult Function( _TransactionResponse value)? $default,{required TResult orElse(),}){ 101 | final _that = this; 102 | switch (_that) { 103 | case _TransactionResponse() when $default != null: 104 | return $default(_that);case _: 105 | return orElse(); 106 | 107 | } 108 | } 109 | /// A `switch`-like method, using callbacks. 110 | /// 111 | /// Callbacks receives the raw object, upcasted. 112 | /// It is equivalent to doing: 113 | /// ```dart 114 | /// switch (sealedClass) { 115 | /// case final Subclass value: 116 | /// return ...; 117 | /// case final Subclass2 value: 118 | /// return ...; 119 | /// } 120 | /// ``` 121 | 122 | @optionalTypeArgs TResult map(TResult Function( _TransactionResponse value) $default,){ 123 | final _that = this; 124 | switch (_that) { 125 | case _TransactionResponse(): 126 | return $default(_that);case _: 127 | throw StateError('Unexpected subclass'); 128 | 129 | } 130 | } 131 | /// A variant of `map` that fallback to returning `null`. 132 | /// 133 | /// It is equivalent to doing: 134 | /// ```dart 135 | /// switch (sealedClass) { 136 | /// case final Subclass value: 137 | /// return ...; 138 | /// case _: 139 | /// return null; 140 | /// } 141 | /// ``` 142 | 143 | @optionalTypeArgs TResult? mapOrNull(TResult? Function( _TransactionResponse value)? $default,){ 144 | final _that = this; 145 | switch (_that) { 146 | case _TransactionResponse() when $default != null: 147 | return $default(_that);case _: 148 | return null; 149 | 150 | } 151 | } 152 | /// A variant of `when` that fallback to an `orElse` callback. 153 | /// 154 | /// It is equivalent to doing: 155 | /// ```dart 156 | /// switch (sealedClass) { 157 | /// case Subclass(:final field): 158 | /// return ...; 159 | /// case _: 160 | /// return orElse(); 161 | /// } 162 | /// ``` 163 | 164 | @optionalTypeArgs TResult maybeWhen(TResult Function( String referenceNumber, String? pollUrl, TransactionStatus? transactionStatus, String? redirectUrl)? $default,{required TResult orElse(),}) {final _that = this; 165 | switch (_that) { 166 | case _TransactionResponse() when $default != null: 167 | return $default(_that.referenceNumber,_that.pollUrl,_that.transactionStatus,_that.redirectUrl);case _: 168 | return orElse(); 169 | 170 | } 171 | } 172 | /// A `switch`-like method, using callbacks. 173 | /// 174 | /// As opposed to `map`, this offers destructuring. 175 | /// It is equivalent to doing: 176 | /// ```dart 177 | /// switch (sealedClass) { 178 | /// case Subclass(:final field): 179 | /// return ...; 180 | /// case Subclass2(:final field2): 181 | /// return ...; 182 | /// } 183 | /// ``` 184 | 185 | @optionalTypeArgs TResult when(TResult Function( String referenceNumber, String? pollUrl, TransactionStatus? transactionStatus, String? redirectUrl) $default,) {final _that = this; 186 | switch (_that) { 187 | case _TransactionResponse(): 188 | return $default(_that.referenceNumber,_that.pollUrl,_that.transactionStatus,_that.redirectUrl);case _: 189 | throw StateError('Unexpected subclass'); 190 | 191 | } 192 | } 193 | /// A variant of `when` that fallback to returning `null` 194 | /// 195 | /// It is equivalent to doing: 196 | /// ```dart 197 | /// switch (sealedClass) { 198 | /// case Subclass(:final field): 199 | /// return ...; 200 | /// case _: 201 | /// return null; 202 | /// } 203 | /// ``` 204 | 205 | @optionalTypeArgs TResult? whenOrNull(TResult? Function( String referenceNumber, String? pollUrl, TransactionStatus? transactionStatus, String? redirectUrl)? $default,) {final _that = this; 206 | switch (_that) { 207 | case _TransactionResponse() when $default != null: 208 | return $default(_that.referenceNumber,_that.pollUrl,_that.transactionStatus,_that.redirectUrl);case _: 209 | return null; 210 | 211 | } 212 | } 213 | 214 | } 215 | 216 | /// @nodoc 217 | @JsonSerializable() 218 | 219 | class _TransactionResponse extends TransactionResponse { 220 | const _TransactionResponse({required this.referenceNumber, required this.pollUrl, this.transactionStatus, this.redirectUrl}): super._(); 221 | factory _TransactionResponse.fromJson(Map json) => _$TransactionResponseFromJson(json); 222 | 223 | /// Reference Number 224 | @override final String referenceNumber; 225 | /// Poll Url 226 | @override final String? pollUrl; 227 | /// Transaction Status 228 | @override final TransactionStatus? transactionStatus; 229 | // TODO(iamngoni): check if this is necessary 'cause it doesn't seem like it 230 | /// Redirect URL 231 | @override final String? redirectUrl; 232 | 233 | /// Create a copy of TransactionResponse 234 | /// with the given fields replaced by the non-null parameter values. 235 | @override @JsonKey(includeFromJson: false, includeToJson: false) 236 | @pragma('vm:prefer-inline') 237 | _$TransactionResponseCopyWith<_TransactionResponse> get copyWith => __$TransactionResponseCopyWithImpl<_TransactionResponse>(this, _$identity); 238 | 239 | @override 240 | Map toJson() { 241 | return _$TransactionResponseToJson(this, ); 242 | } 243 | 244 | @override 245 | bool operator ==(Object other) { 246 | return identical(this, other) || (other.runtimeType == runtimeType&&other is _TransactionResponse&&(identical(other.referenceNumber, referenceNumber) || other.referenceNumber == referenceNumber)&&(identical(other.pollUrl, pollUrl) || other.pollUrl == pollUrl)&&(identical(other.transactionStatus, transactionStatus) || other.transactionStatus == transactionStatus)&&(identical(other.redirectUrl, redirectUrl) || other.redirectUrl == redirectUrl)); 247 | } 248 | 249 | @JsonKey(includeFromJson: false, includeToJson: false) 250 | @override 251 | int get hashCode => Object.hash(runtimeType,referenceNumber,pollUrl,transactionStatus,redirectUrl); 252 | 253 | @override 254 | String toString() { 255 | return 'TransactionResponse(referenceNumber: $referenceNumber, pollUrl: $pollUrl, transactionStatus: $transactionStatus, redirectUrl: $redirectUrl)'; 256 | } 257 | 258 | 259 | } 260 | 261 | /// @nodoc 262 | abstract mixin class _$TransactionResponseCopyWith<$Res> implements $TransactionResponseCopyWith<$Res> { 263 | factory _$TransactionResponseCopyWith(_TransactionResponse value, $Res Function(_TransactionResponse) _then) = __$TransactionResponseCopyWithImpl; 264 | @override @useResult 265 | $Res call({ 266 | String referenceNumber, String? pollUrl, TransactionStatus? transactionStatus, String? redirectUrl 267 | }); 268 | 269 | 270 | 271 | 272 | } 273 | /// @nodoc 274 | class __$TransactionResponseCopyWithImpl<$Res> 275 | implements _$TransactionResponseCopyWith<$Res> { 276 | __$TransactionResponseCopyWithImpl(this._self, this._then); 277 | 278 | final _TransactionResponse _self; 279 | final $Res Function(_TransactionResponse) _then; 280 | 281 | /// Create a copy of TransactionResponse 282 | /// with the given fields replaced by the non-null parameter values. 283 | @override @pragma('vm:prefer-inline') $Res call({Object? referenceNumber = null,Object? pollUrl = freezed,Object? transactionStatus = freezed,Object? redirectUrl = freezed,}) { 284 | return _then(_TransactionResponse( 285 | referenceNumber: null == referenceNumber ? _self.referenceNumber : referenceNumber // ignore: cast_nullable_to_non_nullable 286 | as String,pollUrl: freezed == pollUrl ? _self.pollUrl : pollUrl // ignore: cast_nullable_to_non_nullable 287 | as String?,transactionStatus: freezed == transactionStatus ? _self.transactionStatus : transactionStatus // ignore: cast_nullable_to_non_nullable 288 | as TransactionStatus?,redirectUrl: freezed == redirectUrl ? _self.redirectUrl : redirectUrl // ignore: cast_nullable_to_non_nullable 289 | as String?, 290 | )); 291 | } 292 | 293 | 294 | } 295 | 296 | // dart format on 297 | -------------------------------------------------------------------------------- /lib/src/models/transaction.freezed.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // coverage:ignore-file 3 | // ignore_for_file: type=lint 4 | // 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 5 | 6 | part of 'transaction.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | // dart format off 13 | T _$identity(T value) => value; 14 | 15 | /// @nodoc 16 | mixin _$Transaction { 17 | 18 | /// Amount in value and currency 19 | // ignore: invalid_annotation_target 20 | @JsonKey(name: 'amountDetails') Amount get amount;/// Reason for payment 21 | // ignore: invalid_annotation_target 22 | @JsonKey(name: 'reasonForPayment') String get description;/// Reference from the merchant system 23 | // ignore: invalid_annotation_target 24 | @JsonKey(name: 'merchantReference') String? get reference;/// Type of transaction 25 | String get transactionType;/// Result URL - HTTP callback endpoint on your server for receiving event 26 | /// notifications 27 | String get resultUrl;/// Return URL redirects users back to the originating page during a 28 | /// checkout flow 29 | String get returnUrl; 30 | /// Create a copy of Transaction 31 | /// with the given fields replaced by the non-null parameter values. 32 | @JsonKey(includeFromJson: false, includeToJson: false) 33 | @pragma('vm:prefer-inline') 34 | $TransactionCopyWith get copyWith => _$TransactionCopyWithImpl(this as Transaction, _$identity); 35 | 36 | /// Serializes this Transaction to a JSON map. 37 | Map toJson(); 38 | 39 | 40 | @override 41 | bool operator ==(Object other) { 42 | return identical(this, other) || (other.runtimeType == runtimeType&&other is Transaction&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.description, description) || other.description == description)&&(identical(other.reference, reference) || other.reference == reference)&&(identical(other.transactionType, transactionType) || other.transactionType == transactionType)&&(identical(other.resultUrl, resultUrl) || other.resultUrl == resultUrl)&&(identical(other.returnUrl, returnUrl) || other.returnUrl == returnUrl)); 43 | } 44 | 45 | @JsonKey(includeFromJson: false, includeToJson: false) 46 | @override 47 | int get hashCode => Object.hash(runtimeType,amount,description,reference,transactionType,resultUrl,returnUrl); 48 | 49 | @override 50 | String toString() { 51 | return 'Transaction(amount: $amount, description: $description, reference: $reference, transactionType: $transactionType, resultUrl: $resultUrl, returnUrl: $returnUrl)'; 52 | } 53 | 54 | 55 | } 56 | 57 | /// @nodoc 58 | abstract mixin class $TransactionCopyWith<$Res> { 59 | factory $TransactionCopyWith(Transaction value, $Res Function(Transaction) _then) = _$TransactionCopyWithImpl; 60 | @useResult 61 | $Res call({ 62 | @JsonKey(name: 'amountDetails') Amount amount,@JsonKey(name: 'reasonForPayment') String description,@JsonKey(name: 'merchantReference') String? reference, String transactionType, String resultUrl, String returnUrl 63 | }); 64 | 65 | 66 | $AmountCopyWith<$Res> get amount; 67 | 68 | } 69 | /// @nodoc 70 | class _$TransactionCopyWithImpl<$Res> 71 | implements $TransactionCopyWith<$Res> { 72 | _$TransactionCopyWithImpl(this._self, this._then); 73 | 74 | final Transaction _self; 75 | final $Res Function(Transaction) _then; 76 | 77 | /// Create a copy of Transaction 78 | /// with the given fields replaced by the non-null parameter values. 79 | @pragma('vm:prefer-inline') @override $Res call({Object? amount = null,Object? description = null,Object? reference = freezed,Object? transactionType = null,Object? resultUrl = null,Object? returnUrl = null,}) { 80 | return _then(_self.copyWith( 81 | amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable 82 | as Amount,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable 83 | as String,reference: freezed == reference ? _self.reference : reference // ignore: cast_nullable_to_non_nullable 84 | as String?,transactionType: null == transactionType ? _self.transactionType : transactionType // ignore: cast_nullable_to_non_nullable 85 | as String,resultUrl: null == resultUrl ? _self.resultUrl : resultUrl // ignore: cast_nullable_to_non_nullable 86 | as String,returnUrl: null == returnUrl ? _self.returnUrl : returnUrl // ignore: cast_nullable_to_non_nullable 87 | as String, 88 | )); 89 | } 90 | /// Create a copy of Transaction 91 | /// with the given fields replaced by the non-null parameter values. 92 | @override 93 | @pragma('vm:prefer-inline') 94 | $AmountCopyWith<$Res> get amount { 95 | 96 | return $AmountCopyWith<$Res>(_self.amount, (value) { 97 | return _then(_self.copyWith(amount: value)); 98 | }); 99 | } 100 | } 101 | 102 | 103 | /// Adds pattern-matching-related methods to [Transaction]. 104 | extension TransactionPatterns on Transaction { 105 | /// A variant of `map` that fallback to returning `orElse`. 106 | /// 107 | /// It is equivalent to doing: 108 | /// ```dart 109 | /// switch (sealedClass) { 110 | /// case final Subclass value: 111 | /// return ...; 112 | /// case _: 113 | /// return orElse(); 114 | /// } 115 | /// ``` 116 | 117 | @optionalTypeArgs TResult maybeMap(TResult Function( _Transaction value)? $default,{required TResult orElse(),}){ 118 | final _that = this; 119 | switch (_that) { 120 | case _Transaction() when $default != null: 121 | return $default(_that);case _: 122 | return orElse(); 123 | 124 | } 125 | } 126 | /// A `switch`-like method, using callbacks. 127 | /// 128 | /// Callbacks receives the raw object, upcasted. 129 | /// It is equivalent to doing: 130 | /// ```dart 131 | /// switch (sealedClass) { 132 | /// case final Subclass value: 133 | /// return ...; 134 | /// case final Subclass2 value: 135 | /// return ...; 136 | /// } 137 | /// ``` 138 | 139 | @optionalTypeArgs TResult map(TResult Function( _Transaction value) $default,){ 140 | final _that = this; 141 | switch (_that) { 142 | case _Transaction(): 143 | return $default(_that);case _: 144 | throw StateError('Unexpected subclass'); 145 | 146 | } 147 | } 148 | /// A variant of `map` that fallback to returning `null`. 149 | /// 150 | /// It is equivalent to doing: 151 | /// ```dart 152 | /// switch (sealedClass) { 153 | /// case final Subclass value: 154 | /// return ...; 155 | /// case _: 156 | /// return null; 157 | /// } 158 | /// ``` 159 | 160 | @optionalTypeArgs TResult? mapOrNull(TResult? Function( _Transaction value)? $default,){ 161 | final _that = this; 162 | switch (_that) { 163 | case _Transaction() when $default != null: 164 | return $default(_that);case _: 165 | return null; 166 | 167 | } 168 | } 169 | /// A variant of `when` that fallback to an `orElse` callback. 170 | /// 171 | /// It is equivalent to doing: 172 | /// ```dart 173 | /// switch (sealedClass) { 174 | /// case Subclass(:final field): 175 | /// return ...; 176 | /// case _: 177 | /// return orElse(); 178 | /// } 179 | /// ``` 180 | 181 | @optionalTypeArgs TResult maybeWhen(TResult Function(@JsonKey(name: 'amountDetails') Amount amount, @JsonKey(name: 'reasonForPayment') String description, @JsonKey(name: 'merchantReference') String? reference, String transactionType, String resultUrl, String returnUrl)? $default,{required TResult orElse(),}) {final _that = this; 182 | switch (_that) { 183 | case _Transaction() when $default != null: 184 | return $default(_that.amount,_that.description,_that.reference,_that.transactionType,_that.resultUrl,_that.returnUrl);case _: 185 | return orElse(); 186 | 187 | } 188 | } 189 | /// A `switch`-like method, using callbacks. 190 | /// 191 | /// As opposed to `map`, this offers destructuring. 192 | /// It is equivalent to doing: 193 | /// ```dart 194 | /// switch (sealedClass) { 195 | /// case Subclass(:final field): 196 | /// return ...; 197 | /// case Subclass2(:final field2): 198 | /// return ...; 199 | /// } 200 | /// ``` 201 | 202 | @optionalTypeArgs TResult when(TResult Function(@JsonKey(name: 'amountDetails') Amount amount, @JsonKey(name: 'reasonForPayment') String description, @JsonKey(name: 'merchantReference') String? reference, String transactionType, String resultUrl, String returnUrl) $default,) {final _that = this; 203 | switch (_that) { 204 | case _Transaction(): 205 | return $default(_that.amount,_that.description,_that.reference,_that.transactionType,_that.resultUrl,_that.returnUrl);case _: 206 | throw StateError('Unexpected subclass'); 207 | 208 | } 209 | } 210 | /// A variant of `when` that fallback to returning `null` 211 | /// 212 | /// It is equivalent to doing: 213 | /// ```dart 214 | /// switch (sealedClass) { 215 | /// case Subclass(:final field): 216 | /// return ...; 217 | /// case _: 218 | /// return null; 219 | /// } 220 | /// ``` 221 | 222 | @optionalTypeArgs TResult? whenOrNull(TResult? Function(@JsonKey(name: 'amountDetails') Amount amount, @JsonKey(name: 'reasonForPayment') String description, @JsonKey(name: 'merchantReference') String? reference, String transactionType, String resultUrl, String returnUrl)? $default,) {final _that = this; 223 | switch (_that) { 224 | case _Transaction() when $default != null: 225 | return $default(_that.amount,_that.description,_that.reference,_that.transactionType,_that.resultUrl,_that.returnUrl);case _: 226 | return null; 227 | 228 | } 229 | } 230 | 231 | } 232 | 233 | /// @nodoc 234 | @JsonSerializable() 235 | 236 | class _Transaction extends Transaction { 237 | const _Transaction({@JsonKey(name: 'amountDetails') required this.amount, @JsonKey(name: 'reasonForPayment') required this.description, @JsonKey(name: 'merchantReference') this.reference, this.transactionType = 'BASIC', this.resultUrl = '', this.returnUrl = ''}): super._(); 238 | factory _Transaction.fromJson(Map json) => _$TransactionFromJson(json); 239 | 240 | /// Amount in value and currency 241 | // ignore: invalid_annotation_target 242 | @override@JsonKey(name: 'amountDetails') final Amount amount; 243 | /// Reason for payment 244 | // ignore: invalid_annotation_target 245 | @override@JsonKey(name: 'reasonForPayment') final String description; 246 | /// Reference from the merchant system 247 | // ignore: invalid_annotation_target 248 | @override@JsonKey(name: 'merchantReference') final String? reference; 249 | /// Type of transaction 250 | @override@JsonKey() final String transactionType; 251 | /// Result URL - HTTP callback endpoint on your server for receiving event 252 | /// notifications 253 | @override@JsonKey() final String resultUrl; 254 | /// Return URL redirects users back to the originating page during a 255 | /// checkout flow 256 | @override@JsonKey() final String returnUrl; 257 | 258 | /// Create a copy of Transaction 259 | /// with the given fields replaced by the non-null parameter values. 260 | @override @JsonKey(includeFromJson: false, includeToJson: false) 261 | @pragma('vm:prefer-inline') 262 | _$TransactionCopyWith<_Transaction> get copyWith => __$TransactionCopyWithImpl<_Transaction>(this, _$identity); 263 | 264 | @override 265 | Map toJson() { 266 | return _$TransactionToJson(this, ); 267 | } 268 | 269 | @override 270 | bool operator ==(Object other) { 271 | return identical(this, other) || (other.runtimeType == runtimeType&&other is _Transaction&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.description, description) || other.description == description)&&(identical(other.reference, reference) || other.reference == reference)&&(identical(other.transactionType, transactionType) || other.transactionType == transactionType)&&(identical(other.resultUrl, resultUrl) || other.resultUrl == resultUrl)&&(identical(other.returnUrl, returnUrl) || other.returnUrl == returnUrl)); 272 | } 273 | 274 | @JsonKey(includeFromJson: false, includeToJson: false) 275 | @override 276 | int get hashCode => Object.hash(runtimeType,amount,description,reference,transactionType,resultUrl,returnUrl); 277 | 278 | @override 279 | String toString() { 280 | return 'Transaction(amount: $amount, description: $description, reference: $reference, transactionType: $transactionType, resultUrl: $resultUrl, returnUrl: $returnUrl)'; 281 | } 282 | 283 | 284 | } 285 | 286 | /// @nodoc 287 | abstract mixin class _$TransactionCopyWith<$Res> implements $TransactionCopyWith<$Res> { 288 | factory _$TransactionCopyWith(_Transaction value, $Res Function(_Transaction) _then) = __$TransactionCopyWithImpl; 289 | @override @useResult 290 | $Res call({ 291 | @JsonKey(name: 'amountDetails') Amount amount,@JsonKey(name: 'reasonForPayment') String description,@JsonKey(name: 'merchantReference') String? reference, String transactionType, String resultUrl, String returnUrl 292 | }); 293 | 294 | 295 | @override $AmountCopyWith<$Res> get amount; 296 | 297 | } 298 | /// @nodoc 299 | class __$TransactionCopyWithImpl<$Res> 300 | implements _$TransactionCopyWith<$Res> { 301 | __$TransactionCopyWithImpl(this._self, this._then); 302 | 303 | final _Transaction _self; 304 | final $Res Function(_Transaction) _then; 305 | 306 | /// Create a copy of Transaction 307 | /// with the given fields replaced by the non-null parameter values. 308 | @override @pragma('vm:prefer-inline') $Res call({Object? amount = null,Object? description = null,Object? reference = freezed,Object? transactionType = null,Object? resultUrl = null,Object? returnUrl = null,}) { 309 | return _then(_Transaction( 310 | amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable 311 | as Amount,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable 312 | as String,reference: freezed == reference ? _self.reference : reference // ignore: cast_nullable_to_non_nullable 313 | as String?,transactionType: null == transactionType ? _self.transactionType : transactionType // ignore: cast_nullable_to_non_nullable 314 | as String,resultUrl: null == resultUrl ? _self.resultUrl : resultUrl // ignore: cast_nullable_to_non_nullable 315 | as String,returnUrl: null == returnUrl ? _self.returnUrl : returnUrl // ignore: cast_nullable_to_non_nullable 316 | as String, 317 | )); 318 | } 319 | 320 | /// Create a copy of Transaction 321 | /// with the given fields replaced by the non-null parameter values. 322 | @override 323 | @pragma('vm:prefer-inline') 324 | $AmountCopyWith<$Res> get amount { 325 | 326 | return $AmountCopyWith<$Res>(_self.amount, (value) { 327 | return _then(_self.copyWith(amount: value)); 328 | }); 329 | } 330 | } 331 | 332 | // dart format on 333 | -------------------------------------------------------------------------------- /lib/src/models/seamless_transaction.freezed.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // coverage:ignore-file 3 | // ignore_for_file: type=lint 4 | // 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 5 | 6 | part of 'seamless_transaction.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | // dart format off 13 | T _$identity(T value) => value; 14 | 15 | /// @nodoc 16 | mixin _$SeamlessTransaction { 17 | 18 | /// Amount in value and currency 19 | // ignore: invalid_annotation_target 20 | @JsonKey(name: 'amountDetails') Amount get amount;/// Reason for payment 21 | // ignore: invalid_annotation_target 22 | @JsonKey(name: 'reasonForPayment') String get description;/// Reference from merchant system 23 | // ignore: invalid_annotation_target 24 | @JsonKey(name: 'merchantReference') String get reference;/// Payment method code 25 | String get paymentMethodCode;/// Customer details i.e. name, email and phone number 26 | Customer get customer;/// Return URL redirects users back to the originating page during a 27 | /// checkout flow 28 | String get returnUrl;/// Result URL - HTTP callback endpoint on your server for receiving event 29 | /// notifications 30 | String get resultUrl; 31 | /// Create a copy of SeamlessTransaction 32 | /// with the given fields replaced by the non-null parameter values. 33 | @JsonKey(includeFromJson: false, includeToJson: false) 34 | @pragma('vm:prefer-inline') 35 | $SeamlessTransactionCopyWith get copyWith => _$SeamlessTransactionCopyWithImpl(this as SeamlessTransaction, _$identity); 36 | 37 | /// Serializes this SeamlessTransaction to a JSON map. 38 | Map toJson(); 39 | 40 | 41 | @override 42 | bool operator ==(Object other) { 43 | return identical(this, other) || (other.runtimeType == runtimeType&&other is SeamlessTransaction&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.description, description) || other.description == description)&&(identical(other.reference, reference) || other.reference == reference)&&(identical(other.paymentMethodCode, paymentMethodCode) || other.paymentMethodCode == paymentMethodCode)&&(identical(other.customer, customer) || other.customer == customer)&&(identical(other.returnUrl, returnUrl) || other.returnUrl == returnUrl)&&(identical(other.resultUrl, resultUrl) || other.resultUrl == resultUrl)); 44 | } 45 | 46 | @JsonKey(includeFromJson: false, includeToJson: false) 47 | @override 48 | int get hashCode => Object.hash(runtimeType,amount,description,reference,paymentMethodCode,customer,returnUrl,resultUrl); 49 | 50 | @override 51 | String toString() { 52 | return 'SeamlessTransaction(amount: $amount, description: $description, reference: $reference, paymentMethodCode: $paymentMethodCode, customer: $customer, returnUrl: $returnUrl, resultUrl: $resultUrl)'; 53 | } 54 | 55 | 56 | } 57 | 58 | /// @nodoc 59 | abstract mixin class $SeamlessTransactionCopyWith<$Res> { 60 | factory $SeamlessTransactionCopyWith(SeamlessTransaction value, $Res Function(SeamlessTransaction) _then) = _$SeamlessTransactionCopyWithImpl; 61 | @useResult 62 | $Res call({ 63 | @JsonKey(name: 'amountDetails') Amount amount,@JsonKey(name: 'reasonForPayment') String description,@JsonKey(name: 'merchantReference') String reference, String paymentMethodCode, Customer customer, String returnUrl, String resultUrl 64 | }); 65 | 66 | 67 | $AmountCopyWith<$Res> get amount;$CustomerCopyWith<$Res> get customer; 68 | 69 | } 70 | /// @nodoc 71 | class _$SeamlessTransactionCopyWithImpl<$Res> 72 | implements $SeamlessTransactionCopyWith<$Res> { 73 | _$SeamlessTransactionCopyWithImpl(this._self, this._then); 74 | 75 | final SeamlessTransaction _self; 76 | final $Res Function(SeamlessTransaction) _then; 77 | 78 | /// Create a copy of SeamlessTransaction 79 | /// with the given fields replaced by the non-null parameter values. 80 | @pragma('vm:prefer-inline') @override $Res call({Object? amount = null,Object? description = null,Object? reference = null,Object? paymentMethodCode = null,Object? customer = null,Object? returnUrl = null,Object? resultUrl = null,}) { 81 | return _then(_self.copyWith( 82 | amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable 83 | as Amount,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable 84 | as String,reference: null == reference ? _self.reference : reference // ignore: cast_nullable_to_non_nullable 85 | as String,paymentMethodCode: null == paymentMethodCode ? _self.paymentMethodCode : paymentMethodCode // ignore: cast_nullable_to_non_nullable 86 | as String,customer: null == customer ? _self.customer : customer // ignore: cast_nullable_to_non_nullable 87 | as Customer,returnUrl: null == returnUrl ? _self.returnUrl : returnUrl // ignore: cast_nullable_to_non_nullable 88 | as String,resultUrl: null == resultUrl ? _self.resultUrl : resultUrl // ignore: cast_nullable_to_non_nullable 89 | as String, 90 | )); 91 | } 92 | /// Create a copy of SeamlessTransaction 93 | /// with the given fields replaced by the non-null parameter values. 94 | @override 95 | @pragma('vm:prefer-inline') 96 | $AmountCopyWith<$Res> get amount { 97 | 98 | return $AmountCopyWith<$Res>(_self.amount, (value) { 99 | return _then(_self.copyWith(amount: value)); 100 | }); 101 | }/// Create a copy of SeamlessTransaction 102 | /// with the given fields replaced by the non-null parameter values. 103 | @override 104 | @pragma('vm:prefer-inline') 105 | $CustomerCopyWith<$Res> get customer { 106 | 107 | return $CustomerCopyWith<$Res>(_self.customer, (value) { 108 | return _then(_self.copyWith(customer: value)); 109 | }); 110 | } 111 | } 112 | 113 | 114 | /// Adds pattern-matching-related methods to [SeamlessTransaction]. 115 | extension SeamlessTransactionPatterns on SeamlessTransaction { 116 | /// A variant of `map` that fallback to returning `orElse`. 117 | /// 118 | /// It is equivalent to doing: 119 | /// ```dart 120 | /// switch (sealedClass) { 121 | /// case final Subclass value: 122 | /// return ...; 123 | /// case _: 124 | /// return orElse(); 125 | /// } 126 | /// ``` 127 | 128 | @optionalTypeArgs TResult maybeMap(TResult Function( _SeamlessTransaction value)? $default,{required TResult orElse(),}){ 129 | final _that = this; 130 | switch (_that) { 131 | case _SeamlessTransaction() when $default != null: 132 | return $default(_that);case _: 133 | return orElse(); 134 | 135 | } 136 | } 137 | /// A `switch`-like method, using callbacks. 138 | /// 139 | /// Callbacks receives the raw object, upcasted. 140 | /// It is equivalent to doing: 141 | /// ```dart 142 | /// switch (sealedClass) { 143 | /// case final Subclass value: 144 | /// return ...; 145 | /// case final Subclass2 value: 146 | /// return ...; 147 | /// } 148 | /// ``` 149 | 150 | @optionalTypeArgs TResult map(TResult Function( _SeamlessTransaction value) $default,){ 151 | final _that = this; 152 | switch (_that) { 153 | case _SeamlessTransaction(): 154 | return $default(_that);case _: 155 | throw StateError('Unexpected subclass'); 156 | 157 | } 158 | } 159 | /// A variant of `map` that fallback to returning `null`. 160 | /// 161 | /// It is equivalent to doing: 162 | /// ```dart 163 | /// switch (sealedClass) { 164 | /// case final Subclass value: 165 | /// return ...; 166 | /// case _: 167 | /// return null; 168 | /// } 169 | /// ``` 170 | 171 | @optionalTypeArgs TResult? mapOrNull(TResult? Function( _SeamlessTransaction value)? $default,){ 172 | final _that = this; 173 | switch (_that) { 174 | case _SeamlessTransaction() when $default != null: 175 | return $default(_that);case _: 176 | return null; 177 | 178 | } 179 | } 180 | /// A variant of `when` that fallback to an `orElse` callback. 181 | /// 182 | /// It is equivalent to doing: 183 | /// ```dart 184 | /// switch (sealedClass) { 185 | /// case Subclass(:final field): 186 | /// return ...; 187 | /// case _: 188 | /// return orElse(); 189 | /// } 190 | /// ``` 191 | 192 | @optionalTypeArgs TResult maybeWhen(TResult Function(@JsonKey(name: 'amountDetails') Amount amount, @JsonKey(name: 'reasonForPayment') String description, @JsonKey(name: 'merchantReference') String reference, String paymentMethodCode, Customer customer, String returnUrl, String resultUrl)? $default,{required TResult orElse(),}) {final _that = this; 193 | switch (_that) { 194 | case _SeamlessTransaction() when $default != null: 195 | return $default(_that.amount,_that.description,_that.reference,_that.paymentMethodCode,_that.customer,_that.returnUrl,_that.resultUrl);case _: 196 | return orElse(); 197 | 198 | } 199 | } 200 | /// A `switch`-like method, using callbacks. 201 | /// 202 | /// As opposed to `map`, this offers destructuring. 203 | /// It is equivalent to doing: 204 | /// ```dart 205 | /// switch (sealedClass) { 206 | /// case Subclass(:final field): 207 | /// return ...; 208 | /// case Subclass2(:final field2): 209 | /// return ...; 210 | /// } 211 | /// ``` 212 | 213 | @optionalTypeArgs TResult when(TResult Function(@JsonKey(name: 'amountDetails') Amount amount, @JsonKey(name: 'reasonForPayment') String description, @JsonKey(name: 'merchantReference') String reference, String paymentMethodCode, Customer customer, String returnUrl, String resultUrl) $default,) {final _that = this; 214 | switch (_that) { 215 | case _SeamlessTransaction(): 216 | return $default(_that.amount,_that.description,_that.reference,_that.paymentMethodCode,_that.customer,_that.returnUrl,_that.resultUrl);case _: 217 | throw StateError('Unexpected subclass'); 218 | 219 | } 220 | } 221 | /// A variant of `when` that fallback to returning `null` 222 | /// 223 | /// It is equivalent to doing: 224 | /// ```dart 225 | /// switch (sealedClass) { 226 | /// case Subclass(:final field): 227 | /// return ...; 228 | /// case _: 229 | /// return null; 230 | /// } 231 | /// ``` 232 | 233 | @optionalTypeArgs TResult? whenOrNull(TResult? Function(@JsonKey(name: 'amountDetails') Amount amount, @JsonKey(name: 'reasonForPayment') String description, @JsonKey(name: 'merchantReference') String reference, String paymentMethodCode, Customer customer, String returnUrl, String resultUrl)? $default,) {final _that = this; 234 | switch (_that) { 235 | case _SeamlessTransaction() when $default != null: 236 | return $default(_that.amount,_that.description,_that.reference,_that.paymentMethodCode,_that.customer,_that.returnUrl,_that.resultUrl);case _: 237 | return null; 238 | 239 | } 240 | } 241 | 242 | } 243 | 244 | /// @nodoc 245 | @JsonSerializable() 246 | 247 | class _SeamlessTransaction extends SeamlessTransaction { 248 | const _SeamlessTransaction({@JsonKey(name: 'amountDetails') required this.amount, @JsonKey(name: 'reasonForPayment') required this.description, @JsonKey(name: 'merchantReference') required this.reference, required this.paymentMethodCode, required this.customer, this.returnUrl = '', this.resultUrl = ''}): super._(); 249 | factory _SeamlessTransaction.fromJson(Map json) => _$SeamlessTransactionFromJson(json); 250 | 251 | /// Amount in value and currency 252 | // ignore: invalid_annotation_target 253 | @override@JsonKey(name: 'amountDetails') final Amount amount; 254 | /// Reason for payment 255 | // ignore: invalid_annotation_target 256 | @override@JsonKey(name: 'reasonForPayment') final String description; 257 | /// Reference from merchant system 258 | // ignore: invalid_annotation_target 259 | @override@JsonKey(name: 'merchantReference') final String reference; 260 | /// Payment method code 261 | @override final String paymentMethodCode; 262 | /// Customer details i.e. name, email and phone number 263 | @override final Customer customer; 264 | /// Return URL redirects users back to the originating page during a 265 | /// checkout flow 266 | @override@JsonKey() final String returnUrl; 267 | /// Result URL - HTTP callback endpoint on your server for receiving event 268 | /// notifications 269 | @override@JsonKey() final String resultUrl; 270 | 271 | /// Create a copy of SeamlessTransaction 272 | /// with the given fields replaced by the non-null parameter values. 273 | @override @JsonKey(includeFromJson: false, includeToJson: false) 274 | @pragma('vm:prefer-inline') 275 | _$SeamlessTransactionCopyWith<_SeamlessTransaction> get copyWith => __$SeamlessTransactionCopyWithImpl<_SeamlessTransaction>(this, _$identity); 276 | 277 | @override 278 | Map toJson() { 279 | return _$SeamlessTransactionToJson(this, ); 280 | } 281 | 282 | @override 283 | bool operator ==(Object other) { 284 | return identical(this, other) || (other.runtimeType == runtimeType&&other is _SeamlessTransaction&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.description, description) || other.description == description)&&(identical(other.reference, reference) || other.reference == reference)&&(identical(other.paymentMethodCode, paymentMethodCode) || other.paymentMethodCode == paymentMethodCode)&&(identical(other.customer, customer) || other.customer == customer)&&(identical(other.returnUrl, returnUrl) || other.returnUrl == returnUrl)&&(identical(other.resultUrl, resultUrl) || other.resultUrl == resultUrl)); 285 | } 286 | 287 | @JsonKey(includeFromJson: false, includeToJson: false) 288 | @override 289 | int get hashCode => Object.hash(runtimeType,amount,description,reference,paymentMethodCode,customer,returnUrl,resultUrl); 290 | 291 | @override 292 | String toString() { 293 | return 'SeamlessTransaction(amount: $amount, description: $description, reference: $reference, paymentMethodCode: $paymentMethodCode, customer: $customer, returnUrl: $returnUrl, resultUrl: $resultUrl)'; 294 | } 295 | 296 | 297 | } 298 | 299 | /// @nodoc 300 | abstract mixin class _$SeamlessTransactionCopyWith<$Res> implements $SeamlessTransactionCopyWith<$Res> { 301 | factory _$SeamlessTransactionCopyWith(_SeamlessTransaction value, $Res Function(_SeamlessTransaction) _then) = __$SeamlessTransactionCopyWithImpl; 302 | @override @useResult 303 | $Res call({ 304 | @JsonKey(name: 'amountDetails') Amount amount,@JsonKey(name: 'reasonForPayment') String description,@JsonKey(name: 'merchantReference') String reference, String paymentMethodCode, Customer customer, String returnUrl, String resultUrl 305 | }); 306 | 307 | 308 | @override $AmountCopyWith<$Res> get amount;@override $CustomerCopyWith<$Res> get customer; 309 | 310 | } 311 | /// @nodoc 312 | class __$SeamlessTransactionCopyWithImpl<$Res> 313 | implements _$SeamlessTransactionCopyWith<$Res> { 314 | __$SeamlessTransactionCopyWithImpl(this._self, this._then); 315 | 316 | final _SeamlessTransaction _self; 317 | final $Res Function(_SeamlessTransaction) _then; 318 | 319 | /// Create a copy of SeamlessTransaction 320 | /// with the given fields replaced by the non-null parameter values. 321 | @override @pragma('vm:prefer-inline') $Res call({Object? amount = null,Object? description = null,Object? reference = null,Object? paymentMethodCode = null,Object? customer = null,Object? returnUrl = null,Object? resultUrl = null,}) { 322 | return _then(_SeamlessTransaction( 323 | amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable 324 | as Amount,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable 325 | as String,reference: null == reference ? _self.reference : reference // ignore: cast_nullable_to_non_nullable 326 | as String,paymentMethodCode: null == paymentMethodCode ? _self.paymentMethodCode : paymentMethodCode // ignore: cast_nullable_to_non_nullable 327 | as String,customer: null == customer ? _self.customer : customer // ignore: cast_nullable_to_non_nullable 328 | as Customer,returnUrl: null == returnUrl ? _self.returnUrl : returnUrl // ignore: cast_nullable_to_non_nullable 329 | as String,resultUrl: null == resultUrl ? _self.resultUrl : resultUrl // ignore: cast_nullable_to_non_nullable 330 | as String, 331 | )); 332 | } 333 | 334 | /// Create a copy of SeamlessTransaction 335 | /// with the given fields replaced by the non-null parameter values. 336 | @override 337 | @pragma('vm:prefer-inline') 338 | $AmountCopyWith<$Res> get amount { 339 | 340 | return $AmountCopyWith<$Res>(_self.amount, (value) { 341 | return _then(_self.copyWith(amount: value)); 342 | }); 343 | }/// Create a copy of SeamlessTransaction 344 | /// with the given fields replaced by the non-null parameter values. 345 | @override 346 | @pragma('vm:prefer-inline') 347 | $CustomerCopyWith<$Res> get customer { 348 | 349 | return $CustomerCopyWith<$Res>(_self.customer, (value) { 350 | return _then(_self.copyWith(customer: value)); 351 | }); 352 | } 353 | } 354 | 355 | // dart format on 356 | -------------------------------------------------------------------------------- /lib/src/models/payment_method.freezed.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // coverage:ignore-file 3 | // ignore_for_file: type=lint 4 | // 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 5 | 6 | part of 'payment_method.dart'; 7 | 8 | // ************************************************************************** 9 | // FreezedGenerator 10 | // ************************************************************************** 11 | 12 | // dart format off 13 | T _$identity(T value) => value; 14 | 15 | /// @nodoc 16 | mixin _$PaymentMethod { 17 | 18 | bool get active; String get code; List get currencies; String get description; int get id; double get maximumAmount; double get minimumAmount; String get name; String get processingPaymentMessage; bool get redirectRequired; String? get redirectURL; List? get requiredFields; 19 | /// Create a copy of PaymentMethod 20 | /// with the given fields replaced by the non-null parameter values. 21 | @JsonKey(includeFromJson: false, includeToJson: false) 22 | @pragma('vm:prefer-inline') 23 | $PaymentMethodCopyWith get copyWith => _$PaymentMethodCopyWithImpl(this as PaymentMethod, _$identity); 24 | 25 | /// Serializes this PaymentMethod to a JSON map. 26 | Map toJson(); 27 | 28 | 29 | @override 30 | bool operator ==(Object other) { 31 | return identical(this, other) || (other.runtimeType == runtimeType&&other is PaymentMethod&&(identical(other.active, active) || other.active == active)&&(identical(other.code, code) || other.code == code)&&const DeepCollectionEquality().equals(other.currencies, currencies)&&(identical(other.description, description) || other.description == description)&&(identical(other.id, id) || other.id == id)&&(identical(other.maximumAmount, maximumAmount) || other.maximumAmount == maximumAmount)&&(identical(other.minimumAmount, minimumAmount) || other.minimumAmount == minimumAmount)&&(identical(other.name, name) || other.name == name)&&(identical(other.processingPaymentMessage, processingPaymentMessage) || other.processingPaymentMessage == processingPaymentMessage)&&(identical(other.redirectRequired, redirectRequired) || other.redirectRequired == redirectRequired)&&(identical(other.redirectURL, redirectURL) || other.redirectURL == redirectURL)&&const DeepCollectionEquality().equals(other.requiredFields, requiredFields)); 32 | } 33 | 34 | @JsonKey(includeFromJson: false, includeToJson: false) 35 | @override 36 | int get hashCode => Object.hash(runtimeType,active,code,const DeepCollectionEquality().hash(currencies),description,id,maximumAmount,minimumAmount,name,processingPaymentMessage,redirectRequired,redirectURL,const DeepCollectionEquality().hash(requiredFields)); 37 | 38 | @override 39 | String toString() { 40 | return 'PaymentMethod(active: $active, code: $code, currencies: $currencies, description: $description, id: $id, maximumAmount: $maximumAmount, minimumAmount: $minimumAmount, name: $name, processingPaymentMessage: $processingPaymentMessage, redirectRequired: $redirectRequired, redirectURL: $redirectURL, requiredFields: $requiredFields)'; 41 | } 42 | 43 | 44 | } 45 | 46 | /// @nodoc 47 | abstract mixin class $PaymentMethodCopyWith<$Res> { 48 | factory $PaymentMethodCopyWith(PaymentMethod value, $Res Function(PaymentMethod) _then) = _$PaymentMethodCopyWithImpl; 49 | @useResult 50 | $Res call({ 51 | bool active, String code, List currencies, String description, int id, double maximumAmount, double minimumAmount, String name, String processingPaymentMessage, bool redirectRequired, String? redirectURL, List? requiredFields 52 | }); 53 | 54 | 55 | 56 | 57 | } 58 | /// @nodoc 59 | class _$PaymentMethodCopyWithImpl<$Res> 60 | implements $PaymentMethodCopyWith<$Res> { 61 | _$PaymentMethodCopyWithImpl(this._self, this._then); 62 | 63 | final PaymentMethod _self; 64 | final $Res Function(PaymentMethod) _then; 65 | 66 | /// Create a copy of PaymentMethod 67 | /// with the given fields replaced by the non-null parameter values. 68 | @pragma('vm:prefer-inline') @override $Res call({Object? active = null,Object? code = null,Object? currencies = null,Object? description = null,Object? id = null,Object? maximumAmount = null,Object? minimumAmount = null,Object? name = null,Object? processingPaymentMessage = null,Object? redirectRequired = null,Object? redirectURL = freezed,Object? requiredFields = freezed,}) { 69 | return _then(_self.copyWith( 70 | active: null == active ? _self.active : active // ignore: cast_nullable_to_non_nullable 71 | as bool,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable 72 | as String,currencies: null == currencies ? _self.currencies : currencies // ignore: cast_nullable_to_non_nullable 73 | as List,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable 74 | as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable 75 | as int,maximumAmount: null == maximumAmount ? _self.maximumAmount : maximumAmount // ignore: cast_nullable_to_non_nullable 76 | as double,minimumAmount: null == minimumAmount ? _self.minimumAmount : minimumAmount // ignore: cast_nullable_to_non_nullable 77 | as double,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable 78 | as String,processingPaymentMessage: null == processingPaymentMessage ? _self.processingPaymentMessage : processingPaymentMessage // ignore: cast_nullable_to_non_nullable 79 | as String,redirectRequired: null == redirectRequired ? _self.redirectRequired : redirectRequired // ignore: cast_nullable_to_non_nullable 80 | as bool,redirectURL: freezed == redirectURL ? _self.redirectURL : redirectURL // ignore: cast_nullable_to_non_nullable 81 | as String?,requiredFields: freezed == requiredFields ? _self.requiredFields : requiredFields // ignore: cast_nullable_to_non_nullable 82 | as List?, 83 | )); 84 | } 85 | 86 | } 87 | 88 | 89 | /// Adds pattern-matching-related methods to [PaymentMethod]. 90 | extension PaymentMethodPatterns on PaymentMethod { 91 | /// A variant of `map` that fallback to returning `orElse`. 92 | /// 93 | /// It is equivalent to doing: 94 | /// ```dart 95 | /// switch (sealedClass) { 96 | /// case final Subclass value: 97 | /// return ...; 98 | /// case _: 99 | /// return orElse(); 100 | /// } 101 | /// ``` 102 | 103 | @optionalTypeArgs TResult maybeMap(TResult Function( _PaymentMethod value)? $default,{required TResult orElse(),}){ 104 | final _that = this; 105 | switch (_that) { 106 | case _PaymentMethod() when $default != null: 107 | return $default(_that);case _: 108 | return orElse(); 109 | 110 | } 111 | } 112 | /// A `switch`-like method, using callbacks. 113 | /// 114 | /// Callbacks receives the raw object, upcasted. 115 | /// It is equivalent to doing: 116 | /// ```dart 117 | /// switch (sealedClass) { 118 | /// case final Subclass value: 119 | /// return ...; 120 | /// case final Subclass2 value: 121 | /// return ...; 122 | /// } 123 | /// ``` 124 | 125 | @optionalTypeArgs TResult map(TResult Function( _PaymentMethod value) $default,){ 126 | final _that = this; 127 | switch (_that) { 128 | case _PaymentMethod(): 129 | return $default(_that);case _: 130 | throw StateError('Unexpected subclass'); 131 | 132 | } 133 | } 134 | /// A variant of `map` that fallback to returning `null`. 135 | /// 136 | /// It is equivalent to doing: 137 | /// ```dart 138 | /// switch (sealedClass) { 139 | /// case final Subclass value: 140 | /// return ...; 141 | /// case _: 142 | /// return null; 143 | /// } 144 | /// ``` 145 | 146 | @optionalTypeArgs TResult? mapOrNull(TResult? Function( _PaymentMethod value)? $default,){ 147 | final _that = this; 148 | switch (_that) { 149 | case _PaymentMethod() when $default != null: 150 | return $default(_that);case _: 151 | return null; 152 | 153 | } 154 | } 155 | /// A variant of `when` that fallback to an `orElse` callback. 156 | /// 157 | /// It is equivalent to doing: 158 | /// ```dart 159 | /// switch (sealedClass) { 160 | /// case Subclass(:final field): 161 | /// return ...; 162 | /// case _: 163 | /// return orElse(); 164 | /// } 165 | /// ``` 166 | 167 | @optionalTypeArgs TResult maybeWhen(TResult Function( bool active, String code, List currencies, String description, int id, double maximumAmount, double minimumAmount, String name, String processingPaymentMessage, bool redirectRequired, String? redirectURL, List? requiredFields)? $default,{required TResult orElse(),}) {final _that = this; 168 | switch (_that) { 169 | case _PaymentMethod() when $default != null: 170 | return $default(_that.active,_that.code,_that.currencies,_that.description,_that.id,_that.maximumAmount,_that.minimumAmount,_that.name,_that.processingPaymentMessage,_that.redirectRequired,_that.redirectURL,_that.requiredFields);case _: 171 | return orElse(); 172 | 173 | } 174 | } 175 | /// A `switch`-like method, using callbacks. 176 | /// 177 | /// As opposed to `map`, this offers destructuring. 178 | /// It is equivalent to doing: 179 | /// ```dart 180 | /// switch (sealedClass) { 181 | /// case Subclass(:final field): 182 | /// return ...; 183 | /// case Subclass2(:final field2): 184 | /// return ...; 185 | /// } 186 | /// ``` 187 | 188 | @optionalTypeArgs TResult when(TResult Function( bool active, String code, List currencies, String description, int id, double maximumAmount, double minimumAmount, String name, String processingPaymentMessage, bool redirectRequired, String? redirectURL, List? requiredFields) $default,) {final _that = this; 189 | switch (_that) { 190 | case _PaymentMethod(): 191 | return $default(_that.active,_that.code,_that.currencies,_that.description,_that.id,_that.maximumAmount,_that.minimumAmount,_that.name,_that.processingPaymentMessage,_that.redirectRequired,_that.redirectURL,_that.requiredFields);case _: 192 | throw StateError('Unexpected subclass'); 193 | 194 | } 195 | } 196 | /// A variant of `when` that fallback to returning `null` 197 | /// 198 | /// It is equivalent to doing: 199 | /// ```dart 200 | /// switch (sealedClass) { 201 | /// case Subclass(:final field): 202 | /// return ...; 203 | /// case _: 204 | /// return null; 205 | /// } 206 | /// ``` 207 | 208 | @optionalTypeArgs TResult? whenOrNull(TResult? Function( bool active, String code, List currencies, String description, int id, double maximumAmount, double minimumAmount, String name, String processingPaymentMessage, bool redirectRequired, String? redirectURL, List? requiredFields)? $default,) {final _that = this; 209 | switch (_that) { 210 | case _PaymentMethod() when $default != null: 211 | return $default(_that.active,_that.code,_that.currencies,_that.description,_that.id,_that.maximumAmount,_that.minimumAmount,_that.name,_that.processingPaymentMessage,_that.redirectRequired,_that.redirectURL,_that.requiredFields);case _: 212 | return null; 213 | 214 | } 215 | } 216 | 217 | } 218 | 219 | /// @nodoc 220 | @JsonSerializable() 221 | 222 | class _PaymentMethod extends PaymentMethod { 223 | const _PaymentMethod({required this.active, required this.code, required final List currencies, required this.description, required this.id, required this.maximumAmount, required this.minimumAmount, required this.name, required this.processingPaymentMessage, required this.redirectRequired, this.redirectURL, final List? requiredFields}): _currencies = currencies,_requiredFields = requiredFields,super._(); 224 | factory _PaymentMethod.fromJson(Map json) => _$PaymentMethodFromJson(json); 225 | 226 | @override final bool active; 227 | @override final String code; 228 | final List _currencies; 229 | @override List get currencies { 230 | if (_currencies is EqualUnmodifiableListView) return _currencies; 231 | // ignore: implicit_dynamic_type 232 | return EqualUnmodifiableListView(_currencies); 233 | } 234 | 235 | @override final String description; 236 | @override final int id; 237 | @override final double maximumAmount; 238 | @override final double minimumAmount; 239 | @override final String name; 240 | @override final String processingPaymentMessage; 241 | @override final bool redirectRequired; 242 | @override final String? redirectURL; 243 | final List? _requiredFields; 244 | @override List? get requiredFields { 245 | final value = _requiredFields; 246 | if (value == null) return null; 247 | if (_requiredFields is EqualUnmodifiableListView) return _requiredFields; 248 | // ignore: implicit_dynamic_type 249 | return EqualUnmodifiableListView(value); 250 | } 251 | 252 | 253 | /// Create a copy of PaymentMethod 254 | /// with the given fields replaced by the non-null parameter values. 255 | @override @JsonKey(includeFromJson: false, includeToJson: false) 256 | @pragma('vm:prefer-inline') 257 | _$PaymentMethodCopyWith<_PaymentMethod> get copyWith => __$PaymentMethodCopyWithImpl<_PaymentMethod>(this, _$identity); 258 | 259 | @override 260 | Map toJson() { 261 | return _$PaymentMethodToJson(this, ); 262 | } 263 | 264 | @override 265 | bool operator ==(Object other) { 266 | return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentMethod&&(identical(other.active, active) || other.active == active)&&(identical(other.code, code) || other.code == code)&&const DeepCollectionEquality().equals(other._currencies, _currencies)&&(identical(other.description, description) || other.description == description)&&(identical(other.id, id) || other.id == id)&&(identical(other.maximumAmount, maximumAmount) || other.maximumAmount == maximumAmount)&&(identical(other.minimumAmount, minimumAmount) || other.minimumAmount == minimumAmount)&&(identical(other.name, name) || other.name == name)&&(identical(other.processingPaymentMessage, processingPaymentMessage) || other.processingPaymentMessage == processingPaymentMessage)&&(identical(other.redirectRequired, redirectRequired) || other.redirectRequired == redirectRequired)&&(identical(other.redirectURL, redirectURL) || other.redirectURL == redirectURL)&&const DeepCollectionEquality().equals(other._requiredFields, _requiredFields)); 267 | } 268 | 269 | @JsonKey(includeFromJson: false, includeToJson: false) 270 | @override 271 | int get hashCode => Object.hash(runtimeType,active,code,const DeepCollectionEquality().hash(_currencies),description,id,maximumAmount,minimumAmount,name,processingPaymentMessage,redirectRequired,redirectURL,const DeepCollectionEquality().hash(_requiredFields)); 272 | 273 | @override 274 | String toString() { 275 | return 'PaymentMethod(active: $active, code: $code, currencies: $currencies, description: $description, id: $id, maximumAmount: $maximumAmount, minimumAmount: $minimumAmount, name: $name, processingPaymentMessage: $processingPaymentMessage, redirectRequired: $redirectRequired, redirectURL: $redirectURL, requiredFields: $requiredFields)'; 276 | } 277 | 278 | 279 | } 280 | 281 | /// @nodoc 282 | abstract mixin class _$PaymentMethodCopyWith<$Res> implements $PaymentMethodCopyWith<$Res> { 283 | factory _$PaymentMethodCopyWith(_PaymentMethod value, $Res Function(_PaymentMethod) _then) = __$PaymentMethodCopyWithImpl; 284 | @override @useResult 285 | $Res call({ 286 | bool active, String code, List currencies, String description, int id, double maximumAmount, double minimumAmount, String name, String processingPaymentMessage, bool redirectRequired, String? redirectURL, List? requiredFields 287 | }); 288 | 289 | 290 | 291 | 292 | } 293 | /// @nodoc 294 | class __$PaymentMethodCopyWithImpl<$Res> 295 | implements _$PaymentMethodCopyWith<$Res> { 296 | __$PaymentMethodCopyWithImpl(this._self, this._then); 297 | 298 | final _PaymentMethod _self; 299 | final $Res Function(_PaymentMethod) _then; 300 | 301 | /// Create a copy of PaymentMethod 302 | /// with the given fields replaced by the non-null parameter values. 303 | @override @pragma('vm:prefer-inline') $Res call({Object? active = null,Object? code = null,Object? currencies = null,Object? description = null,Object? id = null,Object? maximumAmount = null,Object? minimumAmount = null,Object? name = null,Object? processingPaymentMessage = null,Object? redirectRequired = null,Object? redirectURL = freezed,Object? requiredFields = freezed,}) { 304 | return _then(_PaymentMethod( 305 | active: null == active ? _self.active : active // ignore: cast_nullable_to_non_nullable 306 | as bool,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable 307 | as String,currencies: null == currencies ? _self._currencies : currencies // ignore: cast_nullable_to_non_nullable 308 | as List,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable 309 | as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable 310 | as int,maximumAmount: null == maximumAmount ? _self.maximumAmount : maximumAmount // ignore: cast_nullable_to_non_nullable 311 | as double,minimumAmount: null == minimumAmount ? _self.minimumAmount : minimumAmount // ignore: cast_nullable_to_non_nullable 312 | as double,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable 313 | as String,processingPaymentMessage: null == processingPaymentMessage ? _self.processingPaymentMessage : processingPaymentMessage // ignore: cast_nullable_to_non_nullable 314 | as String,redirectRequired: null == redirectRequired ? _self.redirectRequired : redirectRequired // ignore: cast_nullable_to_non_nullable 315 | as bool,redirectURL: freezed == redirectURL ? _self.redirectURL : redirectURL // ignore: cast_nullable_to_non_nullable 316 | as String?,requiredFields: freezed == requiredFields ? _self._requiredFields : requiredFields // ignore: cast_nullable_to_non_nullable 317 | as List?, 318 | )); 319 | } 320 | 321 | 322 | } 323 | 324 | // dart format on 325 | --------------------------------------------------------------------------------