dinero_mail 0.0.1
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.
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +117 -0
- data/Rakefile +2 -0
- data/dinero_mail.gemspec +21 -0
- data/lib/dinero_mail.rb +12 -0
- data/lib/dinero_mail/client.rb +18 -0
- data/lib/dinero_mail/configuration.rb +22 -0
- data/lib/dinero_mail/operations.rb +177 -0
- data/lib/dinero_mail/response.rb +52 -0
- data/lib/dinero_mail/security.rb +14 -0
- data/lib/dinero_mail/version.rb +3 -0
- data/lib/support_ext/hash.rb +7 -0
- metadata +76 -0
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
|
20
|
+
|
21
|
+
# YARD artifacts
|
22
|
+
_yardoc
|
23
|
+
doc/
|
24
|
+
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Abraham Kuri
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# DineroMail Gem
|
2
|
+
|
3
|
+
Dinero Mail is a client which communicates with the provider API, and
|
4
|
+
interact with it.
|
5
|
+
|
6
|
+
It was developed for usage in Ruby on Rails web applications, but it
|
7
|
+
also works as a standalone library
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'dinero_mail'
|
14
|
+
|
15
|
+
Living on the edge
|
16
|
+
|
17
|
+
gem 'dinero_mail', git: 'git@github.com:IcaliaLabs/dinero_mail.git'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install dinero_mail
|
26
|
+
|
27
|
+
## Configuration
|
28
|
+
|
29
|
+
If you are on development you are ready to go!
|
30
|
+
Yeeiii
|
31
|
+
|
32
|
+
For those who are on production:
|
33
|
+
|
34
|
+
DineroMail.configure do |config|
|
35
|
+
config.environment = :production
|
36
|
+
config.username = '<username>'
|
37
|
+
config.password = '<password>'
|
38
|
+
end
|
39
|
+
|
40
|
+
## Creating a client
|
41
|
+
|
42
|
+
DM_CLIENT = DineroMail::Client.new
|
43
|
+
|
44
|
+
## Methods
|
45
|
+
|
46
|
+
DM_CLIENT.get_balance unique_message_id: '1', merchant_transaction_id: '1'
|
47
|
+
|
48
|
+
DM_CLIENT.get_operations unique_message_id: '1', merchant_transaction_id: '1', operation_id: '1',
|
49
|
+
start_date: '2012-10-6', end_date: '2012-10-10'
|
50
|
+
|
51
|
+
DM_CLIENT.send_money currency: 'MXN', amount: '100.00', to_email: 'example@example.com', pay_off: 'Producto',
|
52
|
+
subject: 'Pago de servicio', message: 'Hola mundo', merchant_transaction_id: '1', unique_message_id: '1'
|
53
|
+
|
54
|
+
DM_CLIENT.do_payment_with_reference merchant_transaction_id: '1', unique_message_id: '1', subject: 'hola', message: 'mensaje',
|
55
|
+
provider: 'oxxo', items: [{amount: '100.00', code: 'abc', currency: 'MXN', description: 'descricion', name: 'nombre',
|
56
|
+
quantity: '1'}], buyer: {name: 'abraham', last_name: 'kuri', email: 'a@a.com'}
|
57
|
+
|
58
|
+
DM_CLIENT.do_with_draw merchant_transaction_id: '1', method: 'POSTAL', currency: 'MXN', amount: '100.00',
|
59
|
+
address_detail: {street: 'mordor', number: '666', floor: '1', appartment: '5', zip: '666', city: 'inferno',
|
60
|
+
state: 'mordorTown'}, bank_account_detail: {bank:'Banco Santander', bank_number: '300', type: 'CC',
|
61
|
+
name: 'Abraham', last_name: 'Kuri', document_type: 'RFC', document_number: '2019029', branch: '1'},
|
62
|
+
unique_message_id: '1'
|
63
|
+
|
64
|
+
DM_CLIENT.do_payment_with_credit_card merchant_transaction_id: '1', items: [{amount: '100.00', code: 'abc', currency: 'MXN',
|
65
|
+
description: 'descricion', name: 'nombre', quantity: '1'}], buyer: {name: 'abraham', last_name: 'kuri',
|
66
|
+
email: 'a@a.com'}, provider: 'MX_BANORTE_TD', credit_card: {installment: '2', credit_card_number: '123456',
|
67
|
+
holder: 'adrian', expiration_date: '12/16', security_code: '1234', document_number: '1'}, unique_message_id: '1'
|
68
|
+
|
69
|
+
DM_CLIENT.get_payment_ticket currency: "MXN", amount: "100.0", provider: "oxxo",
|
70
|
+
merchant_transaction_id: "1", unique_message_id: "1"
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
1. Fork it
|
75
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
76
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
77
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
78
|
+
5. Create new Pull Request
|
79
|
+
|
80
|
+
## Changelog
|
81
|
+
<ul>
|
82
|
+
<li>Current gem version 0.0.1</li>
|
83
|
+
<li>Full integration with Rails</li>
|
84
|
+
<li></li>
|
85
|
+
</ul>
|
86
|
+
|
87
|
+
|
88
|
+
## Contributors & Patches & Forks
|
89
|
+
<ul>
|
90
|
+
<li>Abraham Kuri Vargas (@kurenn)</li>
|
91
|
+
<li>Adrián González Francke (@Adrian2112)</li>
|
92
|
+
</ul>
|
93
|
+
|
94
|
+
## Future
|
95
|
+
<ul>
|
96
|
+
<li>Writing tests (not implemented yet)</li>
|
97
|
+
<li>Add support to communicate with the IPN</li>
|
98
|
+
<li>Add button helpers</li>
|
99
|
+
</ul>
|
100
|
+
|
101
|
+
|
102
|
+
## Credits
|
103
|
+
Icalia Labs - weare@icalialabs.com
|
104
|
+
|
105
|
+
[Follow us](http://twitter.com/icalialabs "Follow us")
|
106
|
+
|
107
|
+
|
108
|
+
[Like us on Facebook](https://www.facebook.com/icalialab "Like us on Facebook")
|
109
|
+
|
110
|
+
## License
|
111
|
+
Copyright (c) 2011 Abraham Kuri Vargas
|
112
|
+
|
113
|
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
114
|
+
|
115
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
116
|
+
|
117
|
+
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/gpl.html.
|
data/Rakefile
ADDED
data/dinero_mail.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dinero_mail/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Abraham Kuri", "Adrian Gonzalez"]
|
6
|
+
gem.email = ["weare@icalialabs.com"]
|
7
|
+
gem.description = %q{Integrate Dinero Mail as PaymentOption to Rails}
|
8
|
+
gem.summary = %q{Dinero Mail Rails Integration}
|
9
|
+
gem.homepage = "https://github.com/kurenn/dinero_mail"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "dinero_mail"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = DineroMail::VERSION
|
17
|
+
gem.platform = Gem::Platform::RUBY
|
18
|
+
gem.rubyforge_project = 'dinero_mail'
|
19
|
+
|
20
|
+
gem.add_dependency "savon"
|
21
|
+
end
|
data/lib/dinero_mail.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "dinero_mail/version"
|
2
|
+
require "dinero_mail/configuration"
|
3
|
+
require 'dinero_mail/client'
|
4
|
+
|
5
|
+
module DineroMail
|
6
|
+
self.configure do |config|
|
7
|
+
config.environment = :test
|
8
|
+
config.username = 'test'
|
9
|
+
config.password = 'test'
|
10
|
+
config.secret = Digest::SHA2.hexdigest(Time.now.to_s)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'savon'
|
2
|
+
require File.dirname(__FILE__) + '/operations'
|
3
|
+
require File.dirname(__FILE__) + '/../support_ext/hash'
|
4
|
+
|
5
|
+
module DineroMail
|
6
|
+
class Client
|
7
|
+
include DineroMail::Operations
|
8
|
+
|
9
|
+
attr_reader :client, :credential, :response, :secret
|
10
|
+
|
11
|
+
def initialize(credentials = {}, secret = nil)
|
12
|
+
url = DineroMail.configuration.test? ? 'https://sandboxapi.dineromail.com/DMAPI.asmx?WSDL' : 'https://api.dineromail.com/dmapi.asmx?WSDL'
|
13
|
+
@credential = { 'APIUserName' => DineroMail.configuration.username, 'APIPassword' => DineroMail.configuration.password }
|
14
|
+
@secret = DineroMail.configuration.secret || Digest::SHA2.hexdigest(Time.now.to_s)
|
15
|
+
@client = Savon::Client.new(url)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DineroMail
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :environment, :username, :password, :secret
|
4
|
+
|
5
|
+
def test?
|
6
|
+
self.environment == :test
|
7
|
+
end
|
8
|
+
|
9
|
+
def production?
|
10
|
+
self.environment == :production
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
class << self
|
15
|
+
attr_accessor :configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configure
|
19
|
+
self.configuration ||= Configuration.new
|
20
|
+
yield configuration
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/security'
|
2
|
+
require File.dirname(__FILE__) + '/response'
|
3
|
+
|
4
|
+
module DineroMail
|
5
|
+
module Operations
|
6
|
+
include DineroMail::Security
|
7
|
+
|
8
|
+
KEYS_FOR_ACTION = {
|
9
|
+
get_balance: [:merchant_transaction_id, :unique_message_id],
|
10
|
+
get_operations: [:merchant_transaction_id, :unique_message_id, :operation_id, :start_date, :end_date],
|
11
|
+
send_money: [:merchant_transaction_id, :unique_message_id, :currency, :amount, :to_email, :pay_off, :subject, :message],
|
12
|
+
get_payment_ticket: [:merchant_transaction_id, :unique_message_id, :currency, :amount, :provider]
|
13
|
+
}
|
14
|
+
|
15
|
+
attr_reader :response
|
16
|
+
|
17
|
+
# client.get_balance unique_message_id: '1', merchant_transaction_id: '1'
|
18
|
+
# Methods: currency, status, transaction_id, merchant_transaction_id, message, amount
|
19
|
+
def get_balance(options = {})
|
20
|
+
response_for :get_balance, {
|
21
|
+
'Credential' => self.credential,
|
22
|
+
'Crypt' => 'false',
|
23
|
+
'UniqueMessageID' => options[:unique_message_id],
|
24
|
+
'MerchantTransactionId' => options[:merchant_transaction_id],
|
25
|
+
'Hash' => build_hash_for(:get_balance, options)
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# client.get_operations unique_message_id: '1', merchant_transaction_id: '1', operation_id: '1', start_date: '2012-10-6', end_date: '2012-10-10'
|
30
|
+
# Methods: operations, status, merchant_transaciont_id, message
|
31
|
+
def get_operations(options = {})
|
32
|
+
response_for :get_operations, {
|
33
|
+
'Credential' => self.credential,
|
34
|
+
'Crypt' => 'false',
|
35
|
+
'UniqueMessageID' => options[:unique_message_id],
|
36
|
+
'MerchantTransactionId' => options[:merchant_transaction_id],
|
37
|
+
'OperationId' => options[:operation_id],
|
38
|
+
'StartDate' => options[:start_date],
|
39
|
+
'EndDate' => options[:end_date],
|
40
|
+
'Hash' => build_hash_for(:get_operations, options)
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
#client.send_money currency: 'MXN', amount: '100.00', to_email: 'abraham.kuri@gmail.com', pay_off: 'Producto', subject: 'Pago becalia', message: 'Hola mundo', merchant_transaction_id: '1', unique_message_id: '1'
|
45
|
+
#Methods: transaction_id, status, merchant_transaction_id, message
|
46
|
+
def send_money(options = {})
|
47
|
+
response_for :send_money, {
|
48
|
+
'Credential' => self.credential,
|
49
|
+
'Crypt' => 'false',
|
50
|
+
'Currency' => options[:currency],
|
51
|
+
'Amount' => options[:amount],
|
52
|
+
'ToEmail' => options[:to_email],
|
53
|
+
'PayOff' => options[:pay_off],
|
54
|
+
'Subject' => options[:subject],
|
55
|
+
'Message' => options[:message],
|
56
|
+
'MerchantTransactionId' => options[:merchant_transaction_id],
|
57
|
+
'UniqueMessageID' => options[:unique_message_id],
|
58
|
+
'Hash' => build_hash_for(:send_money, options)
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
#client.do_payment_with_reference merchant_transaction_id: '1', unique_message_id: '1', subject: 'hola', message: 'mensaje', provider: 'oxxo', items: [{amount: '100.00', code: 'abc', currency: 'MXN', description: 'descricion', name: 'nombre', quantity: '1'}], buyer: {name: 'abraham', last_name: 'kuri', email: 'a@a.com'}
|
63
|
+
def do_payment_with_reference(options = {})
|
64
|
+
response_for :do_payment_with_reference, {
|
65
|
+
'Credential' => self.credential,
|
66
|
+
'Crypt' => 'false',
|
67
|
+
'MerchantTransactionId' => options[:merchant_transaction_id],
|
68
|
+
'Items' => options[:items],
|
69
|
+
'Buyer' => options[:buyer],
|
70
|
+
'Provider' => options[:provider],
|
71
|
+
'Subject' => options[:subject],
|
72
|
+
'Message' => options[:message],
|
73
|
+
'UniqueMessageID' => options[:unique_message_id],
|
74
|
+
'Hash' => do_payment_with_reference_hash(options)
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
#c.do_with_draw merchant_transaction_id: '1', method: 'POSTAL', currency: 'MXN', amount: '100.00', address_detail: {street: 'mordor', number: '666', floor: '1', appartment: '5', zip: '666', city: 'inferno', state: 'mordorTown'}, bank_account_detail: {bank:'Banco Santander', bank_number: '300', type: 'CC', name: 'Abraham', last_name: 'Kuri', document_type: 'RFC', document_number: '2019029', branch: '1'}, unique_message_id: '1'
|
79
|
+
#Methods: transaction_id, status, merchant_transaction_id, message
|
80
|
+
def do_with_draw(options = {})
|
81
|
+
response_for :do_with_draw, {
|
82
|
+
'Credential' => self.credential,
|
83
|
+
'Crypt' => 'false',
|
84
|
+
'MerchantTransactionId' => options[:merchant_transaction_id],
|
85
|
+
'Method' => options[:method],
|
86
|
+
'Currency' => options[:currency],
|
87
|
+
'Amount' => options[:amount],
|
88
|
+
'AddressDetail' => options[:address_detail],
|
89
|
+
'BankAccountDetail' => options[:bank_account_detail],
|
90
|
+
'UniqueMessageID' => options[:unique_message_id],
|
91
|
+
'Hash' => do_with_draw_hash(options)
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
#c.do_payment_with_credit_card merchant_transaction_id: '1', items: [{amount: '100.00', code: 'abc', currency: 'MXN', description: 'descricion', name: 'nombre', quantity: '1'}], buyer: {name: 'abraham', last_name: 'kuri', email: 'a@a.com'}, provider: 'MX_BANORTE_TD', credit_card: {installment: '2', credit_card_number: '123456', holder: 'adrian', expiration_date: '12/16', security_code: '1234', document_number: '1'}, unique_message_id: '1'
|
96
|
+
def do_payment_with_credit_card(options = {})
|
97
|
+
response_for :do_payment_with_credit_card, {
|
98
|
+
'Credential' => self.credential,
|
99
|
+
'Crypt' => 'false',
|
100
|
+
'MerchantTransactionId' => options[:merchant_transaction_id],
|
101
|
+
'Items' => options[:items],
|
102
|
+
'Buyer' => options[:buyer],
|
103
|
+
'Provider' => options[:provider],
|
104
|
+
'CreditCard' => options[:credit_card],
|
105
|
+
'Subject' => options[:subject],
|
106
|
+
'Message' => options[:message],
|
107
|
+
'UniqueMessageID' => options[:unique_message_id],
|
108
|
+
'Hash' => do_payment_with_credit_card_hash(options)
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
#c.get_payment_ticket currency: "MXN", amount: "100.0", provider: "oxxo", merchant_transaction_id: "1", unique_message_id: "1"
|
113
|
+
def get_payment_ticket(options = {})
|
114
|
+
response_for :get_payment_ticket, {
|
115
|
+
'Credential' => self.credential,
|
116
|
+
'Crypt' => 'false',
|
117
|
+
'Currency' => options[:currency],
|
118
|
+
'Amount' => options[:amount],
|
119
|
+
'MerchantTransactionId' => options[:merchant_transaction_id],
|
120
|
+
'Provider' => options[:provider],
|
121
|
+
'UniqueMessageID' => options[:unique_message_id],
|
122
|
+
'Hash' => build_hash_for(:get_payment_ticket, options)
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def build_hash(options = {}, *keys)
|
129
|
+
encrypt_with :md5, options.get_values_for_keys(*keys).join + self.secret
|
130
|
+
end
|
131
|
+
|
132
|
+
def build_hash_for(action, options = {})
|
133
|
+
build_hash options, *KEYS_FOR_ACTION[action]
|
134
|
+
end
|
135
|
+
|
136
|
+
def response_for(action, body = {})
|
137
|
+
response = client.request action, body: body
|
138
|
+
DineroMail::Response.new(response.to_array.first)
|
139
|
+
end
|
140
|
+
|
141
|
+
def do_payment_with_reference_hash(options = {})
|
142
|
+
itemsConcat = options[:items].map do |item|
|
143
|
+
item.get_values_for_keys(:amount, :code, :currency, :description, :name, :quantity).join
|
144
|
+
end.join
|
145
|
+
|
146
|
+
buyerConcat = options[:buyer].get_values_for_keys(:name, :last_name, :email, :address, :phone, :country, :city).join
|
147
|
+
options.merge!({items_concat: itemsConcat, buyer_concat: buyerConcat})
|
148
|
+
|
149
|
+
build_hash options, :merchant_transaction_id, :unique_message_id, :items_concat, :buyer_concat, :provider, :subject, :message
|
150
|
+
end
|
151
|
+
|
152
|
+
def do_with_draw_hash(options ={})
|
153
|
+
addressConcat = options[:address_detail].get_values_for_keys(:street, :number, :floor, :appartment, :zip, :city, :state).join
|
154
|
+
bankAccountConcat = options[:bank_account_detail].get_values_for_keys(:bank, :bank_number, :type, :name, :last_name, :document_type, :document_number, :branch).join
|
155
|
+
|
156
|
+
options.merge!({address_concat: addressConcat, bank_account_concat: bankAccountConcat })
|
157
|
+
|
158
|
+
build_hash options, :merchant_transaction_id, :unique_message_id, :method, :currency, :amount, :address_concat, :bank_account_concat
|
159
|
+
end
|
160
|
+
|
161
|
+
def do_payment_with_credit_card_hash(options = {})
|
162
|
+
itemsConcat = options[:items].map do |item|
|
163
|
+
item.get_values_for_keys(:amount, :code, :currency, :description, :name, :quantity).join
|
164
|
+
end.join
|
165
|
+
|
166
|
+
buyerConcat = options[:buyer].get_values_for_keys(:name, :last_name, :email, :address, :phone, :country, :city).join
|
167
|
+
|
168
|
+
creditcardConcat = options[:credit_card].get_values_for_keys(:installment, :credit_card_number, :holder, :expiration_date,
|
169
|
+
:security_code, :document_number, :address, :address_number, :address_complement, :zip_code, :neighborhodd, :city, :state, :country)
|
170
|
+
|
171
|
+
options.merge!({items_concat: itemsConcat, buyer_concat: buyerConcat, credit_card_concat: creditcardConcat})
|
172
|
+
|
173
|
+
build_hash options, :merchant_transaction_id, :unique_message_id, :items_concat, :buyer_concat, :credit_card_concat, :provider, :subject, :message
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module DineroMail
|
2
|
+
class Response
|
3
|
+
attr_reader :attributes
|
4
|
+
|
5
|
+
def initialize(attr = {})
|
6
|
+
@attributes = attr
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(name, *args, &block)
|
10
|
+
nested_value = nested_hash_value(@attributes, name)
|
11
|
+
if args.empty? && block.nil? && !nested_value.nil?
|
12
|
+
nested_value
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def success?
|
19
|
+
self.status == "OK" or self.status == "COMPLETED"
|
20
|
+
end
|
21
|
+
|
22
|
+
def error?
|
23
|
+
self.status == "ERROR"
|
24
|
+
end
|
25
|
+
|
26
|
+
def denied?
|
27
|
+
self.status == "DENIED"
|
28
|
+
end
|
29
|
+
|
30
|
+
def completed?
|
31
|
+
self.status == "COMPLETED" or self.status == "OK"
|
32
|
+
end
|
33
|
+
|
34
|
+
def pending?
|
35
|
+
self.status == "PENDING"
|
36
|
+
end
|
37
|
+
|
38
|
+
def procesing?
|
39
|
+
self.status == "PROCESING"
|
40
|
+
end
|
41
|
+
|
42
|
+
def nested_hash_value(obj,key)
|
43
|
+
if obj.respond_to?(:key?) && obj.key?(key)
|
44
|
+
obj[key]
|
45
|
+
elsif obj.respond_to?(:each)
|
46
|
+
r = nil
|
47
|
+
obj.find{ |*a| r=nested_hash_value(a.last,key) }
|
48
|
+
r
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dinero_mail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Abraham Kuri
|
9
|
+
- Adrian Gonzalez
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: savon
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
description: Integrate Dinero Mail as PaymentOption to Rails
|
32
|
+
email:
|
33
|
+
- weare@icalialabs.com
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- dinero_mail.gemspec
|
44
|
+
- lib/dinero_mail.rb
|
45
|
+
- lib/dinero_mail/client.rb
|
46
|
+
- lib/dinero_mail/configuration.rb
|
47
|
+
- lib/dinero_mail/operations.rb
|
48
|
+
- lib/dinero_mail/response.rb
|
49
|
+
- lib/dinero_mail/security.rb
|
50
|
+
- lib/dinero_mail/version.rb
|
51
|
+
- lib/support_ext/hash.rb
|
52
|
+
homepage: https://github.com/kurenn/dinero_mail
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project: dinero_mail
|
72
|
+
rubygems_version: 1.8.24
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Dinero Mail Rails Integration
|
76
|
+
test_files: []
|