simply_wompi 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.idea/.gitignore +8 -0
- data/.idea/Wompi.iml +67 -0
- data/.idea/modules.xml +8 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +16 -0
- data/lib/simply_wompi/transactions/application/services/transaction_creator.rb +28 -0
- data/lib/simply_wompi/transactions/domain/dtos/create_transaction_dto.rb +57 -0
- data/lib/simply_wompi/transactions/domain/dtos/create_transaction_payment_method_dto.rb +36 -0
- data/lib/simply_wompi/transactions/domain/entities/transaction.rb +94 -0
- data/lib/simply_wompi/transactions/domain/repositories/transactions_repository.rb +14 -0
- data/lib/simply_wompi/transactions/infrastructure/repositories/production/transactions_production_repository.rb +73 -0
- data/lib/simply_wompi/transactions/infrastructure/repositories/sandbox/transactions_sandbox_repository.rb +73 -0
- data/lib/simply_wompi/version.rb +5 -0
- data/lib/simply_wompi.rb +17 -0
- data/sig/wompi.rbs +4 -0
- metadata +69 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5bdf6df39d9e2d676d5aff6119c3eb27a0f60717f02fef9f1a1dd75223bd49ae
|
|
4
|
+
data.tar.gz: de16fd55f48f7cb504944c1dceb22f5a5b5ca57256623167db0418aed0a1824b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9b6d9269ef3f61fbd3b5e591f20c885509d75dd9a669e771514da5c7f1019b45dc7fd6082414bcf3b5c58b32eb3720b4f78e7908dcbd04ec40e54937b55ada60
|
|
7
|
+
data.tar.gz: d14f91c9f0a170ff54611735012436075f33da623d8b4c5e916343d4bf9e59d7bee6d5a1efd59b5c20541c20aeed3dc3bb28914e247c1904f2f19bddd215ff80
|
data/.idea/.gitignore
ADDED
data/.idea/Wompi.iml
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
|
4
|
+
<shared />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="NewModuleRootManager">
|
|
7
|
+
<content url="file://$MODULE_DIR$">
|
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
|
11
|
+
</content>
|
|
12
|
+
<orderEntry type="jdk" jdkName="rbenv: 3.0.2" jdkType="RUBY_SDK" />
|
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 3.0.2) [gem]" level="application" />
|
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.11, rbenv: 3.0.2) [gem]" level="application" />
|
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, rbenv: 3.0.2) [gem]" level="application" />
|
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, rbenv: 3.0.2) [gem]" level="application" />
|
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v3.1.0.0, rbenv: 3.0.2) [gem]" level="application" />
|
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.0.2) [gem]" level="application" />
|
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 3.0.2) [gem]" level="application" />
|
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.2.0, rbenv: 3.0.2) [gem]" level="application" />
|
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, rbenv: 3.0.2) [gem]" level="application" />
|
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.25.0, rbenv: 3.0.2) [gem]" level="application" />
|
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.15.1, rbenv: 3.0.2) [gem]" level="application" />
|
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, rbenv: 3.0.2) [gem]" level="application" />
|
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, rbenv: 3.0.2) [gem]" level="application" />
|
|
27
|
+
</component>
|
|
28
|
+
<component name="RakeTasksCache">
|
|
29
|
+
<option name="myRootTask">
|
|
30
|
+
<RakeTaskImpl id="rake">
|
|
31
|
+
<subtasks>
|
|
32
|
+
<RakeTaskImpl description="Build Wompi-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
|
33
|
+
<RakeTaskImpl id="build">
|
|
34
|
+
<subtasks>
|
|
35
|
+
<RakeTaskImpl description="Generate SHA512 checksum if Wompi-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
|
36
|
+
</subtasks>
|
|
37
|
+
</RakeTaskImpl>
|
|
38
|
+
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
|
39
|
+
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
|
40
|
+
<RakeTaskImpl description="Build and install Wompi-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
|
41
|
+
<RakeTaskImpl id="install">
|
|
42
|
+
<subtasks>
|
|
43
|
+
<RakeTaskImpl description="Build and install Wompi-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
|
44
|
+
</subtasks>
|
|
45
|
+
</RakeTaskImpl>
|
|
46
|
+
<RakeTaskImpl description="Create tag v0.1.0 and build and push Wompi-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
|
47
|
+
<RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
|
|
48
|
+
<RakeTaskImpl id="rubocop">
|
|
49
|
+
<subtasks>
|
|
50
|
+
<RakeTaskImpl description="Auto-correct RuboCop offenses" fullCommand="rubocop:auto_correct" id="auto_correct" />
|
|
51
|
+
</subtasks>
|
|
52
|
+
</RakeTaskImpl>
|
|
53
|
+
<RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
|
|
54
|
+
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
|
55
|
+
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
|
56
|
+
<RakeTaskImpl id="release">
|
|
57
|
+
<subtasks>
|
|
58
|
+
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
|
59
|
+
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
|
60
|
+
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
|
61
|
+
</subtasks>
|
|
62
|
+
</RakeTaskImpl>
|
|
63
|
+
</subtasks>
|
|
64
|
+
</RakeTaskImpl>
|
|
65
|
+
</option>
|
|
66
|
+
</component>
|
|
67
|
+
</module>
|
data/.idea/modules.xml
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
22
|
+
advances of any kind
|
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
24
|
+
* Public or private harassment
|
|
25
|
+
* Publishing others' private information, such as a physical or email
|
|
26
|
+
address, without their explicit permission
|
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
28
|
+
professional setting
|
|
29
|
+
|
|
30
|
+
## Enforcement Responsibilities
|
|
31
|
+
|
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
33
|
+
|
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
35
|
+
|
|
36
|
+
## Scope
|
|
37
|
+
|
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
39
|
+
|
|
40
|
+
## Enforcement
|
|
41
|
+
|
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jorge.castillo@idea23.mx. All complaints will be reviewed and investigated promptly and fairly.
|
|
43
|
+
|
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
45
|
+
|
|
46
|
+
## Enforcement Guidelines
|
|
47
|
+
|
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
49
|
+
|
|
50
|
+
### 1. Correction
|
|
51
|
+
|
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
53
|
+
|
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
55
|
+
|
|
56
|
+
### 2. Warning
|
|
57
|
+
|
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
59
|
+
|
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
61
|
+
|
|
62
|
+
### 3. Temporary Ban
|
|
63
|
+
|
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
65
|
+
|
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
67
|
+
|
|
68
|
+
### 4. Permanent Ban
|
|
69
|
+
|
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
71
|
+
|
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
73
|
+
|
|
74
|
+
## Attribution
|
|
75
|
+
|
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
78
|
+
|
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
80
|
+
|
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
|
82
|
+
|
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
simply_wompi (0.0.1)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.2)
|
|
10
|
+
minitest (5.15.0)
|
|
11
|
+
parallel (1.21.0)
|
|
12
|
+
parser (3.1.0.0)
|
|
13
|
+
ast (~> 2.4.1)
|
|
14
|
+
rainbow (3.1.1)
|
|
15
|
+
rake (13.0.6)
|
|
16
|
+
regexp_parser (2.2.0)
|
|
17
|
+
rexml (3.2.5)
|
|
18
|
+
rubocop (1.25.0)
|
|
19
|
+
parallel (~> 1.10)
|
|
20
|
+
parser (>= 3.1.0.0)
|
|
21
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
22
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
23
|
+
rexml
|
|
24
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
|
25
|
+
ruby-progressbar (~> 1.7)
|
|
26
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
27
|
+
rubocop-ast (1.15.1)
|
|
28
|
+
parser (>= 3.0.1.1)
|
|
29
|
+
ruby-progressbar (1.11.0)
|
|
30
|
+
unicode-display_width (2.1.0)
|
|
31
|
+
|
|
32
|
+
PLATFORMS
|
|
33
|
+
x86_64-darwin-21
|
|
34
|
+
|
|
35
|
+
DEPENDENCIES
|
|
36
|
+
minitest (~> 5.0)
|
|
37
|
+
rake (~> 13.0)
|
|
38
|
+
rubocop (~> 1.21)
|
|
39
|
+
simply_wompi!
|
|
40
|
+
|
|
41
|
+
BUNDLED WITH
|
|
42
|
+
2.3.11
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 schorts
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# SimplyWompi
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/wompi`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
10
|
+
|
|
11
|
+
$ bundle add simply_wompi
|
|
12
|
+
|
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
14
|
+
|
|
15
|
+
$ gem install simply_wompi
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
TODO: Write usage instructions here
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
24
|
+
|
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/Wompi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/Wompi/blob/master/CODE_OF_CONDUCT.md).
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
34
|
+
|
|
35
|
+
## Code of Conduct
|
|
36
|
+
|
|
37
|
+
Everyone interacting in the Wompi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/Wompi/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rake/testtask"
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << "test"
|
|
8
|
+
t.libs << "lib"
|
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require "rubocop/rake_task"
|
|
13
|
+
|
|
14
|
+
RuboCop::RakeTask.new
|
|
15
|
+
|
|
16
|
+
task default: %i[test rubocop]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module SimplyWompi
|
|
2
|
+
module Transactions
|
|
3
|
+
module Application
|
|
4
|
+
module Services
|
|
5
|
+
# Transaction Creator
|
|
6
|
+
class TransactionCreator
|
|
7
|
+
attr_reader :transactions_repository
|
|
8
|
+
|
|
9
|
+
def initialize(transactions_repository:)
|
|
10
|
+
unless transactions_repository.is_a?(Domain::Repositories::TransactionsRepository)
|
|
11
|
+
raise ArgumentError("ArgumentError transactions_repository: #{transactions_repository.class}, is not instance of #{Domain::Repositories::TransactionsRepository}")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
@transactions_repository = transactions_repository
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def call(create_transaction_dto:)
|
|
18
|
+
unless create_transaction_dto.is_a?(Domain::Dtos::CreateTransactionDto)
|
|
19
|
+
raise ArgumentError("ArgumentError create_transaction_dto: #{create_transaction_dto.class}, is not instance of #{Domain::Dtos::CreateTransactionDto}")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@transactions_repository.create(create_transaction_dto: create_transaction_dto)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module SimplyWompi
|
|
2
|
+
module Transactions
|
|
3
|
+
module Domain
|
|
4
|
+
module Dtos
|
|
5
|
+
# Create Transaction Data Transfer Object
|
|
6
|
+
class CreateTransactionDto
|
|
7
|
+
attr_reader :acceptance_token,
|
|
8
|
+
:amount_in_cents,
|
|
9
|
+
:currency,
|
|
10
|
+
:customer_email,
|
|
11
|
+
:payment_method,
|
|
12
|
+
:reference
|
|
13
|
+
|
|
14
|
+
def initialize(
|
|
15
|
+
acceptance_token:,
|
|
16
|
+
amount_in_cents:,
|
|
17
|
+
currency:,
|
|
18
|
+
customer_email:,
|
|
19
|
+
payment_method:,
|
|
20
|
+
reference:
|
|
21
|
+
)
|
|
22
|
+
unless acceptance_token.is_a?(String)
|
|
23
|
+
raise ArgumentError("ArgumentError acceptance_token: #{acceptance_token.class}, is not instance of #{String}")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
unless amount_in_cents.is_a?(Integer)
|
|
27
|
+
raise ArgumentError("ArgumentError amount_in_cents: #{amount_in_cents.class}, is not instance of #{Integer}")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
unless currency.is_a?(String)
|
|
31
|
+
raise ArgumentError("ArgumentError currency: #{currency.class}, is not instance of #{String}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
unless customer_email.is_a?(String)
|
|
35
|
+
raise ArgumentError("ArgumentError customer_email: #{customer_email.class}, is not instance of #{String}")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
unless payment_method.is_a?(CreateTransactionPaymentMethodDto)
|
|
39
|
+
raise ArgumentError("ArgumentError payment_method: #{payment_method.class}, is not instance of #{CreateTransactionPaymentMethodDto}")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
unless reference.is_a?(String)
|
|
43
|
+
raise ArgumentError("ArgumentError reference: #{reference.class}, is not instance of #{String}")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
@acceptance_token = acceptance_token
|
|
47
|
+
@amount_in_cents = amount_in_cents
|
|
48
|
+
@currency = currency
|
|
49
|
+
@customer_email = customer_email
|
|
50
|
+
@payment_method = payment_method
|
|
51
|
+
@reference = reference
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module SimplyWompi
|
|
2
|
+
module Transactions
|
|
3
|
+
module Domain
|
|
4
|
+
module Dtos
|
|
5
|
+
# Create Transaction Payment Method Data Transfer Object
|
|
6
|
+
class CreateTransactionPaymentMethodDto
|
|
7
|
+
attr_reader :type,
|
|
8
|
+
:token,
|
|
9
|
+
:installments
|
|
10
|
+
|
|
11
|
+
def initialize(
|
|
12
|
+
type:,
|
|
13
|
+
token:,
|
|
14
|
+
installments:
|
|
15
|
+
)
|
|
16
|
+
unless type.is_a?(String)
|
|
17
|
+
raise ArgumentError("ArgumentError type: #{type.class}, is not instance of #{String}")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
unless token.is_a?(String)
|
|
21
|
+
raise ArgumentError("ArgumentError token: #{token.class}, is not instance of #{String}")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
unless installments.is_a?(Integer)
|
|
25
|
+
raise ArgumentError("ArgumentError installments: #{installments.class}, is not instance of #{Integer}")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
@type = type
|
|
29
|
+
@token = token
|
|
30
|
+
@installments = installments
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require "date"
|
|
2
|
+
|
|
3
|
+
module SimplyWompi
|
|
4
|
+
module Transactions
|
|
5
|
+
module Domain
|
|
6
|
+
module Entities
|
|
7
|
+
# Transaction Entity
|
|
8
|
+
class Transaction
|
|
9
|
+
attr_accessor :id,
|
|
10
|
+
:created_at,
|
|
11
|
+
:amount_in_cents,
|
|
12
|
+
:status,
|
|
13
|
+
:reference,
|
|
14
|
+
:customer_email,
|
|
15
|
+
:currency,
|
|
16
|
+
:payment_method_type,
|
|
17
|
+
:payment_method,
|
|
18
|
+
:redirect_url,
|
|
19
|
+
:payment_link_id
|
|
20
|
+
|
|
21
|
+
def initialize(
|
|
22
|
+
id:,
|
|
23
|
+
created_at:,
|
|
24
|
+
amount_in_cents:,
|
|
25
|
+
status:,
|
|
26
|
+
reference:,
|
|
27
|
+
customer_email:,
|
|
28
|
+
currency:,
|
|
29
|
+
payment_method_type:,
|
|
30
|
+
payment_method:,
|
|
31
|
+
redirect_url:,
|
|
32
|
+
payment_link_id:
|
|
33
|
+
)
|
|
34
|
+
unless id.is_a?(String)
|
|
35
|
+
raise ArgumentError("ArgumentError id: #{id.class}, is not instance of #{String}")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
unless created_at.is_a?(Date)
|
|
39
|
+
raise ArgumentError("ArgumentError created_at: #{created_at.class}, is not instance of #{Date}")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
unless amount_in_cents.is_a?(Integer)
|
|
43
|
+
raise ArgumentError("ArgumentError amount_in_cents: #{amount_in_cents.class}, is not instance of #{Integer}")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
unless status.is_a?(String)
|
|
47
|
+
raise ArgumentError("ArgumentError status: #{status.class}, is not instance of #{String}")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
unless reference.is_a?(String)
|
|
51
|
+
raise ArgumentError("ArgumentError reference: #{reference.class}, is not instance of #{String}")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
unless customer_email.is_a?(String)
|
|
55
|
+
raise ArgumentError("ArgumentError customer_email: #{customer_email.class}, is not instance of #{String}")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
unless currency.is_a?(String)
|
|
59
|
+
raise ArgumentError("ArgumentError currency: #{currency.class}, is not instance of #{String}")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
unless payment_method_type.is_a?(String)
|
|
63
|
+
raise ArgumentError("ArgumentError payment_method_type: #{payment_method_type.class}, is not instance of #{String}")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
unless payment_method.is_a?(Dtos::CreatePaymentPaymentMethodDto)
|
|
67
|
+
raise ArgumentError("ArgumentError payment_method: #{payment_method.class}, is not instance of #{CreatePaymentPaymentMethodDto}")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
unless redirect_url.is_a?(String)
|
|
71
|
+
raise ArgumentError("ArgumentError redirect_url: #{redirect_url.class}, is not instance of #{String}")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
unless payment_link_id.is_a?(String)
|
|
75
|
+
raise ArgumentError("ArgumentError payment_link_id: #{payment_link_id.class}, is not instance of #{String}")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
self.id = id
|
|
79
|
+
self.created_at = created_at
|
|
80
|
+
self.amount_in_cents = amount_in_cents
|
|
81
|
+
self.status = status
|
|
82
|
+
self.reference = reference
|
|
83
|
+
self.customer_email = customer_email
|
|
84
|
+
self.currency = currency
|
|
85
|
+
self.payment_method_type = payment_method_type
|
|
86
|
+
self.payment_method = payment_method
|
|
87
|
+
self.redirect_url = redirect_url
|
|
88
|
+
self.payment_link_id = payment_link_id
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "date"
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "uri"
|
|
5
|
+
|
|
6
|
+
# Domain
|
|
7
|
+
require_relative "../../../domain/repositories/transactions_repository"
|
|
8
|
+
|
|
9
|
+
module SimplyWompi
|
|
10
|
+
module Transactions
|
|
11
|
+
module Infrastructure
|
|
12
|
+
module Repositories
|
|
13
|
+
module Production
|
|
14
|
+
# Transactions Production Repository
|
|
15
|
+
class TransactionsProductionRepository < ::SimplyWompi::Transactions::Domain::Repositories::TransactionsRepository
|
|
16
|
+
def initialize(api_key:)
|
|
17
|
+
unless api_key.is_a?(String)
|
|
18
|
+
raise ArgumentError("ArgumentError api_key: #{api_key.class}, is not instance of #{String}")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
@api_key = api_key
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create(create_transaction_dto:)
|
|
25
|
+
unless create_transaction_dto.is_a?(::SimplyWompi::Transactions::Domain::Dtos::CreateTransactionDto)
|
|
26
|
+
raise ArgumentError("ArgumentError create_transaction_dto: #{create_transaction_dto.class}, is not instance of #{Domain::Dtos::CreateTransactionDto}")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
response = ::Net::HTTP.post(URI('https://production.wompi.co/v1/transactions'), {
|
|
30
|
+
acceptance_token: create_transaction_dto.acceptance_token,
|
|
31
|
+
amount_in_cents: create_transaction_dto.amount_in_cents,
|
|
32
|
+
currency: create_transaction_dto.currency,
|
|
33
|
+
customer_email: create_transaction_dto.customer_email,
|
|
34
|
+
payment_method: {
|
|
35
|
+
type: create_transaction_dto.payment_method.type,
|
|
36
|
+
token: create_transaction_dto.payment_method.token,
|
|
37
|
+
installments: create_transaction_dto.payment_method.installments
|
|
38
|
+
},
|
|
39
|
+
reference: create_transaction_dto.reference
|
|
40
|
+
}.to_json, {
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
Authorization: @api_key
|
|
43
|
+
})
|
|
44
|
+
parsed_response = JSON.parse(response.body, { symbolize_names: true })
|
|
45
|
+
|
|
46
|
+
unless response.code == "201"
|
|
47
|
+
raise "StandardError error: #{parsed_response[:error]}"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
::SimplyWompi::Transactions::Domain::Entities::Transaction.new(
|
|
51
|
+
id: parsed_response[:data][:id],
|
|
52
|
+
created_at: Date.parse(parsed_response[:data][:created_at]),
|
|
53
|
+
amount_in_cents: parsed_response[:data][:amount_in_cents],
|
|
54
|
+
status: parsed_response[:data][:status],
|
|
55
|
+
reference: parsed_response[:data][:reference],
|
|
56
|
+
customer_email: parsed_response[:data][:customer_email],
|
|
57
|
+
currency: parsed_response[:data][:currency],
|
|
58
|
+
payment_method_type: parsed_response[:data][:payment_method_type],
|
|
59
|
+
payment_method: ::SimplyWompi::Transactions::Domain::Dtos::CreatePaymentPaymentMethodDto.new(
|
|
60
|
+
type: parsed_response[:data][:payment_method][:type],
|
|
61
|
+
token: parsed_response[:data][:payment_method][:token],
|
|
62
|
+
installments: parsed_response[:data][:payment_method][:installments]
|
|
63
|
+
),
|
|
64
|
+
redirect_url: parsed_response[:data][:redirect_url],
|
|
65
|
+
payment_link_id: parsed_response[:data][:payment_link_id]
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "date"
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "uri"
|
|
5
|
+
|
|
6
|
+
# Domain
|
|
7
|
+
require_relative "../../../domain/repositories/transactions_repository"
|
|
8
|
+
|
|
9
|
+
module SimplyWompi
|
|
10
|
+
module Transactions
|
|
11
|
+
module Infrastructure
|
|
12
|
+
module Repositories
|
|
13
|
+
module Sandbox
|
|
14
|
+
# Payment Sandbox Repository
|
|
15
|
+
class TransactionsSandboxRepository < ::SimplyWompi::Transactions::Domain::Repositories::TransactionsRepository
|
|
16
|
+
def initialize(api_key:)
|
|
17
|
+
unless api_key.is_a?(String)
|
|
18
|
+
raise ArgumentError("ArgumentError api_key: #{api_key.class}, is not instance of #{String}")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
@api_key = api_key
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create(create_transaction_dto:)
|
|
25
|
+
unless create_transaction_dto.is_a?(::SimplyWompi::Transactions::Domain::Dtos::CreateTransactionDto)
|
|
26
|
+
raise ArgumentError("ArgumentError create_transaction_dto: #{create_transaction_dto.class}, is not instance of #{Domain::Dtos::CreateTransactionDto}")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
response = ::Net::HTTP.post(URI('https://sandbox.wompi.co/v1/transactions'), {
|
|
30
|
+
acceptance_token: create_transaction_dto.acceptance_token,
|
|
31
|
+
amount_in_cents: create_transaction_dto.amount_in_cents,
|
|
32
|
+
currency: create_transaction_dto.currency,
|
|
33
|
+
customer_email: create_transaction_dto.customer_email,
|
|
34
|
+
payment_method: {
|
|
35
|
+
type: create_transaction_dto.payment_method.type,
|
|
36
|
+
token: create_transaction_dto.payment_method.token,
|
|
37
|
+
installments: create_transaction_dto.payment_method.installments
|
|
38
|
+
},
|
|
39
|
+
reference: create_transaction_dto.reference
|
|
40
|
+
}.to_json, {
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
Authorization: @api_key
|
|
43
|
+
})
|
|
44
|
+
parsed_response = JSON.parse(response.body, { symbolize_names: true })
|
|
45
|
+
|
|
46
|
+
unless response.code == "201"
|
|
47
|
+
raise "StandardError error: #{parsed_response[:error]}"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
::SimplyWompi::Transactions::Domain::Entities::Transaction.new(
|
|
51
|
+
id: parsed_response[:data][:id],
|
|
52
|
+
created_at: Date.parse(parsed_response[:data][:created_at]),
|
|
53
|
+
amount_in_cents: parsed_response[:data][:amount_in_cents],
|
|
54
|
+
status: parsed_response[:data][:status],
|
|
55
|
+
reference: parsed_response[:data][:reference],
|
|
56
|
+
customer_email: parsed_response[:data][:customer_email],
|
|
57
|
+
currency: parsed_response[:data][:currency],
|
|
58
|
+
payment_method_type: parsed_response[:data][:payment_method_type],
|
|
59
|
+
payment_method: ::SimplyWompi::Transactions::Domain::Dtos::CreatePaymentPaymentMethodDto.new(
|
|
60
|
+
type: parsed_response[:data][:payment_method][:type],
|
|
61
|
+
token: parsed_response[:data][:payment_method][:token],
|
|
62
|
+
installments: parsed_response[:data][:payment_method][:installments]
|
|
63
|
+
),
|
|
64
|
+
redirect_url: parsed_response[:data][:redirect_url],
|
|
65
|
+
payment_link_id: parsed_response[:data][:payment_link_id]
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
data/lib/simply_wompi.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "simply_wompi/version"
|
|
4
|
+
|
|
5
|
+
# Infrastructure
|
|
6
|
+
require_relative "simply_wompi/transactions/infrastructure/repositories/sandbox/transactions_sandbox_repository"
|
|
7
|
+
require_relative "simply_wompi/transactions/infrastructure/repositories/production/transactions_production_repository"
|
|
8
|
+
|
|
9
|
+
# Application
|
|
10
|
+
require_relative "simply_wompi/transactions/application/services/transaction_creator"
|
|
11
|
+
|
|
12
|
+
# Domain
|
|
13
|
+
require_relative "simply_wompi/transactions/domain/repositories/transactions_repository"
|
|
14
|
+
require_relative "simply_wompi/transactions/domain/dtos/create_transaction_dto"
|
|
15
|
+
require_relative "simply_wompi/transactions/domain/dtos/create_transaction_payment_method_dto"
|
|
16
|
+
|
|
17
|
+
module SimplyWompi; end
|
data/sig/wompi.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: simply_wompi
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Simply Development
|
|
8
|
+
- Jorge Castillo
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2022-04-16 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Ruby implementation of Wompi Payment transactions gateway.
|
|
15
|
+
email:
|
|
16
|
+
- contact@simply-development,com
|
|
17
|
+
- j@simply-development.com
|
|
18
|
+
executables: []
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- ".idea/.gitignore"
|
|
23
|
+
- ".idea/Wompi.iml"
|
|
24
|
+
- ".idea/modules.xml"
|
|
25
|
+
- ".rubocop.yml"
|
|
26
|
+
- CHANGELOG.md
|
|
27
|
+
- CODE_OF_CONDUCT.md
|
|
28
|
+
- Gemfile
|
|
29
|
+
- Gemfile.lock
|
|
30
|
+
- LICENSE.txt
|
|
31
|
+
- README.md
|
|
32
|
+
- Rakefile
|
|
33
|
+
- lib/simply_wompi.rb
|
|
34
|
+
- lib/simply_wompi/transactions/application/services/transaction_creator.rb
|
|
35
|
+
- lib/simply_wompi/transactions/domain/dtos/create_transaction_dto.rb
|
|
36
|
+
- lib/simply_wompi/transactions/domain/dtos/create_transaction_payment_method_dto.rb
|
|
37
|
+
- lib/simply_wompi/transactions/domain/entities/transaction.rb
|
|
38
|
+
- lib/simply_wompi/transactions/domain/repositories/transactions_repository.rb
|
|
39
|
+
- lib/simply_wompi/transactions/infrastructure/repositories/production/transactions_production_repository.rb
|
|
40
|
+
- lib/simply_wompi/transactions/infrastructure/repositories/sandbox/transactions_sandbox_repository.rb
|
|
41
|
+
- lib/simply_wompi/version.rb
|
|
42
|
+
- sig/wompi.rbs
|
|
43
|
+
homepage: https://github.com/Simply-Development/Wompi-Ruby-Gem
|
|
44
|
+
licenses:
|
|
45
|
+
- MIT
|
|
46
|
+
metadata:
|
|
47
|
+
homepage_uri: https://github.com/Simply-Development/Wompi-Ruby-Gem
|
|
48
|
+
source_code_uri: https://github.com/Simply-Development/Wompi-Ruby-Gem
|
|
49
|
+
changelog_uri: https://github.com/Simply-Development/Wompi-Ruby-Gem
|
|
50
|
+
post_install_message:
|
|
51
|
+
rdoc_options: []
|
|
52
|
+
require_paths:
|
|
53
|
+
- lib
|
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: 2.6.0
|
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '0'
|
|
64
|
+
requirements: []
|
|
65
|
+
rubygems_version: 3.2.22
|
|
66
|
+
signing_key:
|
|
67
|
+
specification_version: 4
|
|
68
|
+
summary: Wompi implementation.
|
|
69
|
+
test_files: []
|