activemerchant-argus 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 303662197f4e5ae3ba0105a92799d5cd25c001e4346db0725a78d3a9624bdb64
4
+ data.tar.gz: 9a716dd825911e415451b3d6884cf536c55403ceb08fda6ef305f04b8e4d63f5
5
+ SHA512:
6
+ metadata.gz: fbc9838e285f6e39e713a1f3e75c2dcd2406e6744be50c4c8da599dc7f01c22984d6ea5d3daae108077061cacbfce847cc6bdc9e9b32cc360d6973f2974d553b
7
+ data.tar.gz: 0dab2033c37073f8429ba5fdbade13e0a58472d65087f25e6e489dce50a9aba39fd08b35a8b0f09037035655a00998af64a7e8c137267b1b74b9935100db97f0
@@ -0,0 +1,9 @@
1
+ Gemfile.lock
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis ADDED
File without changes
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in active_merchant-argus.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Piers Chambers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # ActiveMerchant::Argus
2
+
3
+ Active Merchant extension to support Inovio payment gateway (f.k.a. Argus)
4
+
5
+ [![Version ][rubygems_badge]][rubygems]
6
+ [![Travis CI ][travis_badge]][travis]
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'activemerchant-argus'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ ## Usage
21
+
22
+ TODO: Write usage instructions here
23
+
24
+ ## Development
25
+
26
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
+
28
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/varyonic/activemerchant-argus.
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
37
+
38
+ [rubygems_badge]: http://img.shields.io/gem/v/activemerchant-argus.svg
39
+ [rubygems]: https://rubygems.org/gems/activemerchant-argus
40
+ [travis_badge]: http://img.shields.io/travis/varyonic/activemerchant-argus/master.svg
41
+ [travis]: https://travis-ci.org/varyonic/activemerchant-argus
@@ -0,0 +1,27 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => 'test:units'
11
+
12
+ namespace :test do
13
+ Rake::TestTask.new(:units) do |t|
14
+ t.pattern = 'test/unit/**/*_test.rb'
15
+ t.libs << 'test'
16
+ t.verbose = true
17
+ end
18
+
19
+ desc 'Run all tests that do not require network access'
20
+ task :local => ['test:units', 'rubocop']
21
+
22
+ Rake::TestTask.new(:remote) do |t|
23
+ t.pattern = 'test/remote/**/*_test.rb'
24
+ t.libs << 'test'
25
+ t.verbose = true
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "active_merchant/argus/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "activemerchant-argus"
8
+ spec.version = ActiveMerchant::Argus::VERSION
9
+ spec.authors = ["Piers Chambers"]
10
+ spec.email = ["piers@varyonic.com"]
11
+
12
+ spec.summary = %q{Active Merchant extension to support Inovio payment gateway (f.k.a. Argus)}
13
+ spec.homepage = "https://github.com/varyonic/activemerchant-argus"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency 'activemerchant'
26
+
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency('test-unit', '~> 3')
30
+ spec.add_development_dependency('mocha', '~> 1')
31
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "active_merchant/argus"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ require "active_merchant"
2
+ require "active_merchant/argus/version"
3
+ require "active_merchant/billing/gateways/argus"
@@ -0,0 +1,5 @@
1
+ module ActiveMerchant
2
+ module Argus
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,212 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # For more information visit {Argus Payments}[http://www.arguspayments.com/pubsite/public/?/support/document]
4
+ #
5
+ # Written by Piers Chambers (Varyonic.com)
6
+ class ArgusGateway < Gateway
7
+ include Empty
8
+
9
+ self.test_url = 'https://svc.arguspayments.com/payment/pmt_service.cfm'
10
+ self.live_url = 'https://svc.arguspayments.com/payment/pmt_service.cfm'
11
+
12
+ self.supported_countries = ['US']
13
+ self.default_currency = 'USD'
14
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners, :jcb]
15
+
16
+ self.homepage_url = 'http://http://www.arguspayments.com/'
17
+ self.display_name = 'Argus Payments'
18
+
19
+ STANDARD_ERROR_CODE_MAPPING = {
20
+ '555' => STANDARD_ERROR_CODE[:call_issuer],
21
+ '600' => STANDARD_ERROR_CODE[:card_declined],
22
+ '620' => STANDARD_ERROR_CODE[:invalid_cvc],
23
+ '621' => STANDARD_ERROR_CODE[:incorrect_cvc],
24
+ '623' => STANDARD_ERROR_CODE[:incorrect_address],
25
+ '624' => STANDARD_ERROR_CODE[:expired_card],
26
+ '630' => STANDARD_ERROR_CODE[:invalid_number],
27
+ '610' => STANDARD_ERROR_CODE[:pickup_card],
28
+ }
29
+
30
+ def initialize(options={})
31
+ requires!(options, :site_id, :req_username, :req_password)
32
+ super
33
+ end
34
+
35
+ def purchase(money, payment, options={})
36
+ post = PostData.new
37
+ add_invoice(post, money, options)
38
+ add_payment(post, payment)
39
+ add_address(post, payment, options)
40
+ add_customer_data(post, options)
41
+
42
+ commit('CCAUTHCAP', post)
43
+ end
44
+
45
+ def authorize(money, payment, options={})
46
+ post = PostData.new
47
+ add_invoice(post, money, options)
48
+ add_payment(post, payment)
49
+ add_address(post, payment, options)
50
+ add_customer_data(post, options)
51
+
52
+ commit('CCAUTHORIZE', post)
53
+ end
54
+
55
+ def capture(money, authorization, options={})
56
+ post = PostData.new
57
+ post[:li_value_1] = amount(money)
58
+ post[:request_ref_po_id] = authorization
59
+ commit('CCCAPTURE', post)
60
+ end
61
+
62
+ def refund(money, authorization, options={})
63
+ post = PostData.new
64
+ post[:li_value_1] = amount(money)
65
+ post[:request_ref_po_id] = authorization
66
+ commit('CCCREDIT', post)
67
+ end
68
+
69
+ def void(authorization, options={})
70
+ post = PostData.new
71
+ post[:request_ref_po_id] = authorization
72
+ commit('CCREVERSE', post)
73
+ end
74
+
75
+ def verify(credit_card, options={})
76
+ MultiResponse.run(:use_first_response) do |r|
77
+ r.process { authorize(100, credit_card, options) }
78
+ r.process(:ignore_result) { void(r.authorization, options) }
79
+ end
80
+ end
81
+
82
+ def supports_scrubbing?
83
+ true
84
+ end
85
+
86
+ def scrub(transcript)
87
+ transcript.gsub(%r((&?pmt_numb=)[^&]*)i, '\1[FILTERED]').
88
+ gsub(%r((&?pmt_key=)[^&]*)i, '\1[FILTERED]').
89
+ gsub(%r((&?req_password=)[^&]*)i, '\1[FILTERED]')
90
+ end
91
+
92
+ private
93
+
94
+ def add_customer_data(post, options)
95
+ post[:cust_email] = options[:email] unless empty?(options[:email])
96
+ post[:cust_fname] = options[:first_name]
97
+ post[:cust_lname] = options[:last_name]
98
+ # TODO: first_name, last_name = split_names(address[:name])
99
+ add_shipping_address(post, options)
100
+ end
101
+
102
+ def add_address(post, creditcard, options)
103
+ address = options[:billing_address] || options[:address] || {}
104
+ post[:bill_addr] = truncate(address[:address1], 60)
105
+ post[:bill_addr_city] = truncate(address[:city], 40)
106
+ post[:bill_addr_country] = truncate(address[:country], 60)
107
+ post[:bill_addr_state] = empty?(address[:state]) ? 'n/a' : truncate(address[:state], 40)
108
+ post[:bill_addr_zip] = truncate((address[:zip] || options[:zip]), 20)
109
+ end
110
+
111
+ def add_shipping_address(post, options)
112
+ address = options[:shipping_address] || options[:address]
113
+ return unless address
114
+
115
+ post[:ship_addr] = truncate(address[:address1], 60)
116
+ post[:ship_addr_city] = truncate(address[:city], 40)
117
+ post[:ship_addr_country] = truncate(address[:country], 60)
118
+ post[:ship_addr_state] = empty?(address[:state]) ? 'n/a' : truncate(address[:state], 40)
119
+ post[:ship_addr_zip] = truncate((address[:zip] || options[:zip]), 20)
120
+ end
121
+
122
+ def add_invoice(post, money, options)
123
+ post[:amount] = amount(money)
124
+ post[:currency] = (options[:currency] || currency(money))
125
+ post[:li_prod_id_1] = options[:li_prod_id_1] # 'Dynamic Amount Product ID'
126
+ post[:li_value_1] = amount(money)
127
+ end
128
+
129
+ def add_payment(post, payment)
130
+ post[:pmt_expiry] = sprintf('%02d/%04d', payment.month, payment.year)
131
+ post[:pmt_key] = payment.verification_value
132
+ post[:pmt_numb] = truncate(payment.number, 16)
133
+ post[:request_currency] = 'USD'
134
+ post[:merch_acct_id] = @options[:merch_acct_id]
135
+ end
136
+
137
+ def parse(body)
138
+ JSON.parse(body)
139
+ rescue JSON::ParserError
140
+ json_error(body)
141
+ end
142
+
143
+ def json_error(body)
144
+ {
145
+ 'error' => {
146
+ 'message' => "Invalid JSON response body: #{body})",
147
+ 'raw_response' => scrub(body)
148
+ }
149
+ }
150
+ end
151
+
152
+ def commit(action, parameters)
153
+ url = (test? ? test_url : live_url)
154
+ response = parse(ssl_post(url, post_data(action, parameters)))
155
+
156
+ Response.new(
157
+ success_from(response),
158
+ message_from(response),
159
+ response,
160
+ authorization: authorization_from(response),
161
+ avs_result: AVSResult.new(code: response['AVS_RESPONSE']),
162
+ cvv_result: CVVResult.new(response['CVV_RESPONSE']),
163
+ test: test?,
164
+ error_code: error_code_from(response)
165
+ )
166
+ end
167
+
168
+ def success_from(response)
169
+ response['TRANS_STATUS_NAME'] == 'APPROVED'
170
+ end
171
+
172
+ def message_from(response)
173
+ error = [
174
+ format_error_fields(response, 'API_RESPONSE', 'API_ADVICE'), # e.g. missing/invalid credentials or data
175
+ format_error_fields(response, 'SERVICE_RESPONSE', 'SERVICE_ADVICE'), # e.g. expired card
176
+ (response['REF_FIELD'] unless empty?(response['REF_FIELD']))
177
+ ].compact.join(': ')
178
+
179
+ empty?(error) ? response['TRANS_STATUS_NAME'] : error
180
+ end
181
+
182
+ def format_error_fields(response, code, message)
183
+ "(#{response[code]}) #{response[message]}" unless ['', '0'].include? response[code].to_s
184
+ end
185
+
186
+ def authorization_from(response)
187
+ response['PO_ID'].to_s
188
+ end
189
+
190
+ def post_data(action, parameters = {})
191
+ parameters[:request_action] = action
192
+ parameters[:request_api_version] = 3.6,
193
+ parameters[:request_response_format] = 'JSON'
194
+ parameters.merge!(credentials).to_post_data
195
+ end
196
+
197
+ def credentials
198
+ {
199
+ site_id: @options[:site_id],
200
+ req_username: @options[:req_username],
201
+ req_password: @options[:req_password]
202
+ }
203
+ end
204
+
205
+ def error_code_from(response)
206
+ unless success_from(response)
207
+ STANDARD_ERROR_CODE_MAPPING[response['SERVICE_RESPONSE'].to_s]
208
+ end
209
+ end
210
+ end
211
+ end
212
+ end
@@ -0,0 +1 @@
1
+ require 'active_merchant/argus'
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activemerchant-argus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Piers Chambers
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemerchant
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1'
83
+ description:
84
+ email:
85
+ - piers@varyonic.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - active_merchant-argus.gemspec
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/active_merchant/argus.rb
101
+ - lib/active_merchant/argus/version.rb
102
+ - lib/active_merchant/billing/gateways/argus.rb
103
+ - lib/activemerchant-argus.rb
104
+ homepage: https://github.com/varyonic/activemerchant-argus
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubygems_version: 3.0.3
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Active Merchant extension to support Inovio payment gateway (f.k.a. Argus)
127
+ test_files: []