mondido 1.0.8 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mondido/base_model.rb +1 -0
- data/lib/mondido/credentials.rb +2 -1
- data/lib/mondido/credit_card/transaction.rb +33 -5
- data/lib/mondido/version.rb +1 -1
- data/spec/credit_card/transaction_spec.rb +28 -0
- metadata +13 -14
- data/Rakefile +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93e554b36550a73b880205fc196c92f9ec9408e2
|
4
|
+
data.tar.gz: 15a1bffcbeb8463d3f046c5864635d3e7d6f6d18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3371cf5eabe76b51b111ebe6d62be90e52181eb453b8b3cf0a3da5cbcf4b9144951756b672151fb1b2a92d4318ad5c6febd557af669f5246def3b87acf4a9f2e
|
7
|
+
data.tar.gz: 2b7815803b5d38e2d51bea12a7be6c7a7fb6aae33869b48ecbd67ed4cd647742fe5de68e6087d6e1f94b53895cf1e4d3dd4114b4009a54621fd136eb47c3fe0a
|
data/lib/mondido/base_model.rb
CHANGED
@@ -35,6 +35,7 @@ module Mondido
|
|
35
35
|
object = self.new(attributes)
|
36
36
|
object.valid? # Will raise exception if validation fails
|
37
37
|
|
38
|
+
object.set_merchant_id! if object.respond_to? :set_merchant_id!
|
38
39
|
object.set_hash! if object.respond_to? :set_hash!
|
39
40
|
|
40
41
|
response = Mondido::RestClient.process(object)
|
data/lib/mondido/credentials.rb
CHANGED
@@ -24,7 +24,8 @@ module Mondido
|
|
24
24
|
def self.setup
|
25
25
|
config_file = File.join(Rails.root, 'config', 'mondido.yml')
|
26
26
|
if File.exist?(config_file)
|
27
|
-
|
27
|
+
template = ERB.new File.read(config_file)
|
28
|
+
yaml = YAML.load template.result(binding)
|
28
29
|
@@merchant_id = yaml['merchant_id']
|
29
30
|
@@secret = yaml['secret']
|
30
31
|
@@password = yaml['password']
|
@@ -27,7 +27,19 @@ module Mondido
|
|
27
27
|
:customer,
|
28
28
|
:subscription,
|
29
29
|
:payment_details,
|
30
|
-
:hash
|
30
|
+
:hash,
|
31
|
+
:webhooks,
|
32
|
+
:payment_request,
|
33
|
+
:template_id,
|
34
|
+
:error,
|
35
|
+
:success_url,
|
36
|
+
:error_url,
|
37
|
+
:refund,
|
38
|
+
:customer,
|
39
|
+
:store_card,
|
40
|
+
:href,
|
41
|
+
:plan_id,
|
42
|
+
:process
|
31
43
|
|
32
44
|
validates :currency,
|
33
45
|
presence: { message: 'errors.currency.missing' },
|
@@ -63,9 +75,11 @@ module Mondido
|
|
63
75
|
end
|
64
76
|
|
65
77
|
def self.create(attributes={})
|
66
|
-
metadata
|
67
|
-
|
68
|
-
|
78
|
+
['metadata', 'webhooks'].each do |a|
|
79
|
+
attribute = attributes[:"#{a}"]
|
80
|
+
attribute = attribute.to_json if attribute && attribute.respond_to?(:to_json)
|
81
|
+
attributes[:"#{a}"] = attribute
|
82
|
+
end
|
69
83
|
super(attributes)
|
70
84
|
end
|
71
85
|
|
@@ -73,8 +87,22 @@ module Mondido
|
|
73
87
|
super
|
74
88
|
end
|
75
89
|
|
90
|
+
def set_merchant_id!
|
91
|
+
unless self.merchant_id
|
92
|
+
self.merchant_id = Mondido::Credentials.merchant_id
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
76
96
|
def set_hash!
|
77
|
-
unhashed = [
|
97
|
+
unhashed = [
|
98
|
+
Mondido::Credentials.merchant_id,
|
99
|
+
payment_ref,
|
100
|
+
customer_ref,
|
101
|
+
amount,
|
102
|
+
currency,
|
103
|
+
( (test) ? "test" : "" ),
|
104
|
+
Mondido::Credentials.secret
|
105
|
+
].map(&:to_s)
|
78
106
|
self.hash = Digest::MD5.hexdigest(unhashed.join)
|
79
107
|
end
|
80
108
|
|
data/lib/mondido/version.rb
CHANGED
@@ -66,6 +66,34 @@ describe Mondido::CreditCard::Transaction do
|
|
66
66
|
expect(@transaction.payment_ref).to eq(@transaction_hash['payment_ref'])
|
67
67
|
end
|
68
68
|
|
69
|
+
it 'generates the correct hash' do
|
70
|
+
transaction = Mondido::CreditCard::Transaction.new({
|
71
|
+
:merchant_id => Mondido::Credentials.merchant_id.to_s,
|
72
|
+
:payment_ref => "PaymentRefValue",
|
73
|
+
:customer_ref => "CustomerRefValue",
|
74
|
+
:amount => "10.00",
|
75
|
+
:currency => "sek",
|
76
|
+
:test => true,
|
77
|
+
:secret => Mondido::Credentials.secret.to_s
|
78
|
+
})
|
79
|
+
|
80
|
+
transaction.set_hash!
|
81
|
+
|
82
|
+
# Calculate hash
|
83
|
+
unhashed = [
|
84
|
+
Mondido::Credentials.merchant_id.to_s,
|
85
|
+
"PaymentRefValue",
|
86
|
+
"CustomerRefValue",
|
87
|
+
"10.00",
|
88
|
+
"sek",
|
89
|
+
"test",
|
90
|
+
Mondido::Credentials.secret
|
91
|
+
].map(&:to_s)
|
92
|
+
hash = Digest::MD5.hexdigest(unhashed.join)
|
93
|
+
|
94
|
+
expect(transaction.hash).to eq(hash)
|
95
|
+
end
|
96
|
+
|
69
97
|
end
|
70
98
|
|
71
99
|
context 'invalid call' do
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mondido
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Falkén
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: webmock
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Library for making payments with Mondido, visit https://mondido.com to
|
@@ -60,6 +60,8 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- MIT-LICENSE
|
64
|
+
- lib/mondido.rb
|
63
65
|
- lib/mondido/base_behaviour.rb
|
64
66
|
- lib/mondido/base_model.rb
|
65
67
|
- lib/mondido/config.rb
|
@@ -75,9 +77,6 @@ files:
|
|
75
77
|
- lib/mondido/rest_client.rb
|
76
78
|
- lib/mondido/version.rb
|
77
79
|
- lib/mondido/webhook.rb
|
78
|
-
- lib/mondido.rb
|
79
|
-
- MIT-LICENSE
|
80
|
-
- Rakefile
|
81
80
|
- spec/credit_card/refund_spec.rb
|
82
81
|
- spec/credit_card/stored_card_spec.rb
|
83
82
|
- spec/credit_card/transaction_spec.rb
|
@@ -96,17 +95,17 @@ require_paths:
|
|
96
95
|
- lib
|
97
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
97
|
requirements:
|
99
|
-
- -
|
98
|
+
- - ">="
|
100
99
|
- !ruby/object:Gem::Version
|
101
100
|
version: '0'
|
102
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
102
|
requirements:
|
104
|
-
- -
|
103
|
+
- - ">="
|
105
104
|
- !ruby/object:Gem::Version
|
106
105
|
version: '0'
|
107
106
|
requirements: []
|
108
107
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.2.2
|
110
109
|
signing_key:
|
111
110
|
specification_version: 4
|
112
111
|
summary: SDK for consuming the Mondido API
|
data/Rakefile
DELETED
@@ -1,32 +0,0 @@
|
|
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
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'MondidoSdk'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Bundler::GemHelper.install_tasks
|
21
|
-
|
22
|
-
require 'rake/testtask'
|
23
|
-
|
24
|
-
Rake::TestTask.new(:test) do |t|
|
25
|
-
t.libs << 'lib'
|
26
|
-
t.libs << 'test'
|
27
|
-
t.pattern = 'test/**/*_test.rb'
|
28
|
-
t.verbose = false
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
task default: :test
|