solidus-adyen 0.1.2

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.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +26 -0
  3. data/.rubocop.yml +9 -0
  4. data/.rubocop_todo.yml +325 -0
  5. data/Gemfile +9 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +238 -0
  8. data/Rakefile +16 -0
  9. data/app/assets/javascripts/spree/backend/solidus-adyen.js +1 -0
  10. data/app/assets/javascripts/spree/checkout/payment/adyen.js +10 -0
  11. data/app/assets/javascripts/spree/frontend/solidus-adyen.js +1 -0
  12. data/app/assets/stylesheets/spree/backend/solidus-adyen/buttons.scss +15 -0
  13. data/app/assets/stylesheets/spree/backend/solidus-adyen/communication.scss +121 -0
  14. data/app/assets/stylesheets/spree/backend/solidus-adyen/variables.scss +4 -0
  15. data/app/assets/stylesheets/spree/backend/solidus-adyen.css +5 -0
  16. data/app/assets/stylesheets/spree/frontend/solidus-adyen.css +3 -0
  17. data/app/controllers/concerns/spree/adyen/admin/refunds_controller.rb +59 -0
  18. data/app/controllers/spree/adyen/hpps_controller.rb +22 -0
  19. data/app/controllers/spree/adyen_notifications_controller.rb +34 -0
  20. data/app/controllers/spree/adyen_redirect_controller.rb +90 -0
  21. data/app/models/adyen_notification.rb +159 -0
  22. data/app/models/concerns/spree/adyen/order.rb +11 -0
  23. data/app/models/concerns/spree/adyen/payment.rb +95 -0
  24. data/app/models/spree/adyen/hpp_source.rb +101 -0
  25. data/app/models/spree/adyen/notification_processor.rb +102 -0
  26. data/app/models/spree/adyen/presenters/communication.rb +31 -0
  27. data/app/models/spree/adyen/presenters/communications/adyen_notification.rb +26 -0
  28. data/app/models/spree/adyen/presenters/communications/base.rb +50 -0
  29. data/app/models/spree/adyen/presenters/communications/hpp_source.rb +31 -0
  30. data/app/models/spree/adyen/presenters/communications/log_entry.rb +28 -0
  31. data/app/models/spree/adyen/presenters/communications.rb +9 -0
  32. data/app/models/spree/gateway/adyen_hpp.rb +95 -0
  33. data/app/overrides/spree/admin/shared/_order_summary.rb +6 -0
  34. data/app/views/spree/admin/payments/source_forms/_adyen.html.erb +1 -0
  35. data/app/views/spree/admin/payments/source_views/_adyen.html.erb +14 -0
  36. data/app/views/spree/adyen/_manual_refund.html.erb +9 -0
  37. data/app/views/spree/adyen/communication/_communication.html.erb +42 -0
  38. data/app/views/spree/adyen/hpps/directory.html.erb +10 -0
  39. data/app/views/spree/checkout/payment/_adyen.html.erb +33 -0
  40. data/bin/checkout.rb +111 -0
  41. data/bin/regen.sh +1 -0
  42. data/config/initializers/solidus_adyen.rb +1 -0
  43. data/config/locales/en.yml +23 -0
  44. data/config/routes.rb +13 -0
  45. data/db/migrate/20131017040945_create_adyen_notifications.rb +29 -0
  46. data/db/migrate/20150911201942_add_index_adyen_notifications_psp_reference.rb +5 -0
  47. data/db/migrate/20150914162539_create_spree_adyen_hpp_sources.rb +21 -0
  48. data/db/migrate/20151007090519_add_days_to_ship_to_config.rb +5 -0
  49. data/db/migrate/20151020230830_remove_indices_on_adyen_notifications.rb +6 -0
  50. data/db/migrate/20151106093023_allow_merchant_reference_to_be_null_for_adyen_notification.rb +5 -0
  51. data/lib/solidus-adyen.rb +1 -0
  52. data/lib/spree/adyen/engine.rb +32 -0
  53. data/lib/spree/adyen/form.rb +135 -0
  54. data/lib/spree/adyen/hpp_check.rb +11 -0
  55. data/lib/spree/adyen/url.rb +30 -0
  56. data/lib/spree/adyen/version.rb +5 -0
  57. data/lib/spree/adyen.rb +6 -0
  58. data/solidus-adyen.gemspec +51 -0
  59. data/spec/controllers/concerns/spree/adyen/admin/refunds_controller_spec.rb +76 -0
  60. data/spec/controllers/spree/adyen/hpps_controller_spec.rb +43 -0
  61. data/spec/controllers/spree/adyen_notifications_controller_spec.rb +118 -0
  62. data/spec/controllers/spree/adyen_redirect_controller_spec.rb +154 -0
  63. data/spec/factories/active_merchant_billing_response.rb +23 -0
  64. data/spec/factories/adyen_notification.rb +91 -0
  65. data/spec/factories/spree_adyen_hpp_source.rb +15 -0
  66. data/spec/factories/spree_gateway_adyen_hpp.rb +23 -0
  67. data/spec/factories/spree_payment.rb +13 -0
  68. data/spec/lib/spree/adyen/form_spec.rb +214 -0
  69. data/spec/models/adyen_notification_spec.rb +86 -0
  70. data/spec/models/concerns/spree/adyen/order_spec.rb +22 -0
  71. data/spec/models/concerns/spree/adyen/payment_spec.rb +93 -0
  72. data/spec/models/spree/adyen/hpp_source_spec.rb +101 -0
  73. data/spec/models/spree/adyen/notification_processor_spec.rb +205 -0
  74. data/spec/models/spree/adyen/presenters/communication_spec.rb +62 -0
  75. data/spec/models/spree/gateway/adyen_hpp_spec.rb +76 -0
  76. data/spec/spec_helper.rb +65 -0
  77. data/spec/support/shared_contexts/mock_adyen_api.rb +47 -0
  78. metadata +463 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d25ff04beda14b6f6f753c04115a9d76cdc3a647
4
+ data.tar.gz: 5d8805603afd3248f6cd697d4427ef485f97ef91
5
+ SHA512:
6
+ metadata.gz: 315134e5e8c44eb5923a6c7aeb57061879608ab459e149afdeafb11663302f156209fbd51a60ad98151deb98f2ae736e6d646cc47b9d37a804e959d5d98c634c
7
+ data.tar.gz: 2c13cddda66a8387274be8a075c13e82a35c03479f5cd6de6fa98ab357e7d1d07328749fc9d9a84fe8171c647fc61a53ce2847387ac99f79f212089f31a440dc
data/.gitignore ADDED
@@ -0,0 +1,26 @@
1
+ *.rbc
2
+ *.sassc
3
+ .sass-cache
4
+ capybara-*.html
5
+ .rspec
6
+ .rvmrc
7
+ /.bundle
8
+ /vendor/bundle
9
+ /log/*
10
+ /tmp/*
11
+ /db/*.sqlite3
12
+ /public/system/*
13
+ /coverage/
14
+ /spec/tmp/*
15
+ **.orig
16
+ rerun.txt
17
+ pickle-email-*.html
18
+ .project
19
+ config/initializers/secret_token.rb
20
+
21
+ Gemfile.lock
22
+ spec/dummy
23
+ config/credentials.yml
24
+
25
+ spec/cassettes
26
+ spec/examples.txt
data/.rubocop.yml ADDED
@@ -0,0 +1,9 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - "spec/dummy/**/*"
6
+ - "vendor/bundle/**/*"
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,325 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-10-25 21:33:15 -0700 using RuboCop version 0.34.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Offense count: 13
11
+ # Cop supports --auto-correct.
12
+ Lint/UnusedMethodArgument:
13
+ Exclude:
14
+ - 'app/models/spree/gateway/adyen_hpp.rb'
15
+ - 'app/models/spree/gateway/adyen_hpp_bogus.rb'
16
+
17
+ # Offense count: 24
18
+ Metrics/AbcSize:
19
+ Max: 364
20
+
21
+ # Offense count: 1
22
+ # Configuration parameters: CountComments.
23
+ Metrics/ClassLength:
24
+ Max: 412
25
+
26
+ # Offense count: 468
27
+ # Configuration parameters: AllowURI, URISchemes.
28
+ Metrics/LineLength:
29
+ Max: 243
30
+
31
+ # Offense count: 40
32
+ # Configuration parameters: CountComments.
33
+ Metrics/MethodLength:
34
+ Max: 410
35
+
36
+ # Offense count: 4
37
+ # Cop supports --auto-correct.
38
+ # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
39
+ Style/AlignHash:
40
+ Exclude:
41
+ - 'app/models/spree/adyen/hpp_source.rb'
42
+ - 'spec/controllers/spree/adyen_notifications_controller_spec.rb'
43
+ - 'spec/factories/spree_gateway_adyen_hpp.rb'
44
+
45
+ # Offense count: 9
46
+ # Cop supports --auto-correct.
47
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
48
+ Style/AlignParameters:
49
+ Exclude:
50
+ - 'app/models/adyen_notification.rb'
51
+ - 'app/models/spree/adyen/hpp_source.rb'
52
+ - 'app/models/spree/gateway/adyen_hpp_bogus.rb'
53
+ - 'spec/controllers/spree/adyen/hpps_controller_spec.rb'
54
+ - 'spec/models/spree/adyen/hpp_source_spec.rb'
55
+
56
+ # Offense count: 1
57
+ # Cop supports --auto-correct.
58
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
59
+ Style/AndOr:
60
+ Exclude:
61
+ - 'app/controllers/spree/adyen_notifications_controller.rb'
62
+
63
+ # Offense count: 10
64
+ # Cop supports --auto-correct.
65
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
66
+ Style/BlockDelimiters:
67
+ Enabled: false
68
+
69
+ # Offense count: 5
70
+ # Cop supports --auto-correct.
71
+ Style/BlockEndNewline:
72
+ Exclude:
73
+ - 'spec/controllers/spree/adyen/hpps_controller_spec.rb'
74
+ - 'spec/lib/spree/adyen/form_spec.rb'
75
+ - 'spec/models/spree/adyen/hpp_source_spec.rb'
76
+
77
+ # Offense count: 4
78
+ # Cop supports --auto-correct.
79
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
80
+ Style/BracesAroundHashParameters:
81
+ Exclude:
82
+ - 'lib/spree/adyen/form.rb'
83
+ - 'spec/lib/spree/adyen/form_spec.rb'
84
+
85
+ # Offense count: 4
86
+ # Cop supports --auto-correct.
87
+ Style/ColonMethodCall:
88
+ Exclude:
89
+ - 'lib/spree/adyen/form.rb'
90
+ - 'spec/controllers/spree/adyen_notifications_controller_spec.rb'
91
+ - 'spec/lib/spree/adyen/form_spec.rb'
92
+ - 'spec/spec_helper.rb'
93
+
94
+ # Offense count: 6
95
+ # Cop supports --auto-correct.
96
+ # Configuration parameters: Keywords.
97
+ Style/CommentAnnotation:
98
+ Exclude:
99
+ - 'app/controllers/spree/adyen_redirect_controller.rb'
100
+ - 'app/models/adyen_notification.rb'
101
+ - 'app/models/spree/adyen/hpp_source.rb'
102
+ - 'app/models/spree/gateway/adyen_hpp.rb'
103
+ - 'lib/spree/adyen/form.rb'
104
+
105
+ # Offense count: 12
106
+ # Configuration parameters: Exclude.
107
+ Style/Documentation:
108
+ Exclude:
109
+ - 'app/controllers/spree/adyen/hpps_controller.rb'
110
+ - 'app/controllers/spree/adyen_notifications_controller.rb'
111
+ - 'app/controllers/spree/adyen_redirect_controller.rb'
112
+ - 'app/models/spree/adyen/notification_processor.rb'
113
+ - 'bin/checkout.rb'
114
+ - 'db/migrate/20150911201942_add_index_adyen_notifications_psp_reference.rb'
115
+ - 'db/migrate/20151007090519_add_days_to_ship_to_config.rb'
116
+ - 'db/migrate/20151020230830_remove_indices_on_adyen_notifications.rb'
117
+ - 'lib/spree/adyen/engine.rb'
118
+ - 'lib/spree/adyen/form.rb'
119
+ - 'lib/spree/adyen/url.rb'
120
+ - 'lib/spree/adyen/version.rb'
121
+
122
+ # Offense count: 56
123
+ # Cop supports --auto-correct.
124
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
125
+ Style/DotPosition:
126
+ Enabled: false
127
+
128
+ # Offense count: 7
129
+ # Cop supports --auto-correct.
130
+ Style/EmptyLines:
131
+ Exclude:
132
+ - 'solidus-adyen.gemspec'
133
+
134
+ # Offense count: 5
135
+ # Cop supports --auto-correct.
136
+ Style/EmptyLinesAroundAccessModifier:
137
+ Exclude:
138
+ - 'app/controllers/spree/adyen_notifications_controller.rb'
139
+ - 'app/models/spree/adyen/hpp_source.rb'
140
+ - 'lib/spree/adyen/form.rb'
141
+
142
+ # Offense count: 6
143
+ # Cop supports --auto-correct.
144
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
145
+ Style/EmptyLinesAroundBlockBody:
146
+ Exclude:
147
+ - 'spec/factories/spree_gateway_adyen_hpp_bogus.rb'
148
+ - 'spec/lib/spree/adyen/form_spec.rb'
149
+
150
+ # Offense count: 2
151
+ # Cop supports --auto-correct.
152
+ Style/EmptyLiteral:
153
+ Exclude:
154
+ - 'spec/factories/active_merchant_billing_response.rb'
155
+
156
+ # Offense count: 105
157
+ # Cop supports --auto-correct.
158
+ # Configuration parameters: AllowForAlignment.
159
+ Style/ExtraSpacing:
160
+ Exclude:
161
+ - 'spec/lib/spree/adyen/form_spec.rb'
162
+ - 'spec/spec_helper.rb'
163
+
164
+ # Offense count: 1
165
+ # Configuration parameters: Exclude.
166
+ Style/FileName:
167
+ Exclude:
168
+ - 'lib/solidus-adyen.rb'
169
+
170
+ # Offense count: 16
171
+ # Configuration parameters: MinBodyLength.
172
+ Style/GuardClause:
173
+ Enabled: false
174
+
175
+ # Offense count: 347
176
+ # Cop supports --auto-correct.
177
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
178
+ Style/HashSyntax:
179
+ Enabled: false
180
+
181
+ # Offense count: 4
182
+ # Cop supports --auto-correct.
183
+ # Configuration parameters: MaxLineLength.
184
+ Style/IfUnlessModifier:
185
+ Exclude:
186
+ - 'app/controllers/spree/adyen_notifications_controller.rb'
187
+ - 'app/models/spree/adyen/notification_processor.rb'
188
+
189
+ # Offense count: 2
190
+ # Cop supports --auto-correct.
191
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
192
+ Style/IndentationConsistency:
193
+ Exclude:
194
+ - 'spec/lib/spree/adyen/form_spec.rb'
195
+
196
+ # Offense count: 9
197
+ # Cop supports --auto-correct.
198
+ # Configuration parameters: Width.
199
+ Style/IndentationWidth:
200
+ Exclude:
201
+ - 'spec/factories/adyen_notification.rb'
202
+
203
+ # Offense count: 1
204
+ # Cop supports --auto-correct.
205
+ Style/LeadingCommentSpace:
206
+ Exclude:
207
+ - 'app/controllers/spree/adyen_redirect_controller.rb'
208
+
209
+ # Offense count: 20
210
+ # Cop supports --auto-correct.
211
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
212
+ Style/MethodDefParentheses:
213
+ Enabled: false
214
+
215
+ # Offense count: 3
216
+ # Cop supports --auto-correct.
217
+ Style/MultilineBlockLayout:
218
+ Exclude:
219
+ - 'spec/controllers/spree/adyen/hpps_controller_spec.rb'
220
+ - 'spec/lib/spree/adyen/form_spec.rb'
221
+ - 'spec/models/spree/adyen/hpp_source_spec.rb'
222
+
223
+ # Offense count: 7
224
+ # Cop supports --auto-correct.
225
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
226
+ Style/MultilineOperationIndentation:
227
+ Enabled: false
228
+
229
+ # Offense count: 1
230
+ # Cop supports --auto-correct.
231
+ Style/NumericLiterals:
232
+ MinDigits: 15
233
+
234
+ # Offense count: 3
235
+ # Cop supports --auto-correct.
236
+ # Configuration parameters: PreferredDelimiters.
237
+ Style/PercentLiteralDelimiters:
238
+ Exclude:
239
+ - 'spec/models/spree/adyen/hpp_source_spec.rb'
240
+ - 'spec/spec_helper.rb'
241
+
242
+ # Offense count: 1
243
+ # Cop supports --auto-correct.
244
+ # Configuration parameters: AllowMultipleReturnValues.
245
+ Style/RedundantReturn:
246
+ Exclude:
247
+ - 'app/models/spree/adyen/notification_processor.rb'
248
+
249
+ # Offense count: 10
250
+ # Cop supports --auto-correct.
251
+ Style/RedundantSelf:
252
+ Exclude:
253
+ - 'app/models/adyen_notification.rb'
254
+ - 'app/models/spree/adyen/hpp_source.rb'
255
+
256
+ # Offense count: 10
257
+ # Cop supports --auto-correct.
258
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
259
+ Style/SignalException:
260
+ Exclude:
261
+ - 'app/controllers/spree/adyen_redirect_controller.rb'
262
+ - 'app/models/spree/gateway/adyen_hpp_bogus.rb'
263
+ - 'lib/spree/adyen/payment.rb'
264
+
265
+ # Offense count: 2
266
+ # Cop supports --auto-correct.
267
+ # Configuration parameters: AllowIfMethodIsEmpty.
268
+ Style/SingleLineMethods:
269
+ Exclude:
270
+ - 'app/models/spree/gateway/adyen_hpp.rb'
271
+
272
+ # Offense count: 738
273
+ # Cop supports --auto-correct.
274
+ Style/SingleSpaceBeforeFirstArg:
275
+ Enabled: false
276
+
277
+ # Offense count: 30
278
+ # Cop supports --auto-correct.
279
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
280
+ Style/SpaceBeforeBlockBraces:
281
+ Enabled: false
282
+
283
+ # Offense count: 1
284
+ # Cop supports --auto-correct.
285
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
286
+ Style/SpaceInsideBlockBraces:
287
+ Enabled: false
288
+
289
+ # Offense count: 1
290
+ # Cop supports --auto-correct.
291
+ Style/SpaceInsideBrackets:
292
+ Exclude:
293
+ - 'app/models/adyen_notification.rb'
294
+
295
+ # Offense count: 3
296
+ # Cop supports --auto-correct.
297
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
298
+ Style/SpaceInsideHashLiteralBraces:
299
+ Enabled: false
300
+
301
+ # Offense count: 1
302
+ # Cop supports --auto-correct.
303
+ Style/SpecialGlobalVars:
304
+ Exclude:
305
+ - 'solidus-adyen.gemspec'
306
+
307
+ # Offense count: 4
308
+ # Cop supports --auto-correct.
309
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
310
+ Style/TrailingComma:
311
+ Exclude:
312
+ - 'spec/models/adyen_notification_spec.rb'
313
+
314
+ # Offense count: 17
315
+ # Cop supports --auto-correct.
316
+ Style/TrailingWhitespace:
317
+ Exclude:
318
+ - 'db/migrate/20131017040945_create_adyen_notifications.rb'
319
+ - 'spec/controllers/spree/adyen/hpps_controller_spec.rb'
320
+
321
+ # Offense count: 23
322
+ # Cop supports --auto-correct.
323
+ # Configuration parameters: WordRegex.
324
+ Style/WordArray:
325
+ MinSize: 3
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "timecop"
7
+ gem "webmock"
8
+ gem "vcr"
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Washington Luiz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # Solidus-Adyen
2
+ Adds support for Adyen Hosted Payment Page payments to Solidus stores using the
3
+ [Adyen](https://github.com/wvanbergen/adyen/) gem.
4
+
5
+ Due to the way Adyen's payment API works, the payments created using the
6
+ AdyenHPP method's behavior differ significantly from normal payments.
7
+
8
+ Adyen's API is totally asynchronous, Solidus makes a request to modify a
9
+ payment, and some time in the future Adyen responds to a specified endpoint
10
+ with the result of the action. After capture/refund/cancellation the payment
11
+ will move to a `processing` state, and will be change to the new state after the
12
+ notification is received from Adyen.
13
+
14
+ # Installation
15
+ Add this line to your application's Gemfile:
16
+ ```ruby
17
+ gem 'solidus-adyen', github: 'StemboltHQ/solidus-adyen', tag: 'v0.1.1'
18
+ ```
19
+
20
+ Then run:
21
+ ```bash
22
+ $ bundle install
23
+ $ bundle exec rake spree_adyen:install:migrations
24
+ $ bundle exec rake db:migrate
25
+ ```
26
+
27
+ # Usage
28
+
29
+ To integrate with Adyen payments you'll need to request API credentials by
30
+ signing up at Adyen's [website](https://www.adyen.com/).
31
+
32
+ This gem only supports Adyen HPP payment methods. At this time there are no plans
33
+ to support the direct payment methods.
34
+
35
+ A payment method called `AdyenHPP` added to the list of available payment methods
36
+ allowing stores to authorize payments using Adyen Hosted Payments Page solution. This works much
37
+ like paypal and similar services where the customer is redirected to Adyen at
38
+ the payment step, and is redirected back to your store after they have
39
+ completed payment.
40
+
41
+ Please look into the Adyen gem wiki https://github.com/wvanbergen/adyen/wiki and
42
+ Adyen Integration Manual for further info https://www.adyen.com/developers/api/
43
+
44
+ # Configuration
45
+ ## Application Server
46
+ Define two environment variables `$ADYEN_NOTIFY_USER` and `$ADYEN_NOTIFY_PASSWD`
47
+ that are available to the rails server. These will be used Adyen to authenticate
48
+ with the application server when it `POST`'s notifications which will update
49
+ the state of a payment.
50
+
51
+ Obviously these should be kept secret as they will be used to update the state
52
+ of payments.
53
+
54
+ ## Server Communication
55
+ To receive notifications from Adyen about the outcome of payment modifications
56
+ (authorization, capture, refund, cancellation) you will need to configure your merchant
57
+ account with Adyen with the proper url to the
58
+ `Spree::AdyenNotifications#notify` action.
59
+ ```bash
60
+ $ rake routes | grep spree/adyen_notifications#notify
61
+ adyen_notify POST /adyen/notify(.:format) spree/adyen_notifications#notify
62
+ ```
63
+ is the default path for the endpoint.
64
+
65
+ It is worth noting that Adyen will only issue notifications to servers that
66
+ are running on standard HTTP ports, so your rails server must be accessible on
67
+ port 80, 8080, [or some other http-alternative
68
+ port](https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers).
69
+
70
+ Visit [Settings > Server
71
+ Communication](https://ca-test.adyen.com/ca/ca/config/configurethirdparty.shtml)
72
+ and click 'edit & test' for 'Standard Notification', the other notifications
73
+ are not used by this integration and may cause undefined behavior if enabled.
74
+
75
+ Use the following configuration:
76
+
77
+ Field | Value
78
+ ----------------------------|---------------------------------------------------
79
+ URL | http://your.server/adyen/notify *or whatever you have changed the previous path to*
80
+ SSL Version | SSL
81
+ Active | checked
82
+ Service Version | 1
83
+ Method | HTTP POST
84
+ Populate SOAP Action header | unchecked
85
+ User name | $ADYEN_NOTIFY_USER
86
+ Password | $ADYEN_NOTIFY_PASSWD
87
+
88
+ Save your changes and click 'Test Configuration', everything should be successful.
89
+
90
+ If you get errors saying that it was unauthorized you forgot to set the username
91
+ and password environment variables on the server.
92
+
93
+ ## Skin
94
+ A skin defines the look, feel, and behavior of the hosted payment page.
95
+
96
+ To set one up visit [Skins](https://ca-test.adyen.com/ca/ca/skin/skins.shtml)
97
+ and edit an existing skin or create a new one.
98
+
99
+ Fill in
100
+
101
+ field | Test platform | Live platform
102
+ ------------|-----------------------------------------|-------------------------
103
+ HMAC Keys | *some secure key* | *some secure key*
104
+ Result URLs | http://your.site/checkout/payment/adyen | http://your.site/checkout/payment/adyen
105
+
106
+ Write down the values you use for HMAC keys as you'll be using them later when
107
+ your create the payment method.
108
+
109
+ ## AdyenHPP Payment Method
110
+ In the Solidus admin, go to your payment methods and create a new payment method
111
+ using the `Spree::Gateway::AdyenHPP` provider.
112
+
113
+ It is *very* important to note if any of the following values entered have any
114
+ trailing or leading whitespace everything will break.
115
+
116
+ Use the following config
117
+
118
+ Field | Value
119
+ -------------|------------------------------------------------------------------
120
+ Server | test
121
+ Auto Capture | false
122
+ Environment | Development
123
+ Display | Front End
124
+ Active | Yes
125
+
126
+ Fill in `Api username`, `Api password`, `Merchant Account`, `Shared
127
+ Secret`, and `Skin Code` with the values found using the steps below.
128
+
129
+ To find your `Api Username` and `Api password`:
130
+ + Log into your Adyen account
131
+ + Click [Settings > Users](https://ca-test.adyen.com/ca/ca/config/users.shtml)
132
+ from the left hand navigation
133
+ + In the table, change the filter by selecting `System` from the select on
134
+ the left hand side of table header (`Customer` is highlighted by default)
135
+ + Click the linked value in the `Name` column you wish to use.
136
+ + Under the `User Account Details` fieldset the value of `User Name` is
137
+ your `Api Username` and the value of `Password` will be your `Api
138
+ Password`
139
+
140
+ To find your `Merchant Account`:
141
+ + Log into your Adyen account
142
+ + In the top navigation bar beside the magnifying class click on the box that's text
143
+ is the same as your username
144
+ + In the table, under the column called `Account Code` is your `merchant
145
+ account` name
146
+
147
+ To find your `Skin Code` and `Shared Secret`:
148
+ + Log into your Adyen account
149
+ + click [Skins](https://ca-test.adyen.com/ca/ca/skin/skins.shtml) from the left hand nav
150
+ + Click the link under the `skin code` column whose value for the column `valid
151
+ accounts` matches your `Merchant Account`
152
+ + Within the `Skin details` field-set
153
+ + The value for `Skin Code` is the value of text input with the same name
154
+ + The value for `Shared Secret` is the value of text input labeled `HMAC Keys`
155
+
156
+ To verify that your payment method is configured properly:
157
+ + Go to your Solidus store's homepage
158
+ + Add an item to cart
159
+ + Click Check out
160
+ + Enter an Address
161
+ + On the Payment step, select your Adyen payment method, and then 'pay with
162
+ Adyen'
163
+ *if no payment methods show up here check your server logs, you likely don't
164
+ have the payment method configured properly.*
165
+ + You should be redirected to Adyen's portal
166
+ + Congratulations!
167
+
168
+ # HPP Directory Lookup
169
+ This gem supports [adyen directory look ups](https://docs.adyen.com/display/TD/Directory+lookup+-+Skip+HPP).
170
+ The [default checkout view](../master/app/views/spree/checkout/payment/_adyen.html.erb#L10-L13)
171
+ does provide the functionality to asynchronously load the payment methods, but
172
+ if you want to include this feature in your own custom checkout views you can
173
+ follow the instructions below.
174
+
175
+ Include [spree/checkout/payment/adyen.js](../master/app/assets/javascripts/spree/checkout/payment/adyen.js)
176
+ on your checkout page. Add an element that has an id of `adyen-hpp-details` and
177
+ has
178
+
179
+ ```ruby
180
+ data: {
181
+ url: directory_adyen_hpp_path(
182
+ order_id: @order.id,
183
+ payment_method_id: payment_method.id)}
184
+ ```
185
+
186
+ You can also skip using the provided js if you really want to! Important
187
+ thing here is just to make a `get` to `directory_adyen_hpp_path` with the `order_id`
188
+ and `payment_method_id` and then insert the resultant html somewhere in the DOM.
189
+ This will then make the request to adyen to get a list of payment methods that
190
+ are supported and then render the payment links.
191
+
192
+ If you just want to style the list of Adyen payment methods, just override the
193
+ [spree/adyen/hpps/directory](../master/app/views/spree/adyen/hpps/directory.html.erb)
194
+ view. Take a look at the existing version to get an idea of what is available
195
+ in the view.
196
+
197
+ # Testing
198
+ ```bash
199
+ $ bundle exec rake test_app
200
+ $ rspec
201
+ ```
202
+
203
+ # Development
204
+ My prefered method of setting up a sandbox is with
205
+ ```bash
206
+ $ rake test_app
207
+ $ cd spec/dummy
208
+ $ rake railties:install:migrations
209
+ $ rake db:migrate
210
+ $ rake db:seed
211
+ $ rake db:spree_sample:load
212
+ $ ./bin/rails s
213
+ ```
214
+ You will need to reverse tunnel or make your server publicly available by some
215
+ other means - and update the server communication as well as the skin's url
216
+ with the proper end point to receive notifications.
217
+
218
+ # Test Credit Card Info
219
+
220
+ https://support.adyen.com/index.php?/Knowledgebase/Article/View/11/0/test-card-numbers
221
+
222
+ # Terminology and other API information
223
+ [More info about Adyen can be found here](https://docs.adyen.com/display/TD/3D+Secure).
224
+ Includes information about the adyen soap api and the parameters that it accepts.
225
+
226
+ **e.g.**
227
+ > paRequest, md, issuerUrl, resultCode, PaReq, MD, TermUrL, etc.
228
+
229
+ If you find some variable that is not documented in the gem, it's likely
230
+ defined here.
231
+
232
+ # Contributing
233
+
234
+ 1. Fork it
235
+ 2. Create your feature branch (`git checkout -b feature/bug/refactor-thing`)
236
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
237
+ 4. Push to the branch (`git push origin my-new-feature`)
238
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require "rubygems"
2
+ require "rake"
3
+ require "rake/testtask"
4
+ require "rake/packagetask"
5
+ require "rubygems/package_task"
6
+ require "rspec/core"
7
+ require "rspec/core/rake_task"
8
+ require "spree/testing_support/extension_rake"
9
+
10
+ task default: [:spec]
11
+
12
+ desc "Generates a dummy app for testing"
13
+ task :test_app do
14
+ ENV["LIB_NAME"] = "solidus-adyen"
15
+ Rake::Task["extension:test_app"].invoke
16
+ end
@@ -0,0 +1 @@
1
+ //= require spree/backend
@@ -0,0 +1,10 @@
1
+ jQuery(function($) {
2
+ $('#adyen-hpp-details').each(function() {
3
+ node = this;
4
+ url = this.dataset.url;
5
+
6
+ $.get(url, function(data) {
7
+ $(node).html(data);
8
+ });
9
+ });
10
+ });
@@ -0,0 +1 @@
1
+ //= require spree/frontend
@@ -0,0 +1,15 @@
1
+ @import 'variables';
2
+
3
+ .button-error {
4
+ background-color: $color-error;
5
+
6
+ &.fa:before {
7
+ color: $color-warning;
8
+ }
9
+ &:hover {
10
+ background-color: lighten($color-error, 5%);
11
+ }
12
+ &:active {
13
+ background-color: darken($color-error, 5%);
14
+ }
15
+ }