mongoid-active_merchant 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +57 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/mongoid/active_merchant.rb +5 -0
- data/lib/mongoid/active_merchant/billing_response.rb +61 -0
- data/lib/mongoid/active_merchant/version.rb +5 -0
- data/mongoid-active_merchant.gemspec +28 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3578b12dfdf7951ef8e02bb9ec6d43470813ae2b
|
4
|
+
data.tar.gz: 46a5ac96e486df3b549d466b74d718d036a8a871
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61731c34dbc5e4208da74f9c631ced5246a14a982ad10e3bf56b2703f4fdd842b663d83d70ad517563ece7c8c4306b84a05675cf0fe1cfd459ca8b5b2296a189
|
7
|
+
data.tar.gz: c38599042d79e24a67dd244e35a5655aa3bdfd8d2fa43a5089f25c59e8d324ed3e798399e9ad6516f9ccbe20fb2ceb40f9131e259cf342832bd669293e3a95d6
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Ben Crouse
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Mongoid::ActiveMerchant
|
2
|
+
|
3
|
+
This gem adds support for serializing/deserializing an ActiveMerchant::Billing::Response for storage with a Mongoid model.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'mongoid-active_merchant'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mongoid-active_merchant
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
class Payment
|
25
|
+
include Mongoid::Document
|
26
|
+
field :response, type: ActiveMerchant::Billing::Response
|
27
|
+
end
|
28
|
+
|
29
|
+
card = ActiveMerchant::Billing::CreditCard.new(
|
30
|
+
number: '4111111111111111',
|
31
|
+
month: '8',
|
32
|
+
year: '2009',
|
33
|
+
first_name: 'Tobias',
|
34
|
+
last_name: 'Luetke',
|
35
|
+
verification_value: '123'
|
36
|
+
)
|
37
|
+
|
38
|
+
payment = Payment.new
|
39
|
+
response = ActiveMerchant::Billing::BogusGateway.new.authorize(1000, card)
|
40
|
+
|
41
|
+
payment.response = response
|
42
|
+
payment.save!
|
43
|
+
```
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
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.
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bencrouse/mongoid-active_merchant.
|
52
|
+
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
57
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mongoid/active_merchant"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class Response
|
4
|
+
ATTRIBUTES_FOR_MONGOID_OPTIONS_SERIALIZATION = [
|
5
|
+
:test,
|
6
|
+
:authorization,
|
7
|
+
:fraud_review,
|
8
|
+
:error_code,
|
9
|
+
:emv_authorization,
|
10
|
+
:avs_result
|
11
|
+
]
|
12
|
+
|
13
|
+
def mongoize
|
14
|
+
options = ATTRIBUTES_FOR_MONGOID_OPTIONS_SERIALIZATION.reduce({}) do |result, attr|
|
15
|
+
value = instance_variable_get(:"@#{attr}")
|
16
|
+
result[attr.to_s] = value unless value.nil?
|
17
|
+
result
|
18
|
+
end
|
19
|
+
|
20
|
+
# ActiveMerchant::Billing::CvvResult doesn't take a hash to initialize,
|
21
|
+
# but it sets the Response's cvv_result instance variable to a hash.
|
22
|
+
options['cvv_result'] = @cvv_result['code'] if @cvv_result.present?
|
23
|
+
|
24
|
+
{
|
25
|
+
'success' => success?,
|
26
|
+
'message' => message,
|
27
|
+
'params' => params,
|
28
|
+
'options' => options
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
class << self
|
33
|
+
def demongoize(object)
|
34
|
+
options = object['options'].symbolize_keys
|
35
|
+
|
36
|
+
if options[:avs_result].present?
|
37
|
+
options[:avs_result] = options[:avs_result].symbolize_keys
|
38
|
+
end
|
39
|
+
|
40
|
+
Response.new(
|
41
|
+
object['success'],
|
42
|
+
object['message'],
|
43
|
+
object['params'],
|
44
|
+
options
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def mongoize(object)
|
49
|
+
case object
|
50
|
+
when Response then object.mongoize
|
51
|
+
else object
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def evolve(object)
|
56
|
+
raise 'querying on an ActiveMerchant::Billing::Response is unsupported at this time'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mongoid/active_merchant/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mongoid-active_merchant"
|
8
|
+
spec.version = Mongoid::ActiveMerchant::VERSION
|
9
|
+
spec.authors = ["Ben Crouse"]
|
10
|
+
spec.email = ["bencrouse@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Adds Mongoid serialization to ActiveMerchant responses}
|
13
|
+
spec.homepage = "https://github.com/bencrouse/mongoid-active_merchant"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'mongoid', '>= 4.0.0'
|
22
|
+
spec.add_dependency 'activemerchant', '>= 1.52'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "minitest"
|
27
|
+
spec.add_development_dependency "minitest-reporters"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongoid-active_merchant
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Crouse
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mongoid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemerchant
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.52'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.52'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest-reporters
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- bencrouse@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/console
|
111
|
+
- bin/setup
|
112
|
+
- lib/mongoid/active_merchant.rb
|
113
|
+
- lib/mongoid/active_merchant/billing_response.rb
|
114
|
+
- lib/mongoid/active_merchant/version.rb
|
115
|
+
- mongoid-active_merchant.gemspec
|
116
|
+
homepage: https://github.com/bencrouse/mongoid-active_merchant
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.4.5
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Adds Mongoid serialization to ActiveMerchant responses
|
140
|
+
test_files: []
|