workarea-paypal 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintignore +2 -0
  4. data/.eslintrc +24 -0
  5. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  6. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  7. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  8. data/.gitignore +19 -0
  9. data/.rspec +2 -0
  10. data/.scss-lint.yml +188 -0
  11. data/.yardopts +1 -0
  12. data/CHANGELOG.md +314 -0
  13. data/CODE_OF_CONDUCT.md +3 -0
  14. data/CONTRIBUTING.md +3 -0
  15. data/Gemfile +6 -0
  16. data/LICENSE +52 -0
  17. data/README.md +47 -0
  18. data/Rakefile +54 -0
  19. data/app/assets/images/workarea/admin/payment_icons/paypal.svg +1 -0
  20. data/app/assets/images/workarea/storefront/payment_icons/paypal.svg +1 -0
  21. data/app/assets/javascripts/workarea/storefront/paypal/modules/update_checkout_submit_text.js +60 -0
  22. data/app/controllers/workarea/storefront/checkout/place_order_controller.decorator +13 -0
  23. data/app/controllers/workarea/storefront/paypal_controller.rb +51 -0
  24. data/app/models/workarea/payment.decorator +27 -0
  25. data/app/models/workarea/payment/authorize/paypal.rb +31 -0
  26. data/app/models/workarea/payment/capture/paypal.rb +35 -0
  27. data/app/models/workarea/payment/purchase/paypal.rb +31 -0
  28. data/app/models/workarea/payment/refund/paypal.rb +26 -0
  29. data/app/models/workarea/payment/tender/paypal.rb +11 -0
  30. data/app/models/workarea/search/order_text.decorator +8 -0
  31. data/app/services/workarea/paypal/setup.rb +114 -0
  32. data/app/services/workarea/paypal/update.rb +69 -0
  33. data/app/view_models/workarea/admin/paypal_view_model.rb +6 -0
  34. data/app/view_models/workarea/store_front/checkout/payment_view_model.decorator +18 -0
  35. data/app/view_models/workarea/store_front/credit_card_view_model.decorator +7 -0
  36. data/app/view_models/workarea/store_front/paypal_view_model.rb +6 -0
  37. data/app/views/workarea/admin/orders/tenders/_paypal.html.haml +2 -0
  38. data/app/views/workarea/api/orders/tenders/_paypal.json.jbuilder +3 -0
  39. data/app/views/workarea/storefront/carts/_paypal_checkout.html.haml +1 -0
  40. data/app/views/workarea/storefront/checkouts/_paypal_error.html.haml +6 -0
  41. data/app/views/workarea/storefront/checkouts/_paypal_payment.html.haml +12 -0
  42. data/app/views/workarea/storefront/order_mailer/tenders/_paypal.html.haml +3 -0
  43. data/app/views/workarea/storefront/order_mailer/tenders/_paypal.text.haml +2 -0
  44. data/app/views/workarea/storefront/orders/tenders/_paypal.html.haml +2 -0
  45. data/bin/rails +17 -0
  46. data/config/initializers/append_points.rb +19 -0
  47. data/config/initializers/workarea.rb +7 -0
  48. data/config/locales/en.yml +19 -0
  49. data/config/routes.rb +4 -0
  50. data/lib/workarea/paypal.rb +34 -0
  51. data/lib/workarea/paypal/engine.rb +8 -0
  52. data/lib/workarea/paypal/version.rb +5 -0
  53. data/test/dummy/Rakefile +6 -0
  54. data/test/dummy/app/assets/config/manifest.js +4 -0
  55. data/test/dummy/app/assets/javascripts/application.js +13 -0
  56. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  57. data/test/dummy/app/controllers/application_controller.rb +3 -0
  58. data/test/dummy/app/helpers/application_helper.rb +2 -0
  59. data/test/dummy/app/jobs/application_job.rb +2 -0
  60. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  61. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  62. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  63. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  64. data/test/dummy/bin/bundle +3 -0
  65. data/test/dummy/bin/rails +4 -0
  66. data/test/dummy/bin/rake +4 -0
  67. data/test/dummy/bin/setup +34 -0
  68. data/test/dummy/bin/update +29 -0
  69. data/test/dummy/config.ru +5 -0
  70. data/test/dummy/config/application.rb +24 -0
  71. data/test/dummy/config/boot.rb +5 -0
  72. data/test/dummy/config/cable.yml +9 -0
  73. data/test/dummy/config/environment.rb +5 -0
  74. data/test/dummy/config/environments/development.rb +54 -0
  75. data/test/dummy/config/environments/production.rb +86 -0
  76. data/test/dummy/config/environments/test.rb +43 -0
  77. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  78. data/test/dummy/config/initializers/assets.rb +11 -0
  79. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  80. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  81. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  82. data/test/dummy/config/initializers/inflections.rb +16 -0
  83. data/test/dummy/config/initializers/mime_types.rb +4 -0
  84. data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
  85. data/test/dummy/config/initializers/session_store.rb +3 -0
  86. data/test/dummy/config/initializers/workarea.rb +5 -0
  87. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  88. data/test/dummy/config/locales/en.yml +23 -0
  89. data/test/dummy/config/puma.rb +47 -0
  90. data/test/dummy/config/routes.rb +5 -0
  91. data/test/dummy/config/secrets.yml +22 -0
  92. data/test/dummy/config/spring.rb +6 -0
  93. data/test/dummy/db/seeds.rb +2 -0
  94. data/test/dummy/log/.keep +0 -0
  95. data/test/dummy/public/404.html +67 -0
  96. data/test/dummy/public/422.html +67 -0
  97. data/test/dummy/public/500.html +66 -0
  98. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  99. data/test/dummy/public/apple-touch-icon.png +0 -0
  100. data/test/dummy/public/favicon.ico +0 -0
  101. data/test/integration/workarea/storefront/paypal_integration_test.rb +345 -0
  102. data/test/integration/workarea/storefront/place_order_integration_test.decorator +11 -0
  103. data/test/models/workarea/payment/authorize/paypal_test.rb +94 -0
  104. data/test/models/workarea/payment/capture/paypal_test.rb +69 -0
  105. data/test/models/workarea/payment/purchase/paypal_test.rb +94 -0
  106. data/test/models/workarea/payment/refund/paypal_test.rb +69 -0
  107. data/test/models/workarea/payment_test.decorator +34 -0
  108. data/test/models/workarea/search/admin/order_test.decorator +32 -0
  109. data/test/services/workarea/paypal/setup_test.rb +120 -0
  110. data/test/services/workarea/paypal/update_test.rb +221 -0
  111. data/test/system/workarea/storefront/cart_system_test.decorator +14 -0
  112. data/test/system/workarea/storefront/logged_in_checkout_system_test.decorator +9 -0
  113. data/test/test_helper.rb +10 -0
  114. data/workarea-paypal.gemspec +21 -0
  115. metadata +170 -0
@@ -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>
@@ -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,6 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "git@github.com:#{repo}.git" }
3
+
4
+ gemspec
5
+
6
+ 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.
@@ -0,0 +1,47 @@
1
+ Workarea PayPal
2
+ ================================================================================
3
+
4
+ A Workarea Commerce plugin that adds support for PayPal payments. This plugin adds a new tender type in checkout, which allows users to pay for their items with PayPal.
5
+
6
+ Getting Started
7
+ --------------------------------------------------------------------------------
8
+
9
+ Add the gem to your application's Gemfile:
10
+
11
+ ```ruby
12
+ # ...
13
+ gem 'workarea-paypal'
14
+ # ...
15
+ ```
16
+
17
+ Update your application's bundle.
18
+
19
+ ```bash
20
+ cd path/to/application
21
+ bundle
22
+ ```
23
+
24
+ Then, configure your secrets.
25
+
26
+ ```yaml
27
+ paypal:
28
+ login:
29
+ password:
30
+ signature:
31
+ ```
32
+
33
+ These credentials will be sent to you by your client, who should have a PayPal merchant account set up already. If not, or you wish to develop locally, [sign up for a sandbox account](https://developer.paypal.com/developer/accounts/).
34
+
35
+ ## International Addresses
36
+
37
+ When working with international addresses, the data from PayPal regarding country and region codes is not guaranteed to match the identifiers used in Workarea (derived from our usage of the [countries](https://github.com/hexorx/countries) gem), because the 2-digit codes identifying countries and regions are not the same. Therefore, you may have some issues when accepting international payments through PayPal, and thus some changes will need to be applied to ensure a seamless checkout process for international PayPal users.
38
+
39
+ Workarea Commerce Documentation
40
+ --------------------------------------------------------------------------------
41
+
42
+ See [https://developer.workarea.com](https://developer.workarea.com) for Workarea Commerce documentation.
43
+
44
+ License
45
+ --------------------------------------------------------------------------------
46
+
47
+ Workarea Paypal is released under the [Business Software License](LICENSE)
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ require 'rdoc/task'
9
+
10
+ RDoc::Task.new(:rdoc) do |rdoc|
11
+ rdoc.rdoc_dir = 'rdoc'
12
+ rdoc.title = 'Workarea3 Plugin'
13
+ rdoc.options << '--line-numbers'
14
+ rdoc.rdoc_files.include('README.md')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
17
+
18
+ APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
19
+ load 'rails/tasks/engine.rake'
20
+ load 'rails/tasks/statistics.rake'
21
+ load 'workarea/changelog.rake'
22
+
23
+ require 'rake/testtask'
24
+
25
+ Rake::TestTask.new(:test) do |t|
26
+ t.libs << 'lib'
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+
33
+ task default: :test
34
+
35
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
36
+ require 'workarea/paypal/version'
37
+
38
+ desc "Release version #{Workarea::Paypal::VERSION} of the gem"
39
+ task :release do
40
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
41
+
42
+ #Rake::Task['workarea:changelog'].execute
43
+ #system 'git add CHANGELOG.md'
44
+ #system 'git commit -m "Update CHANGELOG"'
45
+ #system 'git push origin HEAD'
46
+
47
+ system "git tag -a v#{Workarea::Paypal::VERSION} -m 'Tagging #{Workarea::Paypal::VERSION}'"
48
+ system 'git push --tags'
49
+
50
+ system 'gem build workarea-paypal.gemspec'
51
+ system "gem push workarea-paypal-#{Workarea::Paypal::VERSION}.gem"
52
+ system "gem push workarea-paypal-#{Workarea::Paypal::VERSION}.gem --host #{host}"
53
+ system "rm workarea-paypal-#{Workarea::Paypal::VERSION}.gem"
54
+ end
@@ -0,0 +1 @@
1
+ <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 106 68"><title>paypal</title><g id="jXowej.tif"><image id="Layer_0" data-name="Layer 0" width="106" height="68" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGoAAABECAYAAABph6DRAAAACXBIWXMAAAsSAAALEgHS3X78AAANdUlEQVR4Xu2cCXiM5xbHX6pXe9tSl2rtRcRSJbcEF9fTaumiDy3tvV0u2tLFflUsDSGWSFSIJbFESEkFKUIkdpUSe4ooIfsyyWRfRvb1f8/53iAZYUJ7J/PpnOc5mZkvM983z/ebc87/Pe/7fSI4OBhmN30X/Mdspm1mUCoxMyiVmBmUSswMSiVmBqUSUyWovIJiHD0Tix0HbsDncFiN3C8wAsfOxeFaVAZSM/OQX1hi6DAmZaoE5eR5AXUsF0O0nA/RflHNvIMDREdHPNVnBfp96oVZzsdx5ooWeSoBpjpQZWXl6PmJF0TrBRBdHCFecqqZd6nwDgS4FQFuaoe/WDlj5vJAZOgKDB221k11oFIy8tBuyHqIdhQlLy95OO/G/j1E24UQz8/FKNsAFBSZdmSpDtTl8FQ0G7BapjNDQAx5d4LVfiHqd1wMd98rhg5dq6Y6UHtOROFvPZdBWPwBoNhfIm9pj94jt6KktMzQ4WvNVAfK1ecSnuSTy+KgWzUnvuv3Mq09iFPNaj94LWKSdIYOX2umOlA2K35BHUpVgv1ekLrW0Pm9Ly+FaLMQL77qhhBKq6ZqqgM1ZPJuEhILpeLTB8UR1tGOom0m+Xf38Vny0XI2RKd5EC3s0GGQG+I1mYYOX2umKlA85ukyfJNUayy5q0Ci6OhCkr31eKo5X5N/Y9hbsY+DaDQWz/d3wq4bWYa+Qq2ZqkBFanRoTb98JaLuEgZLZYQwqNYTau6t6P1NPoewJshbErBDU2zoa9SKqQpU4K8aNO3tcm9QFrPkiTcEp7K3oKhq9hXE+xsgNqZAeCXgWpbpjalUBWqz/1U8zWMflub6io9TXzubBwf1wpcQL06CmH0CwjsDYlUUJpw2vRSoKlCLPM7gsU4kIiyrk+ZUs9pOxYOlPk57X0D0pgj1TID4Q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QqqIBT0Xjrs2149/NtOEIp7l7G98+zW3UCPUg8dBi8Fp/N2gfPPb/hi9kBeHu0Nw4GRRFkeZY4ooZO2qVc4FaP6l5gsKbKvq5mluDdQ2kYdiAFLtdyqjucYjxl4kxpzYpANKM0+P7BVLiG5uIrqm8DfJPwU0weCilKJ5PQ+MdPWniE3Xtf/w8zKii+J14a/drTCERJyf3nivi9XId4gHszX/bTskmM8OeLK312vvtZPM6X4pAUX7ThzF3plDsJGYVliueX3D8E+N9JebJ+ZdPAlt/NXQ2W5EUV++U1GMn02tiLOY0K6o82jtCneVFm/Rl4jaI0PftOynvUTNWgLt5IxToSG+yRGuMNPmvDVA2K01wppaDq1OOjZqoG9WcyMyiVmBmUSswMSiVmBqUSuw3K7Kbv/wPIqTLICVOm0gAAAABJRU5ErkJggg=="/></g></svg>
@@ -0,0 +1 @@
1
+ <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 106 68"><title>paypal</title><g id="jXowej.tif"><image id="Layer_0" data-name="Layer 0" width="106" height="68" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGoAAABECAYAAABph6DRAAAACXBIWXMAAAsSAAALEgHS3X78AAANdUlEQVR4Xu2cCXiM5xbHX6pXe9tSl2rtRcRSJbcEF9fTaumiDy3tvV0u2tLFflUsDSGWSFSIJbFESEkFKUIkdpUSe4ooIfsyyWRfRvb1f8/53iAZYUJ7J/PpnOc5mZkvM983z/ebc87/Pe/7fSI4OBhmN30X/Mdspm1mUCoxMyiVmBmUSswMSiVmBqUSUyWovIJiHD0Tix0HbsDncFiN3C8wAsfOxeFaVAZSM/OQX1hi6DAmZaoE5eR5AXUsF0O0nA/RflHNvIMDREdHPNVnBfp96oVZzsdx5ooWeSoBpjpQZWXl6PmJF0TrBRBdHCFecqqZd6nwDgS4FQFuaoe/WDlj5vJAZOgKDB221k11oFIy8tBuyHqIdhQlLy95OO/G/j1E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owilSmZw8lVoEryh6vThcibZDicablDQqqOtxmbB6b6MC4ZUPPHEyJBGxSTokpOYgJ18COXQuDk2oLvF7plJk3TIWC2985UM1bDasqE5pCSjbMYrAp3li0dIBz7BIae+Ax7ovwf7TMcr/+aT3oPGOAopk+N74AkTnlEKTW3IbSAy9buCdoMj3AQFV1d/E01kKGIYbSgqP65RYEKa8vpRpvAuzjQoqKESLFjROEmIyRkzZraQufQuLy4IFCQQeVzXstwrLtv6KIwRjBAmJurzq6Dk7DKPPplO0sBUVl6IPpz+uVRxZlAZtV59ULnxjS6Ka8sQ2ORXShuR0dfNTcQTNyjdZpj6qTdODsxGYXITxpzNlulweiX9QpMXmlWN8EEXnghvotScJ2nzjSHM2o4LyIKUmB7njMMHxaLVdI46ccY5HlMjhFPk4KcS/MgC+mxilPR4oj7M/iJxKKXG2W5C8fx/VL+uPtyiy/ZZdSCtWFBwPbq32Vj+Q5tbSuhs5UjiwuODxFk9Gcl3jeuQQgRGHUwl6GXqx4psZikEUecaclDQqqIBT0Xjrs2149/NtOEIp7l7G98+zW3UCPUg8dBi8Fp/N2gfPPb/hi9kBeHu0Nw4GRRFkeZY4ooZO2qVc4FaP6l5gsKbKvq5mluDdQ2kYdiAFLtdyqjucYjxl4kxpzYpANKM0+P7BVLiG5uIrqm8DfJPwU0weCilKJ5PQ+MdPWniE3Xtf/w8zKii+J14a/drTCERJyf3nivi9XId4gHszX/bTskmM8OeLK312vvtZPM6X4pAUX7ThzF3plDsJGYVliueX3D8E+N9JebJ+ZdPAlt/NXQ2W5EUV++U1GMn02tiLOY0K6o82jtCneVFm/Rl4jaI0PftOynvUTNWgLt5IxToSG+yRGuMNPmvDVA2K01wppaDq1OOjZqoG9WcyMyiVmBmUSswMSiVmBqUSuw3K7Kbv/wPIqTLICVOm0gAAAABJRU5ErkJggg=="/></g></svg>
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @namespace WORKAREA.updateCheckoutSubmitText
3
+ */
4
+ WORKAREA.registerModule('updateCheckoutSubmitText', (function () {
5
+ 'use strict';
6
+
7
+ var submitButtonText = function ($selectedPaymentMethod) {
8
+ var data = $selectedPaymentMethod.data('updateCheckoutSubmitText') || {};
9
+
10
+ if (data.prevent) { return; }
11
+
12
+ if (data.text) {
13
+ return data.text;
14
+ } else {
15
+ return I18n.t('workarea.storefront.checkouts.place_order');
16
+ }
17
+ },
18
+
19
+ updateText = function($selectedPaymentMethod, $checkoutSubmit) {
20
+ var text = submitButtonText($selectedPaymentMethod);
21
+
22
+ if (_.isEmpty(text)) { return; }
23
+
24
+ $checkoutSubmit.text(text);
25
+ },
26
+
27
+ setup = function($paymentMethodRadios){
28
+ var $initialPaymentMethod = $paymentMethodRadios.filter(':checked');
29
+
30
+ if ($initialPaymentMethod.data('updateCheckoutSubmitText')) {
31
+ var $checkoutSubmit = $('#checkout_form [type="submit"]');
32
+ updateText($initialPaymentMethod, $checkoutSubmit);
33
+ }
34
+ },
35
+
36
+ /**
37
+ * @method
38
+ * @name init
39
+ * @memberof WORKAREA.updateCheckoutSubmitText
40
+ */
41
+ init = function ($scope) {
42
+ var $paymentMethodRadios = $('[type="radio"][name="payment"]', $scope),
43
+ $textChangeRadios = $paymentMethodRadios.filter('[data-update-checkout-submit-text]');
44
+
45
+ if (_.isEmpty($textChangeRadios)) { return; }
46
+
47
+ setup($paymentMethodRadios);
48
+
49
+ $paymentMethodRadios.on('change', function(event){
50
+ var $selectedPaymentMethod = $(event.currentTarget),
51
+ $checkoutSubmit = $selectedPaymentMethod.closest('form').find('[type=submit]');
52
+
53
+ updateText($selectedPaymentMethod, $checkoutSubmit);
54
+ });
55
+ };
56
+
57
+ return {
58
+ init: init
59
+ };
60
+ }()));
@@ -0,0 +1,13 @@
1
+ module Workarea
2
+ decorate Storefront::Checkout::PlaceOrderController, with: 'paypal' do
3
+ def place_order
4
+ if params[:payment] == 'paypal' && !current_checkout.payment.paypal? && params[:from_checkout].present?
5
+ redirect_to start_paypal_path(from_checkout: 'from_checkout') and return
6
+ elsif params[:payment] == 'paypal' && !current_checkout.payment.paypal?
7
+ redirect_to start_paypal_path and return
8
+ else
9
+ super
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,51 @@
1
+ module Workarea
2
+ class Storefront::PaypalController < Storefront::ApplicationController
3
+ include Storefront::CurrentCheckout
4
+
5
+ before_action :validate_checkout
6
+
7
+ def start
8
+ unless params[:from_checkout].present?
9
+ if logged_in?
10
+ current_checkout.start_as(current_user)
11
+ else
12
+ current_checkout.start_as(:guest)
13
+ end
14
+ end
15
+
16
+ self.current_order = current_checkout.order
17
+ Pricing.perform(current_order, current_shipping)
18
+ check_inventory || (return)
19
+
20
+ setup = Paypal::Setup.new(
21
+ current_order,
22
+ current_user,
23
+ current_shipping,
24
+ self
25
+ )
26
+
27
+ redirect_to setup.redirect_url
28
+ end
29
+
30
+ def complete
31
+ self.current_order = Order.find(params[:order_id])
32
+ current_order.user_id = current_user.try(:id)
33
+ Pricing.perform(current_order, current_shipping)
34
+ check_inventory || (return)
35
+
36
+ Paypal::Update.new(
37
+ current_order,
38
+ current_checkout.payment,
39
+ current_shipping,
40
+ params[:token]
41
+ ).apply
42
+
43
+ unless current_checkout.complete?
44
+ flash[:error] = t('workarea.storefront.paypal.address_error')
45
+ redirect_to(checkout_addresses_path) && (return)
46
+ end
47
+
48
+ redirect_to checkout_payment_path
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,27 @@
1
+ module Workarea
2
+ decorate Payment, with: :paypal do
3
+ decorated do
4
+ embeds_one :paypal, class_name: 'Workarea::Payment::Tender::Paypal'
5
+ end
6
+
7
+ def set_paypal(attrs)
8
+ build_paypal unless paypal
9
+ paypal.attributes = attrs.slice(
10
+ :token,
11
+ :payer_id,
12
+ :details
13
+ )
14
+
15
+ save
16
+ end
17
+
18
+ def paypal?
19
+ paypal.present?
20
+ end
21
+
22
+ def set_credit_card(*)
23
+ self.paypal = nil
24
+ super
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ module Workarea
2
+ class Payment
3
+ module Authorize
4
+ class Paypal
5
+ include OperationImplementation
6
+ include CreditCardOperation
7
+
8
+ delegate :gateway, to: Workarea::Paypal
9
+
10
+ def complete!
11
+ transaction.response = handle_active_merchant_errors do
12
+ gateway.authorize(
13
+ transaction.amount.cents,
14
+ token: tender.token,
15
+ payer_id: tender.payer_id,
16
+ currency: transaction.amount.currency
17
+ )
18
+ end
19
+ end
20
+
21
+ def cancel!
22
+ return unless transaction.success?
23
+
24
+ transaction.cancellation = handle_active_merchant_errors do
25
+ gateway.void(transaction.response.params['transaction_id'])
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,35 @@
1
+ module Workarea
2
+ class Payment
3
+ class Capture
4
+ class Paypal
5
+ include OperationImplementation
6
+ include CreditCardOperation
7
+
8
+ delegate :gateway, to: Workarea::Paypal
9
+
10
+ def complete!
11
+ validate_reference!
12
+
13
+ transaction.response = handle_active_merchant_errors do
14
+ gateway.capture(
15
+ transaction.amount.cents,
16
+ transaction.reference.response.params['transaction_id'],
17
+ currency: transaction.amount.currency
18
+ )
19
+ end
20
+ end
21
+
22
+ def cancel!
23
+ return unless transaction.success?
24
+
25
+ transaction.cancellation = handle_active_merchant_errors do
26
+ gateway.refund(
27
+ transaction.amount.cents,
28
+ transaction.response.params['transaction_id']
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ module Workarea
2
+ class Payment
3
+ module Purchase
4
+ class Paypal
5
+ include OperationImplementation
6
+ include CreditCardOperation
7
+
8
+ delegate :gateway, to: Workarea::Paypal
9
+
10
+ def complete!
11
+ transaction.response = handle_active_merchant_errors do
12
+ gateway.purchase(
13
+ transaction.amount.cents,
14
+ token: tender.token,
15
+ payer_id: tender.payer_id,
16
+ currency: transaction.amount.currency
17
+ )
18
+ end
19
+ end
20
+
21
+ def cancel!
22
+ return unless transaction.success?
23
+
24
+ transaction.cancellation = handle_active_merchant_errors do
25
+ gateway.void(transaction.response.params['transaction_id'])
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ module Workarea
2
+ class Payment
3
+ class Refund
4
+ class Paypal
5
+ include OperationImplementation
6
+ include CreditCardOperation
7
+
8
+ def complete!
9
+ validate_reference!
10
+
11
+ transaction.response = handle_active_merchant_errors do
12
+ Workarea::Paypal.gateway.refund(
13
+ transaction.amount.cents,
14
+ transaction.reference.response.params['transaction_id'],
15
+ currency: transaction.amount.currency
16
+ )
17
+ end
18
+ end
19
+
20
+ def cancel!
21
+ # noop
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end