workarea-payware_connect 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) 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/.github/workflows/ci.yml +54 -0
  7. data/.gitignore +13 -0
  8. data/.rubocop.yml +2 -0
  9. data/CHANGELOG.md +63 -0
  10. data/CODE_OF_CONDUCT.md +3 -0
  11. data/CONTRIBUTING.md +3 -0
  12. data/Gemfile +9 -0
  13. data/LICENSE.md +3 -0
  14. data/README.md +53 -0
  15. data/Rakefile +54 -0
  16. data/app/models/workarea/payment/authorize/credit_card.decorator +37 -0
  17. data/app/models/workarea/payment/capture/credit_card.decorator +14 -0
  18. data/app/models/workarea/payment/payware_credit_card.decorator +24 -0
  19. data/app/models/workarea/payment/purchase/credit_card.decorator +37 -0
  20. data/app/models/workarea/payment/refund/credit_card.decorator +14 -0
  21. data/app/models/workarea/payment/store_credit_card.decorator +13 -0
  22. data/app/workers/workarea/save_user_order_details.decorator +33 -0
  23. data/bin/rails +18 -0
  24. data/config/initializers/00_defaults.rb +1 -0
  25. data/doc/PWCTestAccount_WorldPay ecom.pages +0 -0
  26. data/doc/validation/(Completed v2)PAYware Connect Validation Worksheet 2015 V2 .doc +0 -0
  27. data/doc/validation/(Completed v3)PAYware Connect Validation Worksheet 2015 V2 .doc +0 -0
  28. data/doc/validation/PAYware Connect Validation Letter Weblinc 09-11-2015.pdf +0 -0
  29. data/doc/validation/PAYware Connect Validation Letter Weblinc 10-21-2015.pdf +0 -0
  30. data/lib/active_merchant/billing/bogus_payware_connect_gateway.rb +130 -0
  31. data/lib/active_merchant/billing/payware_connect_gateway.rb +137 -0
  32. data/lib/active_merchant/billing/payware_connect_gateway/actions/authorize.rb +63 -0
  33. data/lib/active_merchant/billing/payware_connect_gateway/actions/capture.rb +26 -0
  34. data/lib/active_merchant/billing/payware_connect_gateway/actions/purchase.rb +59 -0
  35. data/lib/active_merchant/billing/payware_connect_gateway/actions/refund.rb +29 -0
  36. data/lib/active_merchant/billing/payware_connect_gateway/actions/void.rb +20 -0
  37. data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_contract.rb +9 -0
  38. data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_customer.rb +9 -0
  39. data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_customer_and_contract.rb +10 -0
  40. data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/update_contract.rb +9 -0
  41. data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/update_customer.rb +9 -0
  42. data/lib/active_merchant/billing/payware_connect_gateway/admin_xml_builder.rb +105 -0
  43. data/lib/active_merchant/billing/payware_connect_gateway/xml_builder.rb +35 -0
  44. data/lib/active_merchant/billing/payware_response.rb +9 -0
  45. data/lib/validation.rb +25 -0
  46. data/lib/workarea/payware_connect.rb +43 -0
  47. data/lib/workarea/payware_connect/engine.rb +8 -0
  48. data/lib/workarea/payware_connect/version.rb +5 -0
  49. data/test/dummy/Rakefile +6 -0
  50. data/test/dummy/app/assets/config/manifest.js +4 -0
  51. data/test/dummy/app/assets/images/.keep +0 -0
  52. data/test/dummy/app/assets/javascripts/application.js +13 -0
  53. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  54. data/test/dummy/app/controllers/application_controller.rb +3 -0
  55. data/test/dummy/app/controllers/concerns/.keep +0 -0
  56. data/test/dummy/app/helpers/application_helper.rb +2 -0
  57. data/test/dummy/app/jobs/application_job.rb +2 -0
  58. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  59. data/test/dummy/app/models/concerns/.keep +0 -0
  60. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  61. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  62. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  63. data/test/dummy/bin/bundle +3 -0
  64. data/test/dummy/bin/rails +4 -0
  65. data/test/dummy/bin/rake +4 -0
  66. data/test/dummy/bin/setup +34 -0
  67. data/test/dummy/bin/update +29 -0
  68. data/test/dummy/config.ru +5 -0
  69. data/test/dummy/config/application.rb +24 -0
  70. data/test/dummy/config/boot.rb +5 -0
  71. data/test/dummy/config/cable.yml +9 -0
  72. data/test/dummy/config/environment.rb +5 -0
  73. data/test/dummy/config/environments/development.rb +56 -0
  74. data/test/dummy/config/environments/production.rb +86 -0
  75. data/test/dummy/config/environments/test.rb +44 -0
  76. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  77. data/test/dummy/config/initializers/assets.rb +11 -0
  78. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  79. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  80. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  81. data/test/dummy/config/initializers/inflections.rb +16 -0
  82. data/test/dummy/config/initializers/mime_types.rb +4 -0
  83. data/test/dummy/config/initializers/new_framework_defaults.rb +23 -0
  84. data/test/dummy/config/initializers/workarea.rb +3 -0
  85. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  86. data/test/dummy/config/locales/en.yml +23 -0
  87. data/test/dummy/config/puma.rb +47 -0
  88. data/test/dummy/config/routes.rb +5 -0
  89. data/test/dummy/config/secrets.yml +22 -0
  90. data/test/dummy/config/spring.rb +6 -0
  91. data/test/dummy/db/seeds.rb +3 -0
  92. data/test/dummy/lib/assets/.keep +0 -0
  93. data/test/dummy/log/.keep +0 -0
  94. data/test/dummy/public/404.html +67 -0
  95. data/test/dummy/public/422.html +67 -0
  96. data/test/dummy/public/500.html +66 -0
  97. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  98. data/test/dummy/public/apple-touch-icon.png +0 -0
  99. data/test/dummy/public/favicon.ico +0 -0
  100. data/test/integration/workarea/storefront/checkout_side_effects_integration_test.decorator +44 -0
  101. data/test/lib/active_merchant/billing/payware_connect_gateway_test.rb +280 -0
  102. data/test/models/workarea/payment/authorize/credit_card_test.decorator +47 -0
  103. data/test/models/workarea/payment/capture/credit_card_test.decorator +33 -0
  104. data/test/models/workarea/payment/credit_card_integration_test.decorator +25 -0
  105. data/test/models/workarea/payment/payware_credit_card_test.rb +44 -0
  106. data/test/models/workarea/payment/purchase/credit_card_test.decorator +54 -0
  107. data/test/models/workarea/payment/refund/credit_card_test.decorator +33 -0
  108. data/test/models/workarea/payment/store_credit_card_test.decorator +10 -0
  109. data/test/support/workarea/payware_connect_gateway_vcr_config.rb +24 -0
  110. data/test/system/workarea/admin/payment_transactions_system_test.decorator +37 -0
  111. data/test/test_helper.rb +12 -0
  112. data/test/vcr_cassettes/credit_card/auth_capture.yml +127 -0
  113. data/test/vcr_cassettes/credit_card/auth_void.yml +126 -0
  114. data/test/vcr_cassettes/credit_card/purchase_void.yml +126 -0
  115. data/test/vcr_cassettes/credit_card/store_auth.yml +67 -0
  116. data/test/vcr_cassettes/credit_card/store_purchase.yml +67 -0
  117. data/test/vcr_cassettes/payware/add_contract.yml +99 -0
  118. data/test/vcr_cassettes/payware/add_customer.yml +52 -0
  119. data/test/vcr_cassettes/payware/authorize_credit_card.yml +67 -0
  120. data/test/vcr_cassettes/payware/authorize_customer_and_contract.yml +161 -0
  121. data/test/vcr_cassettes/payware/authorize_for_0_credit_card.yml +67 -0
  122. data/test/vcr_cassettes/payware/authorize_for_0_troutd.yml +130 -0
  123. data/test/vcr_cassettes/payware/authorize_troutd.yml +130 -0
  124. data/test/vcr_cassettes/payware/capture.yml +127 -0
  125. data/test/vcr_cassettes/payware/refund.yml +223 -0
  126. data/test/vcr_cassettes/payware/refund_troutd.yml +128 -0
  127. data/test/vcr_cassettes/payware/void_authorization.yml +126 -0
  128. data/test/workers/workarea/save_user_order_details_test.decorator +56 -0
  129. data/workarea-payware_connect.gemspec +18 -0
  130. metadata +190 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b266c36255faa2c5dc4596f15144a67a75d267a1c9a7b2a605efca11b6ae188d
4
+ data.tar.gz: a8ce1c990b29cbf167a97b99d2ca7bb6f1d93b1091a4a5e93d4813235c19ddbf
5
+ SHA512:
6
+ metadata.gz: 205cb26ffb4b1e78b06c62a1f18508b8265d5e322d396c575569cc23771d5ef31d359e5470a65fb6d3ba6b8138c3ee16d494948aba4b409a67e8c53fad327258
7
+ data.tar.gz: 945dc12fa2784050eb11ae0bf68e686f3dded3ede1e9ee7e53f119baa7676356856fe0936c1a9267c34cf76528e662409340e5fe3c9ac82a800c8d19c419678d
@@ -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.
@@ -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,13 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ coverage/
5
+ test/dummy/db/*.sqlite3
6
+ test/dummy/db/*.sqlite3-journal
7
+ test/dummy/log/*.log
8
+ test/dummy/tmp/
9
+ test/dummy/.sass-cache
10
+ test/dummy/public/system/workarea
11
+ Gemfile.lock
12
+ .DS_STORE
13
+ .rubocop-http*
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
@@ -0,0 +1,63 @@
1
+ Workarea Payware Connect 2.1.2 (2020-01-21)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Fix Tests for 2020
5
+
6
+ Update all tests so that they no longer depend on the year 2020 as an
7
+ expiration year. Instead, use the method provided by Workarea.
8
+
9
+ PAYWARE-1
10
+ Tom Scott
11
+
12
+
13
+
14
+ Workarea Payware Connect 2.1.1 (2019-05-28)
15
+ --------------------------------------------------------------------------------
16
+
17
+ * Update PaywareConnect API URLs
18
+
19
+ WPC-8
20
+ Eric Pigeon
21
+
22
+
23
+
24
+ Workarea Payware Connect 2.1.0 (2019-04-02)
25
+ --------------------------------------------------------------------------------
26
+
27
+ * Update for v3.4 compatibility
28
+
29
+ * Add CI scripts
30
+ * Update Gemfile
31
+ * Rubocop fixes
32
+ * Update decorated test to use Metrics instead of Analytics
33
+
34
+ WPC-7
35
+ Jake Beresford
36
+
37
+
38
+
39
+ Workarea Payware Connect 2.0.0 (2018-11-21)
40
+ --------------------------------------------------------------------------------
41
+
42
+ * Ensure the partial number is save
43
+
44
+ Ensure partial number is set when saving the payment and when using a
45
+ saved card
46
+
47
+ WPC-6
48
+ Eric Pigeon
49
+
50
+
51
+
52
+ Workarea Payware Connect 2.0.0.beta (2017-10-18)
53
+ --------------------------------------------------------------------------------
54
+
55
+ * Upgrade for Workarea v3
56
+
57
+ Upgrade for v3 compatibility and add in missing support for refunding
58
+
59
+ WPC-5
60
+ Eric Pigeon
61
+
62
+
63
+
@@ -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,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'workarea', git: 'https://github.com/workarea-commerce/workarea.git', branch: 'v3.5-stable'
6
+
7
+ group :test do
8
+ gem "simplecov", require: false
9
+ end
@@ -0,0 +1,3 @@
1
+ View this plugin's license here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/LICENSE.md>
@@ -0,0 +1,53 @@
1
+ Workarea Payware Connect
2
+ ================================================================================
3
+
4
+ Payware Connect plugin for the Workarea platform.
5
+
6
+
7
+ Getting Started
8
+ --------------------------------------------------------------------------------
9
+ NOTES
10
+ -----
11
+ **(9/15/15) Only Pre-auth, Completion, and Void are supported and validated as of v0.9.4.**
12
+ **(10/21/15) Storing cards in user accounts is broken pending verification of business requirements v0.9.5.**
13
+ IF INTEGRATING WITH MACH VALIDATION IS UNNECESSARY.
14
+ SEE VALIDATION LETTER AND WORKSHEET FOR MORE INFO.
15
+
16
+ Revalidation is necessary if any of these change:
17
+ 1. Business type
18
+ 2. Transaction type supported
19
+ 3. Code Changes that may affect Transactions or reports
20
+ 4. Change in Processor
21
+ 5. Report type supported
22
+ 6. New Device Supported
23
+
24
+ The file lib\validation.rb can be used in the console to generate the necessary xml and output to the development.log
25
+ -----
26
+
27
+
28
+ Gateways
29
+ --------------------------------------------------------------------------------
30
+ Unless keys are provided in the secrets.yml file the Payware Connect engine will
31
+ use a bogus gateway.
32
+
33
+ If you want to use the live gateway you must include the following keys in your
34
+ secrets.yml:
35
+
36
+ :payware_connect:
37
+ :client_id:
38
+ :login:
39
+ :password:
40
+ :merchant_key:
41
+ :test: # if using sandbox
42
+
43
+ If the above keys are provided the gateway will be automatically configured. For
44
+ more details on this implementation. Test is optional and will default to true.
45
+
46
+ Workarea Platform Documentation
47
+ --------------------------------------------------------------------------------
48
+
49
+ See [https://developer.workarea.com](http://developer.workarea.com) for Workarea platform documentation.
50
+
51
+ Copyright & Licensing
52
+ --------------------------------------------------------------------------------
53
+ Workarea Commerce Platform is released under the [Business Software License](https://github.com/workarea-commerce/workarea/blob/master/LICENSE)
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ require "rdoc/task"
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.title = "PaywareConnect"
14
+ rdoc.options << "--line-numbers"
15
+ rdoc.rdoc_files.include("README.md")
16
+ rdoc.rdoc_files.include("lib/**/*.rb")
17
+ end
18
+
19
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
20
+ load "rails/tasks/engine.rake"
21
+ load "rails/tasks/statistics.rake"
22
+ load "workarea/changelog.rake"
23
+
24
+ require "rake/testtask"
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << "lib"
28
+ t.libs << "test"
29
+ t.pattern = "test/**/*_test.rb"
30
+ t.verbose = false
31
+ end
32
+
33
+ task default: :test
34
+
35
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
36
+ require "workarea/payware_connect/version"
37
+
38
+ desc "Release version #{Workarea::PaywareConnect::VERSION} of the gem"
39
+ task :release do
40
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
41
+
42
+
43
+ Rake::Task["workarea:changelog"].execute
44
+ system "git add CHANGELOG.md"
45
+ system 'git commit -m "Update CHANGELOG"'
46
+
47
+ system "git tag -a v#{Workarea::PaywareConnect::VERSION} -m 'Tagging #{Workarea::PaywareConnect::VERSION}'"
48
+ system "git push origin HEAD --follow-tags"
49
+
50
+ system "gem build workarea-payware_connect.gemspec"
51
+ system "gem push workarea-payware_connect-#{Workarea::PaywareConnect::VERSION}.gem"
52
+ system "gem push workarea-payware_connect-#{Workarea::PaywareConnect::VERSION}.gem --host #{host}"
53
+ system "rm workarea-payware_connect-#{Workarea::PaywareConnect::VERSION}.gem"
54
+ end
@@ -0,0 +1,37 @@
1
+ module Workarea
2
+ decorate Payment::Authorize::CreditCard, with: :payware_connect do
3
+ decorated { delegate :address, to: :tender }
4
+
5
+ def complete!
6
+ transaction.response = handle_active_merchant_errors do
7
+ gateway.authorize(
8
+ transaction.amount.cents,
9
+ tender_payment.merge(billing_address: address)
10
+ )
11
+ end
12
+
13
+ if transaction.response.success?
14
+ tender.token = transaction.response.troutd
15
+ tender.save!
16
+ end
17
+
18
+ transaction.response
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.troutd)
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def tender_payment
32
+ return { troutd: tender.token } if tender.tokenized?
33
+
34
+ { credit_card: tender.to_active_merchant }
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ module Workarea
2
+ decorate Payment::Capture::CreditCard, with: :payware_connect do
3
+ def complete!
4
+ validate_reference!
5
+
6
+ transaction.response = handle_active_merchant_errors do
7
+ gateway.capture(
8
+ transaction.amount.cents,
9
+ transaction.reference.response.troutd
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ module Workarea
2
+ decorate Payment::Tender::CreditCard, Payment::SavedCreditCard, with: :payware_connect do
3
+ decorated do
4
+ field :partial_number, type: String
5
+
6
+ before_validation :save_partial_number, if: :set_partial_number?
7
+ end
8
+
9
+ def save_partial_number
10
+ self.partial_number = "#{number.first}-#{number.last(4)}"
11
+ end
12
+
13
+ private
14
+
15
+ def set_partial_number?
16
+ number.present? && number !~ /XXXX/
17
+ end
18
+
19
+ def set_saved_card_values
20
+ super
21
+ self.partial_number = saved_card.partial_number if saved_card.present?
22
+ end
23
+ end
24
+ end