genesis_ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +11 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +158 -0
  5. data/LICENSE +21 -0
  6. data/README.md +343 -0
  7. data/Rakefile +12 -0
  8. data/VERSION +1 -0
  9. data/genesis_ruby.gemspec +43 -0
  10. data/lib/genesis_ruby/api/constants/currencies/iso4217.rb +1106 -0
  11. data/lib/genesis_ruby/api/constants/date_time_formats.rb +45 -0
  12. data/lib/genesis_ruby/api/constants/endpoints.rb +18 -0
  13. data/lib/genesis_ruby/api/constants/environments.rb +17 -0
  14. data/lib/genesis_ruby/api/constants/states/state.rb +43 -0
  15. data/lib/genesis_ruby/api/constants/states.rb +86 -0
  16. data/lib/genesis_ruby/api/constants/transactions/parameters/business/payment_types.rb +24 -0
  17. data/lib/genesis_ruby/api/constants/transactions/parameters/recurring/categories.rb +24 -0
  18. data/lib/genesis_ruby/api/constants/transactions/parameters/recurring/types.rb +28 -0
  19. data/lib/genesis_ruby/api/constants/transactions/parameters/sca_exemptions.rb +34 -0
  20. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/browser/color_depths.rb +46 -0
  21. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/password_change_indicators.rb +37 -0
  22. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/registration_indicators.rb +37 -0
  23. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/shipping_address_usage_indicators.rb +34 -0
  24. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/suspicious_activity_indicators.rb +28 -0
  25. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/update_indicators.rb +34 -0
  26. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/control/challenge_indicators.rb +34 -0
  27. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/control/challenge_window_sizes.rb +37 -0
  28. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/control/device_types.rb +28 -0
  29. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/merchant_risk/delivery_timeframes.rb +34 -0
  30. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/merchant_risk/pre_order_purchase_indicators.rb +28 -0
  31. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/merchant_risk/reorder_item_indicators.rb +28 -0
  32. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/merchant_risk/shipping_indicators.rb +46 -0
  33. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/purchase/categories.rb +43 -0
  34. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/interfaces.rb +31 -0
  35. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/ui_types.rb +37 -0
  36. data/lib/genesis_ruby/api/constants/transactions.rb +371 -0
  37. data/lib/genesis_ruby/api/mixins/constants/common.rb +27 -0
  38. data/lib/genesis_ruby/api/mixins/requests/address_info_attributes.rb +20 -0
  39. data/lib/genesis_ruby/api/mixins/requests/customer_address/billing_info_attributes.rb +33 -0
  40. data/lib/genesis_ruby/api/mixins/requests/customer_address/customer_info_attributes.rb +26 -0
  41. data/lib/genesis_ruby/api/mixins/requests/customer_address/shipping_info_attributes.rb +33 -0
  42. data/lib/genesis_ruby/api/mixins/requests/document_attributes.rb +14 -0
  43. data/lib/genesis_ruby/api/mixins/requests/financial/async_attributes.rb +34 -0
  44. data/lib/genesis_ruby/api/mixins/requests/financial/base_attributes.rb +16 -0
  45. data/lib/genesis_ruby/api/mixins/requests/financial/business/airlines_air_carriers_attributes.rb +60 -0
  46. data/lib/genesis_ruby/api/mixins/requests/financial/business/business_attributes.rb +56 -0
  47. data/lib/genesis_ruby/api/mixins/requests/financial/business/car_plane_and_boat_rentals_attributes.rb +53 -0
  48. data/lib/genesis_ruby/api/mixins/requests/financial/business/cruise_lines_attributes.rb +50 -0
  49. data/lib/genesis_ruby/api/mixins/requests/financial/business/event_management_attributes.rb +54 -0
  50. data/lib/genesis_ruby/api/mixins/requests/financial/business/furniture_attributes.rb +53 -0
  51. data/lib/genesis_ruby/api/mixins/requests/financial/business/hotels_and_real_estate_rentals_attributes.rb +53 -0
  52. data/lib/genesis_ruby/api/mixins/requests/financial/business/travel_agencies_attributes.rb +88 -0
  53. data/lib/genesis_ruby/api/mixins/requests/financial/cards/credit_card_attributes.rb +31 -0
  54. data/lib/genesis_ruby/api/mixins/requests/financial/cards/fx_rate_attributes.rb +18 -0
  55. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/recurring_category_attributes.rb +31 -0
  56. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/recurring_type_attributes.rb +31 -0
  57. data/lib/genesis_ruby/api/mixins/requests/financial/cards/tokenization_attributes.rb +39 -0
  58. data/lib/genesis_ruby/api/mixins/requests/financial/crypto_attributes.rb +25 -0
  59. data/lib/genesis_ruby/api/mixins/requests/financial/dynamic_descriptor_attributes.rb +114 -0
  60. data/lib/genesis_ruby/api/mixins/requests/financial/gaming_attributes.rb +25 -0
  61. data/lib/genesis_ruby/api/mixins/requests/financial/moto_attributes.rb +25 -0
  62. data/lib/genesis_ruby/api/mixins/requests/financial/notification_attributes.rb +25 -0
  63. data/lib/genesis_ruby/api/mixins/requests/financial/payment_attributes.rb +32 -0
  64. data/lib/genesis_ruby/api/mixins/requests/financial/pending_payment_attributes.rb +25 -0
  65. data/lib/genesis_ruby/api/mixins/requests/financial/reference_attributes.rb +16 -0
  66. data/lib/genesis_ruby/api/mixins/requests/financial/risk_attributes.rb +47 -0
  67. data/lib/genesis_ruby/api/mixins/requests/financial/sca_attributes.rb +37 -0
  68. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/browser.rb +92 -0
  69. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/card_holder_account.rb +183 -0
  70. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/common_attributes.rb +52 -0
  71. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/control.rb +61 -0
  72. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/merchant_risk.rb +114 -0
  73. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/method.rb +44 -0
  74. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/purchase.rb +42 -0
  75. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/recurring.rb +49 -0
  76. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/sdk.rb +107 -0
  77. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/wpf_attributes.rb +61 -0
  78. data/lib/genesis_ruby/api/mixins/requests/restricted_setter.rb +75 -0
  79. data/lib/genesis_ruby/api/request.rb +171 -0
  80. data/lib/genesis_ruby/api/requests/base/financial.rb +44 -0
  81. data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +27 -0
  82. data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +60 -0
  83. data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +76 -0
  84. data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +59 -0
  85. data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +75 -0
  86. data/lib/genesis_ruby/api/requests/wpf/create.rb +142 -0
  87. data/lib/genesis_ruby/api/response.rb +91 -0
  88. data/lib/genesis_ruby/builder.rb +42 -0
  89. data/lib/genesis_ruby/builders/base.rb +18 -0
  90. data/lib/genesis_ruby/builders/xml.rb +95 -0
  91. data/lib/genesis_ruby/configuration.rb +177 -0
  92. data/lib/genesis_ruby/connection.rb +20 -0
  93. data/lib/genesis_ruby/dependencies.rb +19 -0
  94. data/lib/genesis_ruby/errors/builder_error.rb +14 -0
  95. data/lib/genesis_ruby/errors/endpoint_not_set_error.rb +14 -0
  96. data/lib/genesis_ruby/errors/error.rb +18 -0
  97. data/lib/genesis_ruby/errors/invalid_argument_error.rb +14 -0
  98. data/lib/genesis_ruby/errors/network_error.rb +14 -0
  99. data/lib/genesis_ruby/errors/object_formatter_error.rb +14 -0
  100. data/lib/genesis_ruby/errors/parameter_error.rb +12 -0
  101. data/lib/genesis_ruby/errors/parser_error.rb +14 -0
  102. data/lib/genesis_ruby/errors/response_error.rb +14 -0
  103. data/lib/genesis_ruby/network/adapter/base_adapter.rb +31 -0
  104. data/lib/genesis_ruby/network/adapter/net_http_adapter.rb +92 -0
  105. data/lib/genesis_ruby/network/base_network.rb +83 -0
  106. data/lib/genesis_ruby/network/net_http.rb +28 -0
  107. data/lib/genesis_ruby/parser.rb +44 -0
  108. data/lib/genesis_ruby/parsers/base.rb +25 -0
  109. data/lib/genesis_ruby/parsers/xml.rb +120 -0
  110. data/lib/genesis_ruby/utils/common.rb +108 -0
  111. data/lib/genesis_ruby/utils/formatters/base.rb +40 -0
  112. data/lib/genesis_ruby/utils/formatters/response/definitions.rb +21 -0
  113. data/lib/genesis_ruby/utils/formatters/response/formats/amount.rb +34 -0
  114. data/lib/genesis_ruby/utils/formatters/response/formats/timestamp.rb +29 -0
  115. data/lib/genesis_ruby/utils/formatters/response/loader.rb +42 -0
  116. data/lib/genesis_ruby/utils/money/base/strategy.rb +38 -0
  117. data/lib/genesis_ruby/utils/money/conversions/amount_to_exponent.rb +22 -0
  118. data/lib/genesis_ruby/utils/money/conversions/exponent_to_amount.rb +22 -0
  119. data/lib/genesis_ruby/utils/money/format.rb +34 -0
  120. data/lib/genesis_ruby/utils/money_format.rb +39 -0
  121. data/lib/genesis_ruby/utils/object_formatter.rb +67 -0
  122. data/lib/genesis_ruby/utils/options/api_config.rb +36 -0
  123. data/lib/genesis_ruby/utils/options/base.rb +35 -0
  124. data/lib/genesis_ruby/utils/options/network_adapter_config.rb +41 -0
  125. data/lib/genesis_ruby/utils/transactions/financial_types.rb +50 -0
  126. data/lib/genesis_ruby/utils/transactions/references/capturable_types.rb +52 -0
  127. data/lib/genesis_ruby/utils/transactions/references/refundable_types.rb +70 -0
  128. data/lib/genesis_ruby/utils/transactions/references/voidable_types.rb +49 -0
  129. data/lib/genesis_ruby/utils/transactions/wpf_types.rb +43 -0
  130. data/lib/genesis_ruby/version.rb +5 -0
  131. data/lib/genesis_ruby.rb +57 -0
  132. metadata +372 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 88fa7a15b9a49833d8de193195478d25730cd08832a9f1c77a9e8029bead7fe7
4
+ data.tar.gz: 17a9e30b42dc026cd920e7be4d5983b0631baad23655bf2703b28b92c7f61d04
5
+ SHA512:
6
+ metadata.gz: 1c7ea66d38e6ce58bf8a9560ade34eff61013a580e2af31f96164482891738874a70c3d481fcf4ab19158b5105003df849e6f145c1dbf1e1d46ddb405fd48134
7
+ data.tar.gz: 836820c824e0eb854e9b7c22eb95cfdfcdf990f4f8c0362a77ff6935e28c7fbbaeb81dd046a11e66661018797d77c8ade7e01d19a1ac0d2e664a16c955789b29
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ 0.1.0
2
+ -----
3
+ **Features**:
4
+
5
+ * Added initial Genesis Client Library version 0.1.0
6
+ * Added support for the creation of the following transaction requests:
7
+ * Web Payment Form
8
+ * Authorize
9
+ * Authorize 3D
10
+ * Sale
11
+ * Sale 3D
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in genesis_ruby.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,158 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ genesis_ruby (0.1.0)
5
+ net-http (~> 0.3.2)
6
+ nokogiri (~> 1.14)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.5)
12
+ public_suffix (>= 2.0.2, < 6.0)
13
+ ast (2.4.2)
14
+ base64 (0.1.1)
15
+ concurrent-ruby (1.2.2)
16
+ crack (0.4.5)
17
+ rexml
18
+ diff-lcs (1.5.0)
19
+ faker (2.23.0)
20
+ i18n (>= 1.8.11, < 2)
21
+ faraday (2.7.11)
22
+ base64
23
+ faraday-net_http (>= 2.0, < 3.1)
24
+ ruby2_keywords (>= 0.0.4)
25
+ faraday-net_http (3.0.2)
26
+ faraday-retry (2.2.0)
27
+ faraday (~> 2.0)
28
+ gitlab (4.19.0)
29
+ httparty (~> 0.20)
30
+ terminal-table (>= 1.5.1)
31
+ hashdiff (1.0.1)
32
+ httparty (0.21.0)
33
+ mini_mime (>= 1.0.0)
34
+ multi_xml (>= 0.5.2)
35
+ i18n (1.14.1)
36
+ concurrent-ruby (~> 1.0)
37
+ json (2.6.3)
38
+ language_server-protocol (3.17.0.3)
39
+ mini_mime (1.1.5)
40
+ mini_portile2 (2.8.4)
41
+ multi_xml (0.6.0)
42
+ mustermann (3.0.0)
43
+ ruby2_keywords (~> 0.0.1)
44
+ net-http (0.3.2)
45
+ uri
46
+ nokogiri (1.15.4)
47
+ mini_portile2 (~> 2.8.2)
48
+ racc (~> 1.4)
49
+ octokit (6.1.1)
50
+ faraday (>= 1, < 3)
51
+ sawyer (~> 0.9)
52
+ parallel (1.23.0)
53
+ parser (3.2.2.3)
54
+ ast (~> 2.4.1)
55
+ racc
56
+ pronto (0.11.1)
57
+ gitlab (>= 4.4.0, < 5.0)
58
+ httparty (>= 0.13.7, < 1.0)
59
+ octokit (>= 4.7.0, < 7.0)
60
+ rainbow (>= 2.2, < 4.0)
61
+ rexml (>= 3.2.5, < 4.0)
62
+ rugged (>= 0.23.0, < 2.0)
63
+ thor (>= 0.20.3, < 2.0)
64
+ pronto-rubocop (0.11.5)
65
+ pronto (~> 0.11.0)
66
+ rubocop (>= 0.63.1, < 2.0)
67
+ public_suffix (5.0.3)
68
+ racc (1.7.1)
69
+ rack (2.2.8)
70
+ rack-protection (3.1.0)
71
+ rack (~> 2.2, >= 2.2.4)
72
+ rainbow (3.1.1)
73
+ rake (13.0.6)
74
+ regexp_parser (2.8.1)
75
+ rexml (3.2.6)
76
+ rspec (3.12.0)
77
+ rspec-core (~> 3.12.0)
78
+ rspec-expectations (~> 3.12.0)
79
+ rspec-mocks (~> 3.12.0)
80
+ rspec-core (3.12.2)
81
+ rspec-support (~> 3.12.0)
82
+ rspec-expectations (3.12.3)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.12.0)
85
+ rspec-mocks (3.12.6)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.12.0)
88
+ rspec-support (3.12.1)
89
+ rubocop (1.56.3)
90
+ base64 (~> 0.1.1)
91
+ json (~> 2.3)
92
+ language_server-protocol (>= 3.17.0)
93
+ parallel (~> 1.10)
94
+ parser (>= 3.2.2.3)
95
+ rainbow (>= 2.2.2, < 4.0)
96
+ regexp_parser (>= 1.8, < 3.0)
97
+ rexml (>= 3.2.5, < 4.0)
98
+ rubocop-ast (>= 1.28.1, < 2.0)
99
+ ruby-progressbar (~> 1.7)
100
+ unicode-display_width (>= 2.4.0, < 3.0)
101
+ rubocop-ast (1.29.0)
102
+ parser (>= 3.2.1.0)
103
+ rubocop-capybara (2.18.0)
104
+ rubocop (~> 1.41)
105
+ rubocop-factory_bot (2.23.1)
106
+ rubocop (~> 1.33)
107
+ rubocop-faker (1.1.0)
108
+ faker (>= 2.12.0)
109
+ rubocop (>= 0.82.0)
110
+ rubocop-rspec (2.24.0)
111
+ rubocop (~> 1.33)
112
+ rubocop-capybara (~> 2.17)
113
+ rubocop-factory_bot (~> 2.22)
114
+ ruby-progressbar (1.13.0)
115
+ ruby2_keywords (0.0.5)
116
+ rugged (1.7.1)
117
+ sawyer (0.9.2)
118
+ addressable (>= 2.3.5)
119
+ faraday (>= 0.17.3, < 3)
120
+ sinatra (3.1.0)
121
+ mustermann (~> 3.0)
122
+ rack (~> 2.2, >= 2.2.4)
123
+ rack-protection (= 3.1.0)
124
+ tilt (~> 2.0)
125
+ terminal-table (3.0.2)
126
+ unicode-display_width (>= 1.1.1, < 3)
127
+ thor (1.2.2)
128
+ tilt (2.3.0)
129
+ unicode-display_width (2.4.2)
130
+ uri (0.12.2)
131
+ webmock (3.19.1)
132
+ addressable (>= 2.8.0)
133
+ crack (>= 0.3.2)
134
+ hashdiff (>= 0.4.0, < 2.0.0)
135
+
136
+ PLATFORMS
137
+ ruby
138
+ x86_64-darwin-21
139
+ x86_64-darwin-22
140
+ x86_64-linux
141
+
142
+ DEPENDENCIES
143
+ bundler
144
+ faker (~> 2.22)
145
+ faraday-retry (~> 2.0)
146
+ genesis_ruby!
147
+ pronto (~> 0.11)
148
+ pronto-rubocop (~> 0.11)
149
+ rake (~> 13.0)
150
+ rspec (~> 3.0)
151
+ rubocop (~> 1.21)
152
+ rubocop-faker (~> 1.1)
153
+ rubocop-rspec (~> 2.13)
154
+ sinatra (~> 3.0)
155
+ webmock (~> 3.18)
156
+
157
+ BUNDLED WITH
158
+ 2.2.33
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Genesis Gateway
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.
data/README.md ADDED
@@ -0,0 +1,343 @@
1
+
2
+ # Genesis Ruby
3
+
4
+ [![Software License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](LICENSE)
5
+
6
+ Ruby Client for Genesis Payment Processing Gateway
7
+
8
+ ## Overview
9
+
10
+ Client Library for processing payments through Genesis Payment Processing Gateway. Its highly recommended to checkout "Genesis Payment Gateway API Documentation" first, in order to get an overview of Genesis's Payment Gateway API and functionality.
11
+
12
+ ## Requirements
13
+
14
+ * Ruby version 2.7 or newer
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'genesis_ruby'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install genesis_ruby
31
+
32
+ ## Getting Started
33
+
34
+ ### Configuration
35
+ ```ruby
36
+ configuration = GenesisRuby::Configuration.new
37
+ configuration.username = '<YOUR USERNAME>'
38
+ configuration.password = '<YOUR PASSWORD>'
39
+ configuration.token = '<YOUR TOKEN>'
40
+ configuration.environment = GenesisRuby::Api::Constants::Environments::STAGING # Support alias strings: 'test', 'testing', 'staging', 'live', 'prod', 'production'
41
+ configuration.endpoint = GenesisRuby::Api::Constants::Endpoints::EMERCHANTPAY # Support alias strings: 'emp', 'emerchantpay', 'ecp', 'ecomprocessing', 'e-comprocessing'
42
+ ```
43
+
44
+ ### Web Payment Form
45
+ ```ruby
46
+ require 'genesis_ruby'
47
+
48
+ begin
49
+ genesis = GenesisRuby::Genesis.for(config: configuration, request: GenesisRuby::Api::Requests::Wpf::Create) do |request|
50
+ # Common Attributes
51
+ request.transaction_id = '12345-67890'
52
+ request.amount = '0.99'
53
+ request.currency = 'EUR'
54
+ request.usage = 'Example usage'
55
+ request.description = 'You are about to complete you purchase'
56
+ request.customer_email = 'travis@example.com'
57
+ request.customer_phone = '+1987987987987'
58
+ request.notification_url = 'https://www.example.com/notification'
59
+ request.return_success_url = 'https://www.example.com/success'
60
+ request.return_cancel_url = 'https://www.example.com/failure'
61
+ request.return_failure_url = 'https://www.example.com/cancel.html'
62
+ request.return_pending_url = 'https://www.example.com/payment-pending.html'
63
+
64
+ # Transaction Types
65
+ request.add_transaction_type('authorize3d')
66
+ # Transaction Type with Customer Attribute
67
+ request.add_transaction_type('sale3d', { bin: '420000' })
68
+
69
+ # Tokenization Attributes
70
+ request.consumer_id = '123456789'
71
+ request.remember_card = true
72
+
73
+ # Billing Attributes
74
+ request.billing_first_name = 'Travis'
75
+ request.billing_last_name = 'Pastrana'
76
+ request.billing_address1 = 'Muster Str. 12'
77
+ request.billing_zip_code = '10178'
78
+ request.billing_city = 'Los Angeles'
79
+ request.billing_state = 'CA'
80
+ request.billing_country = 'US'
81
+
82
+ # Shipping Attributes
83
+ request.shipping_first_name = 'Travis'
84
+ request.shipping_last_name = 'Pastrana'
85
+ request.shipping_address1 = 'Muster Str. 12'
86
+ request.shipping_zip_code = '10178'
87
+ request.shipping_city = 'Los Angeles'
88
+ request.shipping_state = 'CA'
89
+ request.shipping_country = 'US'
90
+
91
+ # Internationalization
92
+ request.locale = 'EN'
93
+
94
+ # Other
95
+ request.lifetime = 30
96
+ request.web_payment_form_id = '987654321'
97
+ end.execute
98
+
99
+ puts genesis.response.response_object
100
+
101
+ rescue GenesisRuby::Error => error
102
+ puts error.message
103
+ end
104
+ ```
105
+
106
+ ### Transactions
107
+
108
+ ```ruby
109
+ require 'genesis_ruby'
110
+
111
+ begin
112
+ genesis = GenesisRuby::Genesis.for(config: configuration, request: GenesisRuby::Api::Requests::Financial::Cards::Sale) do |request|
113
+ # Common Attributes
114
+ request.transaction_id = '12345-67890'
115
+ request.amount = '0.99'
116
+ request.currency = 'EUR'
117
+ request.usage = 'Example usage'
118
+ request.customer_email = 'travis@example.com'
119
+ request.customer_phone = '+1987987987987'
120
+
121
+ # Credit Card Attributes
122
+ request.card_holder = 'Travis Pastrana'
123
+ request.card_number = '4200000000000000'
124
+ request.expiration_month = '12'
125
+ request.expiration_year = '2040'
126
+ request.cvv = '834'
127
+
128
+ # Billing Attributes
129
+ request.billing_first_name = 'Travis'
130
+ request.billing_last_name = 'Pastrana'
131
+ request.billing_address1 = 'Muster Str. 12'
132
+ request.billing_zip_code = '10178'
133
+ request.billing_city = 'Los Angeles'
134
+ request.billing_state = 'CA'
135
+ request.billing_country = 'US'
136
+ end.execute
137
+
138
+ puts genesis.response.response_object
139
+
140
+ rescue GenesisRuby::Error => error
141
+ puts error.message
142
+ end
143
+ ```
144
+
145
+ A full list of the Transaction Types and Custom Attributes can be found [here](https://emerchantpay.github.io/gateway-api-docs/?shell#wpf-transaction-types).
146
+
147
+ ### Recurring
148
+
149
+ A recurring transaction describes a payment where the cardholder’s account is periodically charged for a repeated
150
+ delivery and use of a product or service (subscription, membership fee, etc.) over time. A recurring payment consists of an initial transaction and one or several repeated subsequent transactions.
151
+
152
+ ```ruby
153
+ request.recurring_type = GenesisRuby::Api::Constants::Transactions::Parameters::Recurring::Types::INITIAL
154
+ ```
155
+
156
+ #### Managed Recurring
157
+
158
+ Managed Recurring provides the option to automatically schedule recurring transactions for a specific day and time.
159
+ Managed Recurring is available after additional configuration. More info can be found [here](https://emerchantpay.github.io/gateway-api-docs/?shell#managed-recurring-intro)
160
+
161
+ ```ruby
162
+ request.recurring_type = GenesisRuby::Api::Constants::Transactions::Parameters::Recurring::Types::MANAGED
163
+ ```
164
+
165
+ * <details>
166
+ <summary>Web Payment Form</summary>
167
+
168
+ ```ruby
169
+ request.add_transaction_type(
170
+ 'sale3d',
171
+ {
172
+ managed_recurring: {
173
+ mode: 'automatic',
174
+ interval: 'days',
175
+ first_date: ((Date.today) + 1).strftime('%Y-%d-%m'),
176
+ time_of_day: 1,
177
+ period: 1,
178
+ amount: GenesisRuby::Utils::MoneyFormat.amount_to_exponent('0.99', 'EUR'),
179
+ max_count: 1
180
+ }
181
+ }
182
+ )
183
+ ```
184
+ </details>
185
+
186
+
187
+ ## Response
188
+
189
+ After Request execution (`genesis.execute`) a Response object can be accessed `genesis.response`.
190
+
191
+ The Response contains the original response from the Gateway:
192
+ ```ruby
193
+ genesis.response.response_raw
194
+ ```
195
+
196
+ The Response contains the parsed response from the Gateway:
197
+ ```ruby
198
+ genesis.response.response_object
199
+ ```
200
+
201
+ ### Success Request
202
+
203
+ You receive from the Response Object a Hash collection. The data contains a `:status`.
204
+
205
+
206
+ If the Transaction is Successful the status is one of the following:
207
+ * `new`
208
+ * `approved`
209
+ * `pending_async`
210
+
211
+ <details>
212
+ <summary>Example Successful Transaction Execution</summary>
213
+
214
+ ```ruby
215
+ {:status=>"new",
216
+ :unique_id=>"2993ad9c2dd45ecfa9862b9eaf0ceb29",
217
+ :transaction_id=>"9c8b862b-4f91-478b-8a14-87bffab7e55d",
218
+ :timestamp=>
219
+ #<DateTime: 2023-04-20T12:11:42+00:00 ((2460055j,43902s,0n),+0s,2299161j)>,
220
+ :amount=>"0.99",
221
+ :currency=>"EUR",
222
+ :redirect_url=>
223
+ "https://staging.wpf.emerchantpay.net/ja/v2/payment/2993ad9c2dd45ecfa9862b9eaf0ceb29"}
224
+ ```
225
+ </details>
226
+
227
+ If an error occurs during the Transaction Execution the status is one of the following:
228
+ * `error`
229
+ * `declined`
230
+
231
+ <details>
232
+ <summary>Example Transaction Execution with Error</summary>
233
+
234
+ ```ruby
235
+ {:status=>"error",
236
+ :unique_id=>"fc94d7cdebe5f81618785d1033948fcc",
237
+ :transaction_id=>"8bf4556b-a6ba-4389-a2e8-b7efa9e384b3",
238
+ :code=>"120",
239
+ :technical_message=>
240
+ "Lacking Terminal/MID setups for the currency 'USD' for the requested transaction types",
241
+ :message=>"Transaction failed, please contact support!",
242
+ :timestamp=>
243
+ #<DateTime: 2023-04-20T12:13:52+00:00 ((2460055j,44032s,0n),+0s,2299161j)>,
244
+ :amount=>"0.99",
245
+ :currency=>"USD"}
246
+ ```
247
+ </details>
248
+
249
+ ### Response Helpers
250
+
251
+ #### Sates
252
+
253
+ The Response object has predefined checks for validating the status of the received response.
254
+ Every available status received from the Gateway can be checked in the following way.
255
+
256
+ ```ruby
257
+ genesis.response.new?
258
+ genesis.response.approved?
259
+ genesis.response.declined?
260
+ genesis.response.error?
261
+ ...
262
+ ```
263
+
264
+ #### Formatters
265
+
266
+ By default, the Response Object is formatted. For example, amounts are transformed in major currency format, timestamps in `DateTime`, etc.
267
+ If you want to stop formatting you can do it by defining `format_reponse` in the [Configuration](#Configuration).
268
+
269
+ ```ruby
270
+ configuration.format_response = false
271
+ ```
272
+
273
+ #### Sanitization
274
+
275
+ By default, the Response Object is sanitized, and `<empty/>` values are removed.
276
+ If you want to stop sanitization you can do it by defining `configuration.sanitize_response` in the [Configuration](#Configuration).
277
+
278
+ ```ruby
279
+ configuration.sanitize_response = false
280
+ ```
281
+
282
+ ## Requests
283
+
284
+ You can use the following request classes to initialize the Genesis client:
285
+
286
+ ```ruby
287
+ # Transactions
288
+ ## Cards
289
+ GenesisRuby::Api::Requests::Financial::Cards::Authorize
290
+ GenesisRuby::Api::Requests::Financial::Cards::Authorize3d
291
+ GenesisRuby::Api::Requests::Financial::Cards::Sale
292
+ GenesisRuby::Api::Requests::Financial::Cards::Sale3d
293
+
294
+ # Web Payment Form
295
+ ## Create
296
+ GenesisRuby::Api::Requests::Wpf::Create
297
+ ```
298
+
299
+ ### Manual initialization
300
+
301
+ <details>
302
+ <summary>Manual Client initialization</summary>
303
+
304
+ ```ruby
305
+ require 'genesis_ruby'
306
+
307
+ begin
308
+ request = GenesisRuby::Api::Requests::Wpf::Create.new(configuration)
309
+
310
+ request.transaction_id = '12345-67890'
311
+ request.amount = '0.99'
312
+ request.currency = 'EUR'
313
+ request.usage = 'Example usage'
314
+ request.description = 'You are about to complete you purchase'
315
+ request.customer_email = 'travis@example.com'
316
+ request.customer_phone = '+1987987987987'
317
+ request.notification_url = 'https://www.example.com/notification'
318
+ request.return_success_url = 'https://www.example.com/success'
319
+ request.return_cancel_url = 'https://www.example.com/failure'
320
+ request.return_failure_url = 'https://www.example.com/cancel.html'
321
+ request.return_pending_url = 'https://www.example.com/payment-pending.html'
322
+
323
+ # Transaction Types
324
+ request.add_transaction_type('authorize3d')
325
+
326
+ genesis = GenesisRuby::Genesis.new(configuration, request)
327
+
328
+ puts genesis.execute.response.response_object
329
+
330
+ rescue GenesisRuby::Error => error
331
+ puts error.message
332
+ end
333
+ ```
334
+
335
+ </details>
336
+
337
+ ## Running Specs
338
+
339
+ `rake test`
340
+
341
+ ## Running Linters
342
+
343
+ `rake styles`
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require 'rubocop/rake_task'
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[spec rubocop]
11
+ task test: :spec
12
+ task styles: :rubocop
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,43 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'genesis_ruby/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'genesis_ruby'
7
+ spec.version = GenesisRuby::VERSION
8
+ spec.authors = ['emerchantpay Ltd.']
9
+ spec.email = ['client_integrations@emerchantpay.com']
10
+
11
+ spec.summary = 'Ruby Client for Genesis Payment Processing Gateway'
12
+ spec.homepage = 'https://github.com/GenesisGateway/genesis_ruby'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.7.0'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/GenesisGateway/genesis_ruby'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/GenesisGateway/genesis_ruby/CHANGELOG.md'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(bin|test|spec|features|sig)/|\.(?:git|pronto|rspec|rubocop)})
22
+ end
23
+
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_runtime_dependency 'net-http', '~> 0.3.2'
29
+ spec.add_runtime_dependency 'nokogiri', '~> 1.14'
30
+
31
+ spec.add_development_dependency 'bundler'
32
+ spec.add_development_dependency 'faker', '~> 2.22'
33
+ spec.add_development_dependency 'faraday-retry', '~> 2.0'
34
+ spec.add_development_dependency 'pronto', '~> 0.11'
35
+ spec.add_development_dependency 'pronto-rubocop', '~> 0.11'
36
+ spec.add_development_dependency 'rake', '~> 13.0'
37
+ spec.add_development_dependency 'rspec', '~> 3.0'
38
+ spec.add_development_dependency 'rubocop', '~> 1.21'
39
+ spec.add_development_dependency 'rubocop-faker', '~> 1.1'
40
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.13'
41
+ spec.add_development_dependency 'sinatra', '~> 3.0'
42
+ spec.add_development_dependency 'webmock', '~> 3.18'
43
+ end