workarea-afterpay 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.gitignore +22 -0
  7. data/CHANGELOG.md +161 -0
  8. data/CODE_OF_CONDUCT.md +3 -0
  9. data/CONTRIBUTING.md +3 -0
  10. data/Gemfile +17 -0
  11. data/LICENSE +52 -0
  12. data/README.md +131 -0
  13. data/Rakefile +60 -0
  14. data/app/assets/fonts/workarea/storefront/raleway/raleway_800.woff +0 -0
  15. data/app/assets/fonts/workarea/storefront/raleway/raleway_800.woff2 +0 -0
  16. data/app/assets/fonts/workarea/storefront/raleway/raleway_regular.woff +0 -0
  17. data/app/assets/fonts/workarea/storefront/raleway/raleway_regular.woff2 +0 -0
  18. data/app/assets/images/workarea/storefront/afterpay/afterpay_logo.png +0 -0
  19. data/app/assets/images/workarea/storefront/afterpay/aus/dialog_header_image.png +0 -0
  20. data/app/assets/images/workarea/storefront/afterpay/aus/step_1.png +0 -0
  21. data/app/assets/images/workarea/storefront/afterpay/aus/step_2.png +0 -0
  22. data/app/assets/images/workarea/storefront/afterpay/aus/step_3.png +0 -0
  23. data/app/assets/images/workarea/storefront/afterpay/us/complete_checkout.svg +1 -0
  24. data/app/assets/images/workarea/storefront/afterpay/us/four_equal_payments.svg +1 -0
  25. data/app/assets/images/workarea/storefront/afterpay/us/select_installments.svg +1 -0
  26. data/app/assets/javascripts/workarea/storefront/afterpay/config.js.erb +17 -0
  27. data/app/assets/javascripts/workarea/storefront/afterpay/modules/afterpay_redirect.js +30 -0
  28. data/app/assets/stylesheets/workarea/storefront/components/_afterpay_dialog.scss +158 -0
  29. data/app/controllers/workarea/admin/afterpay/configurations_controller.rb +33 -0
  30. data/app/controllers/workarea/storefront/afterpay_controller.rb +124 -0
  31. data/app/controllers/workarea/storefront/afterpay_dialog_controller.rb +7 -0
  32. data/app/controllers/workarea/storefront/checkout/place_order_controller.decorator +11 -0
  33. data/app/helpers/workarea/storefront/afterpay_helper.rb +16 -0
  34. data/app/models/workarea/afterpay/configuration.rb +16 -0
  35. data/app/models/workarea/order.decorator +17 -0
  36. data/app/models/workarea/payment/afterpay_payment_gateway.rb +16 -0
  37. data/app/models/workarea/payment/authorize/afterpay.rb +7 -0
  38. data/app/models/workarea/payment/capture/afterpay.rb +35 -0
  39. data/app/models/workarea/payment/purchase/afterpay.rb +7 -0
  40. data/app/models/workarea/payment/refund/afterpay.rb +52 -0
  41. data/app/models/workarea/payment/tender/afterpay.rb +18 -0
  42. data/app/models/workarea/payment.decorator +42 -0
  43. data/app/services/workarea/afterpay/order_builder.rb +107 -0
  44. data/app/view_models/workarea/admin/afterpay_configuration_view_model.rb +36 -0
  45. data/app/view_models/workarea/storefront/afterpay_configuration.rb +25 -0
  46. data/app/view_models/workarea/storefront/afterpay_view_model.rb +89 -0
  47. data/app/view_models/workarea/storefront/cart_view_model.decorator +12 -0
  48. data/app/view_models/workarea/storefront/checkout/payment_view_model.decorator +32 -0
  49. data/app/view_models/workarea/storefront/product_view_model.decorator +50 -0
  50. data/app/views/workarea/admin/afterpay/configurations/edit.html.haml +59 -0
  51. data/app/views/workarea/admin/orders/tenders/_afterpay.html.haml +2 -0
  52. data/app/views/workarea/admin/shared/_afterpay_configuration_link.html.haml +1 -0
  53. data/app/views/workarea/storefront/afterpay_dialog/show.html.haml +40 -0
  54. data/app/views/workarea/storefront/afterpay_dialog/show_aus.html.haml +40 -0
  55. data/app/views/workarea/storefront/carts/_afterpay.html.haml +9 -0
  56. data/app/views/workarea/storefront/checkouts/_afterpay_payment.html.haml +17 -0
  57. data/app/views/workarea/storefront/order_mailer/tenders/_afterpay.html.haml +4 -0
  58. data/app/views/workarea/storefront/order_mailer/tenders/_afterpay.text.erb +1 -0
  59. data/app/views/workarea/storefront/orders/tenders/_afterpay.html.haml +5 -0
  60. data/app/views/workarea/storefront/products/_afterpay_pricing.html.haml +3 -0
  61. data/app/views/workarea/storefront/style_guides/components/_afterpay_dialog.html.haml +92 -0
  62. data/bin/rails +19 -0
  63. data/bin/test +5 -0
  64. data/config/initializers/appends.rb +34 -0
  65. data/config/initializers/workarea.rb +17 -0
  66. data/config/locales/en.yml +107 -0
  67. data/config/routes.rb +15 -0
  68. data/four_equal_paymnets.svg +1 -0
  69. data/lib/workarea/afterpay/bogus_gateway.rb +211 -0
  70. data/lib/workarea/afterpay/engine.rb +14 -0
  71. data/lib/workarea/afterpay/gateway.rb +121 -0
  72. data/lib/workarea/afterpay/response.rb +17 -0
  73. data/lib/workarea/afterpay/version.rb +5 -0
  74. data/lib/workarea/afterpay.rb +59 -0
  75. data/test/dummy/Rakefile +6 -0
  76. data/test/dummy/bin/bundle +3 -0
  77. data/test/dummy/bin/rails +4 -0
  78. data/test/dummy/bin/rake +4 -0
  79. data/test/dummy/bin/setup +30 -0
  80. data/test/dummy/bin/update +26 -0
  81. data/test/dummy/bin/yarn +11 -0
  82. data/test/dummy/config/application.rb +30 -0
  83. data/test/dummy/config/boot.rb +5 -0
  84. data/test/dummy/config/cable.yml +10 -0
  85. data/test/dummy/config/environment.rb +5 -0
  86. data/test/dummy/config/environments/development.rb +51 -0
  87. data/test/dummy/config/environments/production.rb +88 -0
  88. data/test/dummy/config/environments/test.rb +44 -0
  89. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  90. data/test/dummy/config/initializers/assets.rb +14 -0
  91. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  92. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  93. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  94. data/test/dummy/config/initializers/inflections.rb +16 -0
  95. data/test/dummy/config/initializers/mime_types.rb +4 -0
  96. data/test/dummy/config/initializers/new_framework_defaults.rb +18 -0
  97. data/test/dummy/config/initializers/session_store.rb +3 -0
  98. data/test/dummy/config/initializers/workarea.rb +5 -0
  99. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  100. data/test/dummy/config/locales/en.yml +33 -0
  101. data/test/dummy/config/puma.rb +56 -0
  102. data/test/dummy/config/routes.rb +5 -0
  103. data/test/dummy/config/secrets.yml +32 -0
  104. data/test/dummy/config/spring.rb +6 -0
  105. data/test/dummy/config.ru +5 -0
  106. data/test/dummy/db/seeds.rb +2 -0
  107. data/test/dummy/log/.keep +0 -0
  108. data/test/integration/workarea/storefront/afterpay_integration_test.rb +242 -0
  109. data/test/models/workarea/afterpay_order_test.rb +10 -0
  110. data/test/models/workarea/payment/afterpay_payment_integration_test.rb +67 -0
  111. data/test/services/workarea/afterpay/order_builder_test.rb +88 -0
  112. data/test/system/workarea/storefront/afterpay_product_test.rb +51 -0
  113. data/test/system/workarea/storefront/cart_system_test.decorator +83 -0
  114. data/test/system/workarea/storefront/logged_in_checkout_system_test.decorator +10 -0
  115. data/test/teaspoon_env.rb +6 -0
  116. data/test/test_helper.rb +10 -0
  117. data/test/view_models/workarea/storefront/afterpay_view_model_test.rb +100 -0
  118. data/test/view_models/workarea/storefront/product_view_model_afterpay_test.rb +78 -0
  119. data/workarea-afterpay.gemspec +23 -0
  120. metadata +189 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8d3bd7aa8e6ea1b4493b0e2113b397eb349348bb20887cbb630e2ff029d8a375
4
+ data.tar.gz: 7561c865fdeadc280abc3e599349b0613cf288671da66dccf8e9ab0f8b1ffdd2
5
+ SHA512:
6
+ metadata.gz: 10af7c308d5e89221a2568ac1e410b8e34711b94b01f703426eec6d393ad71a4770279a988129d77751c7cbeabc376f81d0b9d50c03277f684bab3dbc8422d70
7
+ data.tar.gz: 9e99889a49616715047e465d9fc59c50d6c242eb0de6af85302b607083105719f5a2eec9601c99dfcd62508461bcdda4c92178869adea771af4780109913a083
data/.editorconfig ADDED
@@ -0,0 +1,20 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ end_of_line = lf
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [{*.rb,*.haml,*.decorator,*.yml,*.yaml,*.jbuilder}]
12
+ indent_size = 2
13
+ indent_style = space
14
+
15
+ [{*.js,*.jst,*.ejs,*.scss}]
16
+ indent_size = 4
17
+
18
+ [*.md]
19
+ indent_size = 4
20
+ trim_trailing_whitespace = false
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve Workarea
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ ⚠️**Before you create**⚠️
11
+ Please verify the issue you're experiencing is not part of your Workarea project customizations. The best way to do this is with a [vanilla Workarea installation](https://developer.workarea.com/articles/create-a-new-host-application.html). This will help us spend time on fixes/improvements for the whole community. Thank you!
12
+
13
+ **Describe the bug**
14
+ A clear and concise description of what the bug is.
15
+
16
+ **To Reproduce**
17
+ Steps to reproduce the behavior:
18
+ 1. Go to '...'
19
+ 2. Click on '....'
20
+ 3. Scroll down to '....'
21
+ 4. See error
22
+
23
+ **Expected behavior**
24
+ A clear and concise description of what you expected to happen.
25
+
26
+ **Workarea Setup (please complete the following information):**
27
+ - Workarea Version: [e.g. v3.4.6]
28
+ - Plugins [e.g. workarea-blog, workarea-sitemaps]
29
+
30
+ **Attachments**
31
+ If applicable, add any attachments to help explain your problem, things like:
32
+ - screenshots
33
+ - Gemfile.lock
34
+ - test cases
35
+
36
+ **Additional context**
37
+ Add any other context about the problem here.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Documentation request
3
+ about: Suggest documentation
4
+ title: ''
5
+ labels: documentation
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your documentation related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm confused by [...]
12
+
13
+ **Describe the article you'd like**
14
+ A clear and concise description of what would be in the documentation article.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for Workarea
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ .DS_Store
9
+ .byebug_history
10
+ .bundle/
11
+ .sass-cache/
12
+ Gemfile.lock
13
+ pkg/
14
+ test/dummy/tmp/
15
+ test/dummy/public/
16
+ log/*.log
17
+ test/dummy/log/*.log
18
+ test/dummy/db/*.sqlite3
19
+ test/dummy/db/*.sqlite3-journal
20
+ node_modules
21
+ package.json
22
+ yarn.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,161 @@
1
+ Workarea Afterpay 2.0.2 (2019-08-21)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Open Source!
5
+
6
+
7
+
8
+ Workarea Afterpay 2.0.1 (2019-06-11)
9
+ --------------------------------------------------------------------------------
10
+
11
+ * Show correct dialog for Australia
12
+
13
+ AFTERPAY-28
14
+ Jeff Yucis
15
+
16
+
17
+
18
+ Workarea Afterpay 2.0.0 (2019-05-28)
19
+ --------------------------------------------------------------------------------
20
+
21
+ * Afterpay 2.0.0
22
+
23
+ no changes from Afterpay v2.0.0.beta.1
24
+ Eric Pigeon
25
+
26
+
27
+
28
+ Workarea Afterpay 2.0.0.beta.1 (2019-05-24)
29
+ --------------------------------------------------------------------------------
30
+
31
+ * Implement afterpay dialog designs
32
+
33
+ * Add styleguide component for US and AUS
34
+ * Add afterpay assets - images and raleway font
35
+ * Add afterpay-dialog Sass component
36
+ * Add afterpay_dialog controller
37
+ * Add views for AUS and US dialogs
38
+ * Update afterpay_helper to use afterpay_dialog routes
39
+ * Remove redundant config
40
+ * Display show more link inline with afterpay info in cart & clean up incomplete class
41
+ * Add Helper in engine, remove decorator for application controller
42
+
43
+ AFTERPAY-20
44
+ Jake Beresford
45
+
46
+ * Integrate with afterpay australia api
47
+
48
+ Contextually switch the api endpoints based on a users location, which
49
+ in derived from their currency. Commit also displays the correct
50
+ terms for the users integration type.
51
+
52
+ AFTERPAY-16
53
+ Jeff Yucis
54
+
55
+ * Remove ID attribute from from_checkout field to prevent duplicate ID errors when installed with Workarea-PayPal
56
+
57
+ AFTERPAY-27
58
+ Jake Beresford
59
+
60
+ * Pass suburb to billing and shipping addresses
61
+
62
+ Split out the billing and shipping address to use the data from
63
+ payment and shipping respectively.
64
+
65
+ AFTERPAY-17
66
+ Jeff Yucis
67
+
68
+ * Pass test flag to gateway when present in secrets.
69
+
70
+ AFTERPAY-18
71
+ Jeff Yucis
72
+
73
+
74
+
75
+ Workarea Afterpay 1.0.2 (2019-03-05)
76
+ --------------------------------------------------------------------------------
77
+
78
+ * Fix casing of Afterpay in translation file
79
+
80
+ AFTERPAY-14
81
+ Jeff Yucis
82
+
83
+
84
+
85
+ Workarea Afterpay 1.0.1 (2019-02-19)
86
+ --------------------------------------------------------------------------------
87
+
88
+ * Auto capture afterpay payments
89
+
90
+ Afterpay recomends performing an auth with immediate capture when
91
+ processing the payment. This allows refunds to be placed via the
92
+ workarea admin.
93
+
94
+ AFTERPAY-12
95
+ Jeff Yucis
96
+
97
+ * Clear credit card tender when adding afterpay
98
+
99
+ AFTERPAY-13
100
+ Jeff Yucis
101
+
102
+
103
+
104
+ Workarea Afterpay 1.0.0 (2018-11-28)
105
+ --------------------------------------------------------------------------------
106
+
107
+ * Check that the order is in an eligible country
108
+
109
+ Commit supresses afterpay from displaying if the currecny is not in a
110
+ supported country.
111
+
112
+ AFTERPAY-8
113
+ Jeff Yucis
114
+
115
+ * Place afterpay orders immediatly upon returning from afterpay
116
+
117
+ AFTERPAY-9
118
+ Jeff Yucis
119
+
120
+
121
+
122
+ Workarea Afterpay 1.0.0.beta.3 (2018-10-23)
123
+ --------------------------------------------------------------------------------
124
+
125
+ * Correct api cache behavior for multisite
126
+
127
+ AFTERPAY-7
128
+ Jeff Yucis
129
+
130
+ * Improve messaging around tenders on order conf, admin and mailers
131
+
132
+ Commit also fixes bug in order balance check for elibility
133
+
134
+ AFTERPAY-6
135
+ Jeff Yucis
136
+
137
+
138
+
139
+ Workarea Afterpay 1.0.0.beta.2 (2018-10-08)
140
+ --------------------------------------------------------------------------------
141
+
142
+ * Allow afterpay to be used with split tender orders.
143
+
144
+ AFTERPAY-5
145
+ Jeff Yucis
146
+
147
+
148
+
149
+ Workarea Afterpay 1.0.0.beta.1 (2018-10-03)
150
+ --------------------------------------------------------------------------------
151
+
152
+ * Add afterpay as payment option
153
+
154
+ Commit allows users to checkout with afterpay. Relevant options are
155
+ displayed if a users order qualifies for afterpay
156
+
157
+ AFTERPAY-3
158
+ Jeff Yucis
159
+
160
+
161
+
@@ -0,0 +1,3 @@
1
+ View this plugin's code of conduct here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CODE_OF_CONDUCT.md>
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ View this plugin's contribution guidelines here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CONTRIBUTING.md>
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "git@github.com:#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in workarea-afterpay.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # To use a debugger
15
+ # gem 'byebug', group: [:development, :test]
16
+
17
+ gem 'workarea'
data/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ WebLinc
2
+ Business Source License
3
+
4
+ Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
5
+
6
+ Licensed Work: Workarea Commerce Platform
7
+ The Licensed Work is (c) 2019 WebLinc Corporation
8
+
9
+ Additional Use Grant:
10
+ You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
11
+
12
+ A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
13
+
14
+ For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
15
+
16
+ Change Date: 2019-08-20
17
+
18
+ Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
19
+
20
+ Terms
21
+
22
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
25
+
26
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
27
+
28
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
29
+
30
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
31
+
32
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
33
+
34
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
35
+
36
+ Covenants of Licensor
37
+ In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
38
+
39
+ To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
40
+
41
+ To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
42
+
43
+ To specify a Change Date.
44
+
45
+ Not to modify this License in any other way.
46
+
47
+ Notice
48
+ The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
49
+
50
+ For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
51
+
52
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
data/README.md ADDED
@@ -0,0 +1,131 @@
1
+ Workarea Afterpay
2
+ ================================================================================
3
+
4
+ Afterpay is a pay-by-installments solution. If a user selects afterpay as a payment
5
+ option they are taken to the afterpay site where they enter their payment details.
6
+ After confirming and placing the order the payment is then captured by the Workarea platform.
7
+
8
+ Both the US and Australian API endpoints are supported in this implementation. See the **Secrets** section for setting up credentials.
9
+ An orders currency code will determine what API endpoints will be used when placing an order. Orders in a non supported currency will not
10
+ have Afterpay as an option when checking out.
11
+
12
+ Refunds are supported in the Workarea Platform.
13
+
14
+ Workarea Afterpay orders use the following flow:
15
+
16
+ 1. An API call is made on the Checkout Payment step to see if the order is eligible for Afterpay.
17
+ 2. If eligible an option for Afterpay is displayed.
18
+ 3. User clicks place order button - an api call is made to get a token.
19
+ 4. If token creation is successful the token is injected into the DOM and the user is redirected to the Afterpay site.
20
+ 5. User enters payment details and submits payment.
21
+ 6. User is taken back to Workarea and payment is captured.
22
+ 7. Order confirmation page is displayed.
23
+
24
+ A diagram of the flow can be found here: https://docs.afterpay.com/us-online-api-v1.html#direct-payment-flow
25
+
26
+ Implementation Notes
27
+ --------------------------------------------------------------------------------
28
+
29
+ **Payment**
30
+
31
+ Afterpay requires that all payments are captured when the order is placed. All Afterpay
32
+ payments will perform a "Purchase" action instead of the default "Authorize"; meaning that Afterpay payments will be "captured" immediately. Other payment tenders will still behave as configured.
33
+
34
+
35
+ **Product Detail Pages**
36
+
37
+ This integration makes use of the ```storefront.product_pricing_details``` append point to display the Afterpay pricing on the product detail page. Some custom PDP templates may not have this append point.
38
+
39
+ If you wish for the Afterpay pricing to appear on your custom PDP template simply add the append point manually by adding the following:
40
+
41
+ ```= append_partials('storefront.product_pricing_details', product: product)```
42
+
43
+
44
+ **Testing**
45
+
46
+ The test API endpoints will be used by default. Production mode can be triggered by setting the ***test*** configuration value in an initializer to ***false***.
47
+
48
+ ```
49
+ config.afterpay.test = false
50
+ ```
51
+
52
+
53
+ **Proxy**
54
+
55
+ Be sure to whitelist the sandbox and production API endpoints to the Proxy in your hosting environment. Workarea environments running Kubernetes can add this via the command line interface tool.
56
+
57
+
58
+ **Certification Process**
59
+
60
+ Afterpay has a rigorous certification process that must be completed before using Afterpay in a production environment. This plugin can not guarantee compliance with this process because most of the certification process is branding and marketing specific and is beyond the scope of this integration.
61
+
62
+ Configuration
63
+ --------------------------------------------------------------------------------
64
+ The display of Afterpay can be controlled via the ***Afterpay Configuration*** control panel in the Workarea Admin.
65
+
66
+ The following can be controlled
67
+ - Global Display: Turn on/off the display on the entire site, including checkout.
68
+ - PDP Display: Turn on/off display on the product detail page.
69
+ - Cart Display: Turn on/off display on the cart page
70
+
71
+
72
+ Secrets
73
+ --------------------------------------------------------------------------------
74
+
75
+ The regional US and Australian API endpoints require separate credentials. You can omit regions that are not relevant to your business needs.
76
+
77
+ afterpay:
78
+ us:
79
+ merchant_id: YOUR_US_MERCHANT_ID
80
+ secret_key: YOUR_US_SECRET_KEY
81
+ au:
82
+ merchant_id: YOUR_AU_MERCHANT_ID
83
+ secret_key: YOUR_AU_SECRET_KEY
84
+
85
+
86
+ Getting Started
87
+ --------------------------------------------------------------------------------
88
+
89
+ This gem contains a rails engine that must be mounted onto a host Rails application.
90
+
91
+ To access Workarea gems and source code, you must be an employee of WebLinc or a licensed retailer or partner.
92
+
93
+ Workarea gems are hosted privately at https://gems.weblinc.com/.
94
+ You must have individual or team credentials to install gems from this server. Add your gems server credentials to Bundler:
95
+
96
+ bundle config gems.weblinc.com my_username:my_password
97
+
98
+ Or set the appropriate environment variable in a shell startup file:
99
+
100
+ export BUNDLE_GEMS__WEBLINC__COM='my_username:my_password'
101
+
102
+ Then add the gem to your application's Gemfile specifying the source:
103
+
104
+ # ...
105
+ gem 'workarea-afterpay', source: 'https://gems.weblinc.com'
106
+ # ...
107
+
108
+ Or use a source block:
109
+
110
+ # ...
111
+ source 'https://gems.weblinc.com' do
112
+ gem 'workarea-afterpay'
113
+ end
114
+ # ...
115
+
116
+ Update your application's bundle.
117
+
118
+ cd path/to/application
119
+ bundle
120
+
121
+ Workarea Platform Documentation
122
+ --------------------------------------------------------------------------------
123
+
124
+ See [http://developer.workarea.com](http://developer.workarea.com) for Workarea platform documentation.
125
+
126
+ Copyright & Licensing
127
+ --------------------------------------------------------------------------------
128
+
129
+ Copyright WebLinc 2018. All rights reserved.
130
+
131
+ For licensing, contact sales@workarea.com.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+ RDoc::Task.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = 'rdoc'
10
+ rdoc.title = 'Workarea Afterpay'
11
+ rdoc.options << '--line-numbers'
12
+ rdoc.rdoc_files.include('README.md')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ load 'rails/tasks/engine.rake'
18
+ load 'rails/tasks/statistics.rake'
19
+ load 'workarea/changelog.rake'
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'lib'
24
+ t.libs << 'test'
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = false
27
+ end
28
+ task default: :test
29
+
30
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
31
+ require 'workarea/afterpay/version'
32
+
33
+ desc "Release version #{Workarea::Afterpay::VERSION} of the gem"
34
+ task :release do
35
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
36
+
37
+ #Rake::Task['workarea:changelog'].execute
38
+ #system 'git add CHANGELOG.md'
39
+ #system 'git commit -m "Update CHANGELOG"'
40
+ #system 'git push origin HEAD'
41
+
42
+ system "git tag -a v#{Workarea::Afterpay::VERSION} -m 'Tagging #{Workarea::Afterpay::VERSION}'"
43
+ system 'git push --tags'
44
+
45
+ system "gem build workarea-afterpay.gemspec"
46
+ system "gem push workarea-afterpay-#{Workarea::Afterpay::VERSION}.gem"
47
+ system "gem push workarea-afterpay-#{Workarea::Afterpay::VERSION}.gem --host #{host}"
48
+ system "rm workarea-afterpay-#{Workarea::Afterpay::VERSION}.gem"
49
+ end
50
+
51
+ desc 'Run the JavaScript tests'
52
+ ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
53
+ task teaspoon: 'app:teaspoon'
54
+
55
+ desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
56
+ task :teaspoon_server do
57
+ Dir.chdir("test/dummy")
58
+ teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
59
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
60
+ end
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 109 109"><defs><style>.a{fill:#f4f4f4;}.b{fill:#fff;}.b,.c{stroke:#717171;}.c{fill:none;}</style></defs><g transform="translate(-8218 -290)"><circle class="a" cx="54.5" cy="54.5" r="54.5" transform="translate(8218 290)"/><path class="b" d="M8272.5,315.413l-30.432,11.819v33.6l30.432,12.537,29.41-12.537v-33.6Z"/><path class="c" d="M8242.068,327.351l30.409,12.009,29.257-12.009"/><path class="c" d="M8296.955,342.033l-13.146,6.259v14.743l13.146-5.817Z"/><path class="c" d="M8281.6,319.1l-28.191,12.849v16.631l7.233,3.292V334.714l28.837-12.337Z"/><path class="c" d="M8272.5,339.359v34.007"/></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 109 109"><defs><style>.three-a{fill:#f4f4f4;}.three-b{fill:#fff;stroke:#717171;}.three-c,.g{fill:#717171;}.three-c{font-size:14px;font-family:ProximaNova-Bold, Proxima Nova;font-weight:700;}.three-d,.three-f{fill:none;}.three-e,.three-g{stroke:none;}</style></defs><g transform="translate(-8208 -438)"><circle class="three-a" cx="54.5" cy="54.5" r="54.5" transform="translate(8208 438)"/><g class="three-b" transform="translate(8235 483)"><rect class="three-e" width="63" height="28"/><rect class="three-f" x="0.5" y="0.5" width="62" height="27"/></g><g class="three-b" transform="translate(8231 479)"><rect class="three-e" width="63" height="28"/><rect class="three-f" x="0.5" y="0.5" width="62" height="27"/></g><g class="three-b" transform="translate(8227 474)"><rect class="three-e" width="63" height="28"/><rect class="three-f" x="0.5" y="0.5" width="62" height="27"/></g><text class="three-c" transform="translate(8254 492)"><tspan x="0" y="0">$</tspan></text><g class="three-d" transform="translate(8217 474)"><path class="three-e" d="M10,28V18A10,10,0,0,1,20,28Z"/><path class="three-g" d="M 18.94461059570312 26.99990081787109 C 18.48200225830078 22.83473587036133 15.16506290435791 19.51779747009277 10.99989891052246 19.05518913269043 L 10.99989891052246 26.99990081787109 L 18.94461059570312 26.99990081787109 M 19.99979972839355 27.99990081787109 L 9.999898910522461 27.99990081787109 L 9.999898910522461 18 C 15.5231990814209 18 19.99979972839355 22.47750091552734 19.99979972839355 27.99990081787109 Z"/></g><g class="three-d" transform="translate(8227 474)"><path class="three-e" d="M53,28A10,10,0,0,1,63,18V28Z"/><path class="three-g" d="M 62.00000381469727 26.99990081787109 L 62.00000381469727 19.05518913269043 C 57.8348388671875 19.51779747009277 54.51790237426758 22.83473587036133 54.05529403686523 26.99990081787109 L 62.00000381469727 26.99990081787109 M 63.00000381469727 27.99990081787109 L 53.00010299682617 27.99990081787109 C 53.00010299682617 22.47750091552734 57.47760391235352 18 63.00000381469727 18 L 63.00000381469727 27.99990081787109 Z"/></g><g class="three-d" transform="translate(8227 464)"><path class="three-e" d="M53,10H63V20A10,10,0,0,1,53,10Z"/><path class="three-g" d="M 62.00000381469727 18.94461059570312 L 62.00000381469727 10.99989891052246 L 54.05529403686523 10.99989891052246 C 54.51790237426758 15.16506290435791 57.8348388671875 18.48200225830078 62.00000381469727 18.94461059570312 M 63.00000381469727 19.99979972839355 C 57.47760391235352 19.99979972839355 53.00010299682617 15.5231990814209 53.00010299682617 9.999898910522461 L 63.00000381469727 9.999898910522461 L 63.00000381469727 19.99979972839355 Z"/></g><g class="three-d" transform="translate(8217 464)"><path class="three-e" d="M10,20V10H20A10,10,0,0,1,10,20Z"/><path class="three-g" d="M 10.99989891052246 18.94461059570312 C 15.16506290435791 18.48200225830078 18.48200225830078 15.16506290435791 18.94461059570312 10.99989891052246 L 10.99989891052246 10.99989891052246 L 10.99989891052246 18.94461059570312 M 9.999898910522461 19.99979972839355 L 9.999898910522461 9.999898910522461 L 19.99979972839355 9.999898910522461 C 19.99979972839355 15.5231990814209 15.5231990814209 19.99979972839355 9.999898910522461 19.99979972839355 Z"/></g></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 109 109"><defs><style>.a{fill:#f4f4f4;}.one-b,.c{fill:#fff;}.one-b{stroke:#717171;}.one-d,.f{stroke:none;}.one-e{fill:none;}.f{fill:#717171;}</style></defs><g transform="translate(-8224 -119)"><circle class="a" cx="54.5" cy="54.5" r="54.5" transform="translate(8224 119)"/><g class="one-b" transform="translate(8249 144)"><circle class="one-d" cx="29.5" cy="29.5" r="29.5"/><circle class="one-e" cx="29.5" cy="29.5" r="29"/></g><g class="c" transform="translate(8249 144)"><path class="one-d" d="M 29.50020217895508 58.50040054321289 C 26.13094139099121 58.50040054321289 22.83016204833984 57.92802810668945 19.68954277038574 56.79919815063477 C 16.72932052612305 55.73520660400391 13.97559642791748 54.20188522338867 11.50117301940918 52.24020767211914 C 11.52944183349609 49.48311233520508 12.00914573669434 46.80937576293945 12.9280424118042 44.28916931152344 C 13.83994197845459 41.78813934326172 15.14359188079834 39.54315948486328 16.80277252197266 37.61660003662109 C 18.45733261108398 35.69540023803711 20.38190269470215 34.18795013427734 22.52303123474121 33.13613891601562 C 24.73362159729004 32.05020904541016 27.08108139038086 31.49959945678711 29.50020217895508 31.49959945678711 C 31.91910171508789 31.49959945678711 34.26637268066406 32.05022811889648 36.47683334350586 33.13619995117188 C 38.61784362792969 34.18804931640625 40.54233169555664 35.69554138183594 42.19683074951172 37.61679077148438 C 43.85597229003906 39.54341888427734 45.15958023071289 41.78844833374023 46.07147216796875 44.28950881958008 C 46.99036026000977 46.80977249145508 47.47006225585938 49.48350143432617 47.49832916259766 52.2405891418457 C 45.02389907836914 54.20187759399414 42.27020263671875 55.73498916625977 39.30999374389648 56.79901885986328 C 36.16913223266602 57.92797088623047 32.8686408996582 58.50040054321289 29.50020217895508 58.50040054321289 Z"/><path class="f" d="M 29.50020217895508 58.00040054321289 C 32.81082153320312 58.00040054321289 36.05441284179688 57.43788909912109 39.14086151123047 56.3284912109375 C 41.97302627563477 55.31048583984375 44.61298370361328 53.85541152954102 46.99462509155273 52.00049209594727 C 46.94181060791016 49.38697814941406 46.47385787963867 46.85282897949219 45.60172271728516 44.46078109741211 C 44.71059036254883 42.01665115356445 43.43755340576172 39.82376861572266 41.81796264648438 37.94306182861328 C 38.51740264892578 34.11035919189453 34.14286041259766 31.99959945678711 29.50020217895508 31.99959945678711 C 24.85711288452148 31.99959945678711 20.48229217529297 34.11029815673828 17.18164253234863 37.94287872314453 C 15.56200218200684 39.82352828979492 14.28893184661865 42.01634979248047 13.39779186248779 44.46044158935547 C 12.52564525604248 46.85244369506836 12.05769157409668 49.38662338256836 12.00487995147705 52.00014114379883 C 14.38649940490723 53.85541915893555 17.02651786804199 55.31071472167969 19.85866165161133 56.32867050170898 C 22.94487190246582 57.43795013427734 26.18875122070312 58.00040054321289 29.50020217895508 58.00040054321289 M 29.50020217895508 59.00040054321289 C 22.49446296691895 59.00040054321289 16.05997276306152 56.55889129638672 10.99985218048096 52.47956085205078 C 11.00895214080811 40.61484909057617 19.28811264038086 30.99959945678711 29.50020217895508 30.99959945678711 C 39.71139144897461 30.99959945678711 47.99055099487305 40.61526107788086 47.99965286254883 52.4799690246582 C 42.93979263305664 56.55826187133789 36.50456237792969 59.00040054321289 29.50020217895508 59.00040054321289 Z"/></g><g class="one-b" transform="translate(8267 157)"><circle class="one-d" cx="11.5" cy="11.5" r="11.5"/><circle class="one-e" cx="11.5" cy="11.5" r="11"/></g><g class="one-b" transform="translate(8292 150)"><circle class="one-d" cx="10.5" cy="10.5" r="10.5"/><circle class="one-e" cx="10.5" cy="10.5" r="10"/></g><g class="one-b" transform="translate(8302 156)"><rect width="1" height="9"/><rect class="one-e" x="0.5" y="0.5" height="8"/></g><g class="one-b" transform="translate(8298 161) rotate(-90)"><rect width="1" height="9"/><rect class="one-e" x="0.5" y="0.5" height="8"/></g></g></svg>
@@ -0,0 +1,17 @@
1
+ (function () {
2
+ 'use strict';
3
+
4
+ /**
5
+ * Config Variables
6
+ */
7
+
8
+ WORKAREA.config.afterpay = {
9
+ afterpayScript: function() {
10
+ if('<%= Workarea::Afterpay.test? %>' == 'true') {
11
+ return 'https://portal.sandbox.afterpay.com/afterpay-async.js';
12
+ } else {
13
+ return 'https://portal.afterpay.com/afterpay-async.js';
14
+ }
15
+ }()
16
+ }
17
+ }());
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @namespace WORKAREA.afterpayRedirect
3
+ */
4
+ WORKAREA.registerModule('afterpayRedirect', (function () {
5
+ 'use strict';
6
+
7
+ var redirectToAfterpay = function(token, country){
8
+ window.AfterPay.initialize({countryCode: country});
9
+ window.AfterPay.redirect({token: token});
10
+ },
11
+
12
+ getAfterpay = function(token, country) {
13
+ $.getScript(WORKAREA.config.afterpay.afterpayScript, _.partial(redirectToAfterpay, token, country));
14
+ },
15
+
16
+
17
+ init = function ($scope) {
18
+ var $afterpayMethod = $('[data-afterpay-token]', $scope),
19
+ token = $afterpayMethod.data('afterpayToken'),
20
+ country = $afterpayMethod.data('afterpayCountry');
21
+
22
+ if (_.isEmpty(token)) { return; }
23
+
24
+ getAfterpay(token, country);
25
+ };
26
+
27
+ return {
28
+ init: init
29
+ };
30
+ }()));