workarea-checkoutdotcom 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc +24 -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/.github/workflows/ci.yml +54 -0
  7. data/.gitignore +23 -0
  8. data/.rubocop.yml +3 -0
  9. data/.stylelintrc.json +8 -0
  10. data/CHANGELOG.md +59 -0
  11. data/Gemfile +6 -0
  12. data/README.md +74 -0
  13. data/Rakefile +60 -0
  14. data/app/lib/active_merchant/billing/gateways/checkout_v2.decorator +22 -0
  15. data/app/models/workarea/payment/authorize/credit_card.decorator +41 -0
  16. data/app/models/workarea/payment/purchase/credit_card.decorator +44 -0
  17. data/app/models/workarea/payment/store_credit_card.decorator +17 -0
  18. data/bin/rails +20 -0
  19. data/config/initializers/workarea.rb +1 -0
  20. data/lib/active_merchant/billing/bogus_checkout_v2_gateway.rb +42 -0
  21. data/lib/workarea/checkoutdotcom.rb +46 -0
  22. data/lib/workarea/checkoutdotcom/engine.rb +8 -0
  23. data/lib/workarea/checkoutdotcom/version.rb +5 -0
  24. data/script/admin_ci +9 -0
  25. data/script/ci +11 -0
  26. data/script/core_ci +9 -0
  27. data/script/plugins_ci +9 -0
  28. data/script/storefront_ci +9 -0
  29. data/test/dummy/Rakefile +6 -0
  30. data/test/dummy/bin/bundle +3 -0
  31. data/test/dummy/bin/rails +4 -0
  32. data/test/dummy/bin/rake +4 -0
  33. data/test/dummy/bin/setup +30 -0
  34. data/test/dummy/bin/update +26 -0
  35. data/test/dummy/bin/yarn +11 -0
  36. data/test/dummy/config.ru +5 -0
  37. data/test/dummy/config/application.rb +30 -0
  38. data/test/dummy/config/boot.rb +5 -0
  39. data/test/dummy/config/cable.yml +10 -0
  40. data/test/dummy/config/environment.rb +5 -0
  41. data/test/dummy/config/environments/development.rb +51 -0
  42. data/test/dummy/config/environments/production.rb +88 -0
  43. data/test/dummy/config/environments/test.rb +44 -0
  44. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  45. data/test/dummy/config/initializers/assets.rb +14 -0
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  47. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  48. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/test/dummy/config/initializers/inflections.rb +16 -0
  50. data/test/dummy/config/initializers/mime_types.rb +4 -0
  51. data/test/dummy/config/initializers/workarea.rb +5 -0
  52. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  53. data/test/dummy/config/locales/en.yml +33 -0
  54. data/test/dummy/config/puma.rb +56 -0
  55. data/test/dummy/config/routes.rb +5 -0
  56. data/test/dummy/config/secrets.yml +32 -0
  57. data/test/dummy/config/spring.rb +6 -0
  58. data/test/dummy/db/seeds.rb +2 -0
  59. data/test/dummy/log/.keep +0 -0
  60. data/test/models/workarea/payment/authorize/credit_card_test.decorator +38 -0
  61. data/test/models/workarea/payment/capture_test.decorator +27 -0
  62. data/test/models/workarea/payment/checkoutdotcom_integration_test.rb +178 -0
  63. data/test/models/workarea/payment/credit_card_integration_test.decorator +107 -0
  64. data/test/models/workarea/payment/purchase/credit_card_test.decorator +38 -0
  65. data/test/models/workarea/payment/refund_test.decorator +27 -0
  66. data/test/support/workarea/checkoutdotcom_gateway_vcr_config.rb +20 -0
  67. data/test/support/workarea/workarea_3_2_backports.rb +57 -0
  68. data/test/teaspoon_env.rb +6 -0
  69. data/test/test_helper.rb +10 -0
  70. data/test/vcr_cassettes/checkoutdotcom/auth_capture.yml +154 -0
  71. data/test/vcr_cassettes/checkoutdotcom/auth_capture_refund.yml +225 -0
  72. data/test/vcr_cassettes/checkoutdotcom/auth_void.yml +154 -0
  73. data/test/vcr_cassettes/checkoutdotcom/purchase_refund.yml +225 -0
  74. data/test/vcr_cassettes/checkoutdotcom/store_auth.yml +83 -0
  75. data/test/vcr_cassettes/checkoutdotcom/store_purchase.yml +154 -0
  76. data/test/vcr_cassettes/credit_card/auth_capture.yml +154 -0
  77. data/test/vcr_cassettes/credit_card/auth_capture_refund.yml +225 -0
  78. data/test/vcr_cassettes/credit_card/auth_void.yml +154 -0
  79. data/test/vcr_cassettes/credit_card/purchase_refund.yml +225 -0
  80. data/test/vcr_cassettes/credit_card/store_auth.yml +83 -0
  81. data/test/vcr_cassettes/credit_card/store_purchase.yml +154 -0
  82. data/test/workers/workarea/send_refund_email_test.decorator +27 -0
  83. data/workarea-checkoutdotcom.gemspec +19 -0
  84. metadata +144 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b377de0dd833aae8bd4334f1084926025c757ca68d0c7e84eb46da7256c9b552
4
+ data.tar.gz: 644d9f66c3a3c8f5d871f08a76ca438c67c5d1c644b67baf1faa2812bfdbb8d4
5
+ SHA512:
6
+ metadata.gz: fb78b5276096c55f2c495e5355940b45a07a44b13be23cbeac36d7631969f55484d017c2abc6fc11bb06d9014322957d669b130416fe61e6957bb083dbe78b6c
7
+ data.tar.gz: c55105dc04ed7317f87ecafa611c875e42bb06f927c4a22f037e48855bc0b8e6150b41637854b31fd47cc3be3107c861f6151f9fb8a4b57104cb0b589acdc1f0
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "eslint:recommended",
3
+ "rules": {
4
+ "semi": [1, "always"]
5
+ },
6
+ "globals": {
7
+ "window": true,
8
+ "document": true,
9
+ "WORKAREA": true,
10
+ "$": true,
11
+ "jQuery": true,
12
+ "_": true,
13
+ "feature": true,
14
+ "JST": true,
15
+ "Turbolinks": true,
16
+ "I18n": true,
17
+ "Chart": true,
18
+ "Dropzone": true,
19
+ "strftime": true,
20
+ "Waypoint": true,
21
+ "wysihtml": true,
22
+ "LocalTime": true,
23
+ }
24
+ }
@@ -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.
@@ -0,0 +1,54 @@
1
+ name: CI
2
+ on: [push]
3
+
4
+ jobs:
5
+ static_analysis:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v1
9
+ - uses: workarea-commerce/ci/bundler-audit@v1
10
+ - uses: workarea-commerce/ci/rubocop@v1
11
+
12
+ admin_tests:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v1
16
+ - uses: actions/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.6.x
19
+ - uses: workarea-commerce/ci/test@v1
20
+ with:
21
+ command: bin/rails app:workarea:test:admin
22
+
23
+ core_tests:
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v1
27
+ - uses: actions/setup-ruby@v1
28
+ with:
29
+ ruby-version: 2.6.x
30
+ - uses: workarea-commerce/ci/test@v1
31
+ with:
32
+ command: bin/rails app:workarea:test:core
33
+
34
+ storefront_tests:
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v1
38
+ - uses: actions/setup-ruby@v1
39
+ with:
40
+ ruby-version: 2.6.x
41
+ - uses: workarea-commerce/ci/test@v1
42
+ with:
43
+ command: bin/rails app:workarea:test:storefront
44
+
45
+ plugins_tests:
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/checkout@v1
49
+ - uses: actions/setup-ruby@v1
50
+ with:
51
+ ruby-version: 2.6.x
52
+ - uses: workarea-commerce/ci/test@v1
53
+ with:
54
+ command: bin/rails app:workarea:test:plugins
@@ -0,0 +1,23 @@
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
23
+ .rubocop-http*
@@ -0,0 +1,3 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
3
+
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "stylelint-config-recommended-scss",
3
+ "rules": {
4
+ "block-no-empty": null,
5
+ "no-descending-specificity": null,
6
+ "property-no-unknown": [true, { "ignoreProperties": ["mso-hide"] }]
7
+ }
8
+ }
@@ -0,0 +1,59 @@
1
+ Workarea Checkoutdotcom 1.2.0 (2019-11-26)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Move credit card tokenization to post transaction
5
+
6
+ Checkout.com charges for every authorization transaction. Moving tokenzation to post
7
+ transaction helps reduce the extra cost for the merchant.
8
+
9
+ CHECKOUTDOTCOM-1
10
+ Jeff Yucis
11
+
12
+ * RuboCop Corrections
13
+
14
+ Tom Scott
15
+
16
+ * Add CI and Contribution Guidelines
17
+
18
+ Tom Scott
19
+
20
+ * Add Refund Tests from Workarea
21
+
22
+ This was originally included upstream, but are typically skipped by
23
+ plugins and applications. CheckoutDotCom is the only plugin that needs
24
+ the unmodified tests from base, so copy those tests into the plugin
25
+ since they are removed from base in v3.5+.
26
+ Tom Scott
27
+
28
+ * Update payment integration to use payment sources.
29
+
30
+ CHKOUTCOM-3
31
+ Jeff Yucis
32
+
33
+ * Integrate checkout.com for credit card processing.
34
+
35
+ CHKOUTCOM-1
36
+ Jeff Yucis
37
+
38
+
39
+
40
+ Workarea Checkoutdotcom 1.1.0 (2019-08-06)
41
+ --------------------------------------------------------------------------------
42
+
43
+ * Update payment integration to use payment sources.
44
+
45
+ CHKOUTCOM-3
46
+ Jeff Yucis
47
+
48
+
49
+
50
+ Workarea Checkoutdotcom 1.0.0 (2019-03-19)
51
+ --------------------------------------------------------------------------------
52
+
53
+ * Integrate checkout.com for credit card processing.
54
+
55
+ CHKOUTCOM-1
56
+ Jeff Yucis
57
+
58
+
59
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ gemspec
5
+
6
+ gem 'workarea', github: 'workarea-commerce/workarea', branch: :master
@@ -0,0 +1,74 @@
1
+ Workarea Checkout.com Payment Processor
2
+ ================================================================================
3
+
4
+ Checkout.com payment processor integration for credit cards.
5
+
6
+ The plugin supports:
7
+
8
+ 1. Tokenization
9
+ 2. Authorization
10
+ 3. Purchase (auth with capture)
11
+ 4. Refund
12
+
13
+
14
+ Installation
15
+ --------------------------------------------------------------------------------
16
+
17
+ Testing accounts can be created for free at https://www.checkout.com/
18
+
19
+ Once an account is provisioned the secret key will need to be installed into the host applications secrets file:
20
+
21
+ checkoutdotcom:
22
+ secret_key: sk_test_XXXXXXX
23
+ test: true # set this to false in production.
24
+
25
+ The secret key can be found in the **Channels** tab in the **Settings** section of the Checkout.com hub.
26
+
27
+ Test environments must use the pre-defined test cards for successful transactions. See more information about testing here: https://docs.checkout.com/docs/testing
28
+
29
+ Getting Started
30
+ --------------------------------------------------------------------------------
31
+
32
+ This gem contains a rails engine that must be mounted onto a host Rails application.
33
+
34
+ To access Workarea gems and source code, you must be an employee of WebLinc or a licensed retailer or partner.
35
+
36
+ Workarea gems are hosted privately at https://gems.weblinc.com/.
37
+ You must have individual or team credentials to install gems from this server. Add your gems server credentials to Bundler:
38
+
39
+ bundle config gems.weblinc.com my_username:my_password
40
+
41
+ Or set the appropriate environment variable in a shell startup file:
42
+
43
+ export BUNDLE_GEMS__WEBLINC__COM='my_username:my_password'
44
+
45
+ Then add the gem to your application's Gemfile specifying the source:
46
+
47
+ # ...
48
+ gem 'workarea-checkoutdotcom', source: 'https://gems.weblinc.com'
49
+ # ...
50
+
51
+ Or use a source block:
52
+
53
+ # ...
54
+ source 'https://gems.weblinc.com' do
55
+ gem 'workarea-checkoutdotcom'
56
+ end
57
+ # ...
58
+
59
+ Update your application's bundle.
60
+
61
+ cd path/to/application
62
+ bundle
63
+
64
+ Workarea Platform Documentation
65
+ --------------------------------------------------------------------------------
66
+
67
+ See [http://developer.weblinc.com](http://developer.weblinc.com) for Workarea platform documentation.
68
+
69
+ Copyright & Licensing
70
+ --------------------------------------------------------------------------------
71
+
72
+ Copyright WebLinc 2019. All rights reserved.
73
+
74
+ For licensing, contact sales@workarea.com.
@@ -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 = 'Checkoutdotcom'
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/checkoutdotcom/version'
32
+
33
+ desc "Release version #{Workarea::Checkoutdotcom::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::Checkoutdotcom::VERSION} -m 'Tagging #{Workarea::Checkoutdotcom::VERSION}'"
43
+ system 'git push --tags'
44
+
45
+ system "gem build workarea-checkoutdotcom.gemspec"
46
+ system "gem push workarea-checkoutdotcom-#{Workarea::Checkoutdotcom::VERSION}.gem"
47
+ system "gem push workarea-checkoutdotcom-#{Workarea::Checkoutdotcom::VERSION}.gem --host #{host}"
48
+ system "rm workarea-checkoutdotcom-#{Workarea::Checkoutdotcom::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,22 @@
1
+ module ActiveMerchant
2
+ decorate Billing::CheckoutV2Gateway, with: :checkoutdotcom do
3
+ def verify(credit_card, options={})
4
+ authorize(0, credit_card, options)
5
+ end
6
+
7
+ def add_payment_method(post, payment_method, options)
8
+ post[:source] = {}
9
+ if payment_method.is_a?(String)
10
+ post[:source][:type] = 'id'
11
+ post[:source][:id] = payment_method
12
+ else
13
+ post[:source][:type] = 'card'
14
+ post[:source][:name] = payment_method.name
15
+ post[:source][:number] = payment_method.number
16
+ post[:source][:cvv] = payment_method.verification_value
17
+ post[:source][:expiry_year] = format(payment_method.year, :four_digits)
18
+ post[:source][:expiry_month] = format(payment_method.month, :two_digits)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,41 @@
1
+ module Workarea
2
+ decorate Payment::Authorize::CreditCard, with: :checkoutdotcom do
3
+ decorated do
4
+ delegate :address, to: :tender
5
+ end
6
+
7
+ def complete!
8
+ transaction.response = handle_active_merchant_errors do
9
+ gateway.authorize(
10
+ transaction.amount.cents,
11
+ tender.to_token_or_active_merchant,
12
+ transaction_options
13
+ )
14
+ end
15
+
16
+ if transaction.response.success? && tender.token.blank?
17
+ tender.token = transaction.response.params["source"]["id"]
18
+ tender.save!
19
+ end
20
+
21
+ transaction.response
22
+ end
23
+
24
+ private
25
+
26
+ def transaction_options
27
+ {
28
+ order_id: tender.payment.id,
29
+ email: tender.profile.email,
30
+ billing_address: {
31
+ address1: address.street,
32
+ address2: address.street_2,
33
+ city: address.city,
34
+ state: address.region,
35
+ country: address.country.alpha2,
36
+ zip: address.postal_code
37
+ }
38
+ }
39
+ end
40
+ end
41
+ end