cbraspag 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -3
- data/cbraspag.gemspec +2 -0
- data/coverage/.resultset.json +3445 -0
- data/coverage/assets/0.5.3/app.js +88 -0
- data/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
- data/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/coverage/assets/0.5.3/favicon_green.png +0 -0
- data/coverage/assets/0.5.3/favicon_red.png +0 -0
- data/coverage/assets/0.5.3/favicon_yellow.png +0 -0
- data/coverage/assets/0.5.3/highlight.css +129 -0
- data/coverage/assets/0.5.3/highlight.pack.js +1 -0
- data/coverage/assets/0.5.3/jquery-1.6.2.min.js +18 -0
- data/coverage/assets/0.5.3/jquery.dataTables.min.js +152 -0
- data/coverage/assets/0.5.3/jquery.timeago.js +141 -0
- data/coverage/assets/0.5.3/jquery.url.js +174 -0
- data/coverage/assets/0.5.3/loading.gif +0 -0
- data/coverage/assets/0.5.3/magnify.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +295 -0
- data/coverage/assets/0.5.3/stylesheet.css +383 -0
- data/coverage/index.html +21549 -0
- data/lib/cbraspag.rb +1 -1
- data/lib/cbraspag/core/connection.rb +25 -20
- data/lib/cbraspag/core/converter.rb +22 -119
- data/lib/cbraspag/core/customer.rb +0 -24
- data/lib/cbraspag/core/order.rb +179 -129
- data/lib/cbraspag/payment/billet.rb +38 -17
- data/lib/cbraspag/payment/credit_card.rb +86 -112
- data/lib/cbraspag/payment/eft.rb +0 -16
- data/lib/cbraspag/payment/recurrency_credit_card.rb +99 -0
- data/lib/cbraspag/version.rb +1 -1
- data/spec/core/connection_spec.rb +56 -2
- data/spec/core/converter_spec.rb +49 -10
- data/spec/core/order_spec.rb +315 -193
- data/spec/integration/billet_spec.rb +38 -0
- data/spec/integration/credit_card_spec.rb +0 -0
- data/spec/payment/billet_spec.rb +130 -81
- data/spec/payment/credit_card_spec.rb +263 -487
- data/spec/payment/recurrency_credit_card_spec.rb +479 -0
- data/spec/spec_helper.rb +15 -2
- metadata +92 -6
- data/Guardfile +0 -10
- data/lib/cbraspag/core/response.rb +0 -27
- data/spec/core/response_spec.rb +0 -5
@@ -4,10 +4,9 @@ module Braspag
|
|
4
4
|
class Connection
|
5
5
|
def generate_billet(order, billet)
|
6
6
|
response = self.post(:generate_billet, order, billet)
|
7
|
-
|
8
7
|
status = (response[:status] == "0")
|
9
8
|
|
10
|
-
Response.new(status,
|
9
|
+
ActiveMerchant::Billing::Response.new(status,
|
11
10
|
response[:message],
|
12
11
|
response,
|
13
12
|
:test => homologation?,
|
@@ -20,6 +19,7 @@ module Braspag
|
|
20
19
|
|
21
20
|
class DueDateValidator < ActiveModel::EachValidator
|
22
21
|
def validate_each(record, attribute, value)
|
22
|
+
# unless value.class.in? [Date, Time]
|
23
23
|
unless (
|
24
24
|
value.kind_of?(Time) || value.kind_of?(Date)
|
25
25
|
)
|
@@ -28,31 +28,52 @@ module Braspag
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
attr_accessor :id, :instructions, :due_date_on, :url
|
31
|
+
attr_accessor :id, :instructions, :due_date_on, :url, :code, :created_at, :due_date_on
|
32
|
+
attr_accessor :receiver, :bank, :agency, :account, :wallet, :amount, :amount_paid, :paid_at
|
32
33
|
|
33
34
|
validates :id, :length => {:minimum => 1, :maximum => 255, :on => :generate, :allow_blank => true }
|
34
35
|
validates :instructions, :length => {:minimum => 1, :maximum => 512, :on => :generate, :allow_blank => true }
|
35
36
|
validates :due_date_on, :presence => { :on => :generate }
|
36
37
|
validates :due_date_on, :due_date => { :on => :generate }
|
37
38
|
|
38
|
-
def
|
39
|
-
self.send("to_#{method}")
|
40
|
-
end
|
41
|
-
|
42
|
-
def to_generate_billet
|
39
|
+
def self.to_generate_billet(connection, order, billet)
|
43
40
|
{
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
"merchantId" => connection.merchant_id,
|
42
|
+
"boletoNumber" => billet.id.to_s,
|
43
|
+
"instructions" => billet.instructions.to_s,
|
44
|
+
"expirationDate" => billet.due_date_on.strftime("%d/%m/%y"),
|
45
|
+
"customerName" => order.customer.name.to_s,
|
46
|
+
"customerIdNumber" => order.customer.document.to_s,
|
47
|
+
"emails" => order.customer.email.to_s,
|
48
|
+
"orderId" => order.id.to_s,
|
49
|
+
"amount" => Braspag::Converter::decimal_to_string(order.amount),
|
50
|
+
"paymentMethod" => order.payment_method
|
47
51
|
}
|
48
52
|
end
|
49
53
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def self.from_generate_billet(connection, order, billet, params)
|
55
|
+
response = Braspag::Converter::hash_from_xml(params.body, {
|
56
|
+
:url => nil,
|
57
|
+
:amount => nil,
|
58
|
+
:number => "boletoNumber",
|
59
|
+
:expiration_date => Proc.new { |document|
|
60
|
+
begin
|
61
|
+
Date.parse(document.search("expirationDate").first.to_s)
|
62
|
+
rescue
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
},
|
66
|
+
:return_code => "returnCode",
|
67
|
+
:status => nil,
|
68
|
+
:message => nil
|
69
|
+
})
|
70
|
+
|
71
|
+
order.gateway_return_code = response[:return_code]
|
72
|
+
order.gateway_status = response[:status]
|
73
|
+
order.gateway_amount = BigDecimal.new(response[:amount].to_s) if response[:amount]
|
74
|
+
billet.url = response[:url]
|
75
|
+
|
76
|
+
response
|
56
77
|
end
|
57
78
|
end
|
58
79
|
end
|
@@ -11,7 +11,7 @@ module Braspag
|
|
11
11
|
|
12
12
|
status = (response[:status] == "0" || response[:status] == "1")
|
13
13
|
|
14
|
-
Response.new(status,
|
14
|
+
ActiveMerchant::Billing::Response.new(status,
|
15
15
|
response[:message],
|
16
16
|
response,
|
17
17
|
:test => homologation?,
|
@@ -23,7 +23,7 @@ module Braspag
|
|
23
23
|
|
24
24
|
status = (response[:status] == "0")
|
25
25
|
|
26
|
-
Response.new(status,
|
26
|
+
ActiveMerchant::Billing::Response.new(status,
|
27
27
|
response[:message],
|
28
28
|
response,
|
29
29
|
:test => homologation?,
|
@@ -35,117 +35,19 @@ module Braspag
|
|
35
35
|
|
36
36
|
status = (response[:status] == "0")
|
37
37
|
|
38
|
-
Response.new(status,
|
38
|
+
ActiveMerchant::Billing::Response.new(status,
|
39
39
|
response[:message],
|
40
40
|
response,
|
41
41
|
:test => homologation?)
|
42
42
|
end
|
43
|
-
|
44
|
-
PROTECTED_CARD_MAPPING = {
|
45
|
-
:request_id => "RequestId",
|
46
|
-
:merchant_id => "MerchantKey",
|
47
|
-
:customer_name => "CustomerName",
|
48
|
-
:holder => "CardHolder",
|
49
|
-
:card_number => "CardNumber",
|
50
|
-
:expiration => "CardExpiration"
|
51
|
-
}
|
52
|
-
|
53
|
-
JUST_CLICK_MAPPING = {
|
54
|
-
:request_id => "RequestId",
|
55
|
-
:merchant_id => "MerchantKey",
|
56
|
-
:customer_name => "CustomerName",
|
57
|
-
:order_id => "OrderId",
|
58
|
-
:amount => "Amount",
|
59
|
-
:payment_method => "PaymentMethod",
|
60
|
-
:number_installments => "NumberInstallments",
|
61
|
-
:payment_type => "PaymentType",
|
62
|
-
:just_click_key => "JustClickKey",
|
63
|
-
:security_code => "SecurityCode"
|
64
|
-
}
|
65
|
-
|
66
|
-
|
67
|
-
# saves credit card in Braspag PCI Compliant
|
68
|
-
def archive(credit_card, customer, request_id)
|
69
|
-
return ::Response
|
70
|
-
|
71
|
-
self.check_protected_card_params(params)
|
72
|
-
|
73
|
-
data = { 'saveCreditCardRequestWS' => {} }
|
74
|
-
|
75
|
-
PROTECTED_CARD_MAPPING.each do |k, v|
|
76
|
-
data['saveCreditCardRequestWS'][v] = params[k] || ""
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
client = Savon::Client.new(self.save_protected_card_url)
|
81
|
-
response = client.request(:web, :save_credit_card) do
|
82
|
-
soap.body = data
|
83
|
-
end
|
84
|
-
|
85
|
-
response.to_hash[:save_credit_card_response][:save_credit_card_result]
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
# request the credit card info in Braspag PCI Compliant
|
90
|
-
def get_recurrency(credit_card)
|
91
|
-
return ::Response
|
92
|
-
|
93
|
-
raise InvalidJustClickKey unless valid_just_click_key?(just_click_key)
|
94
|
-
|
95
|
-
data = { 'getCreditCardRequestWS' => {:loja => connection.merchant_id, :justClickKey => just_click_key} }
|
96
|
-
|
97
|
-
request = ::HTTPI::Request.new(self.get_protected_card_url)
|
98
|
-
request.body = { 'getCreditCardRequestWS' => {:loja => connection.merchant_id, :justClickKey => just_click_key} }
|
99
|
-
|
100
|
-
response = ::HTTPI.post(request)
|
101
|
-
|
102
|
-
response = Utils::convert_to_map(response.body, {
|
103
|
-
:holder => "CardHolder",
|
104
|
-
:card_number => "CardNumber",
|
105
|
-
:expiration => "CardExpiration",
|
106
|
-
:masked_card_number => "MaskedCardNumber"
|
107
|
-
})
|
108
|
-
|
109
|
-
raise UnknownError if response[:card_number].nil?
|
110
|
-
response
|
111
|
-
end
|
112
|
-
|
113
|
-
def recurrency(order, credit_card, request_id)
|
114
|
-
return ::Response
|
115
|
-
|
116
|
-
self.check_just_click_shop_params(params)
|
117
|
-
|
118
|
-
order_id = params[:order_id]
|
119
|
-
raise InvalidOrderId unless self.valid_order_id?(order_id)
|
120
|
-
|
121
|
-
data = { 'justClickShopRequestWS' => {} }
|
122
|
-
|
123
|
-
JUST_CLICK_MAPPING.each do |k, v|
|
124
|
-
case k
|
125
|
-
when :payment_method
|
126
|
-
data['justClickShopRequestWS'][v] = Braspag::Connection.instance.homologation? ? PAYMENT_METHODS[:braspag] : PAYMENT_METHODS[params[:payment_method]]
|
127
|
-
else
|
128
|
-
data['justClickShopRequestWS'][v] = params[k] || ""
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
client = Savon::Client.new(self.just_click_shop_url)
|
133
|
-
response = client.request(:web, :just_click_shop) do
|
134
|
-
soap.body = data
|
135
|
-
end
|
136
|
-
|
137
|
-
response.to_hash[:just_click_shop_response][:just_click_shop_result]
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
43
|
end
|
143
44
|
|
144
|
-
|
145
45
|
class CreditCard
|
146
46
|
include ::ActiveAttr::Model
|
147
47
|
|
148
48
|
attr_accessor :holder_name, :number, :month, :year, :verification_value, :alias, :id
|
49
|
+
attr_accessor :checking_number, :avs, :autorization_number, :transaction_number
|
50
|
+
attr_accessor :avs_response, :issuing, :authenticated_number
|
149
51
|
|
150
52
|
class ExpiratorValidator < ActiveModel::EachValidator
|
151
53
|
def validate_each(record, attribute, value)
|
@@ -181,23 +83,95 @@ module Braspag
|
|
181
83
|
[:get_recurrency, :recurrency].each do |check_on|
|
182
84
|
validates :id, :length => {:is => 36, :on => check_on}
|
183
85
|
end
|
86
|
+
|
87
|
+
def self.to_authorize(connection, order, credit_card)
|
88
|
+
year_normalize = credit_card.year.to_s[-2, 2]
|
89
|
+
{
|
90
|
+
"merchantId" => connection.merchant_id,
|
91
|
+
"holder" => credit_card.holder_name.to_s,
|
92
|
+
"cardNumber" => credit_card.number.to_s,
|
93
|
+
"expiration" => "#{credit_card.month}/#{year_normalize}",
|
94
|
+
"securityCode" => credit_card.verification_value.to_s,
|
95
|
+
"customerName" => order.customer.name.to_s,
|
96
|
+
"orderId" => order.id.to_s,
|
97
|
+
"amount" => Braspag::Converter::decimal_to_string(order.amount),
|
98
|
+
"paymentMethod" => order.payment_method,
|
99
|
+
"numberPayments" => order.installments,
|
100
|
+
"typePayment" => order.installments_type
|
101
|
+
}
|
102
|
+
end
|
184
103
|
|
185
|
-
def
|
186
|
-
|
104
|
+
def self.from_authorize(connection, order, credit_card, params)
|
105
|
+
response = Braspag::Converter::hash_from_xml(params.body, {
|
106
|
+
:amount => nil,
|
107
|
+
:number => "authorisationNumber",
|
108
|
+
:message => nil,
|
109
|
+
:return_code => 'returnCode',
|
110
|
+
:status => nil,
|
111
|
+
:transaction_id => "transactionId"
|
112
|
+
})
|
113
|
+
|
114
|
+
order.gateway_authorization = response[:number]
|
115
|
+
order.gateway_id = response[:transaction_id]
|
116
|
+
order.gateway_return_code = response[:return_code]
|
117
|
+
order.gateway_status = response[:status]
|
118
|
+
order.gateway_message = response[:message]
|
119
|
+
order.gateway_amount = Braspag::Converter::string_to_decimal(response[:amount])
|
120
|
+
|
121
|
+
response
|
187
122
|
end
|
188
123
|
|
189
|
-
def
|
190
|
-
year_normalize = year.to_s[-2, 2]
|
124
|
+
def self.to_capture(connection, order)
|
191
125
|
{
|
192
|
-
|
193
|
-
|
194
|
-
:expiration => "#{self.month}/#{year_normalize}",
|
195
|
-
:security_code => self.verification_value.to_s,
|
126
|
+
"merchantId" => connection.merchant_id,
|
127
|
+
"orderId" => order.id.to_s
|
196
128
|
}
|
197
129
|
end
|
198
130
|
|
199
|
-
def
|
131
|
+
def self.from_capture(connection, order, params)
|
132
|
+
response = Braspag::Converter::hash_from_xml(params.body, {
|
133
|
+
:amount => nil,
|
134
|
+
:message => 'message',
|
135
|
+
:return_code => 'returnCode',
|
136
|
+
:status => 'status',
|
137
|
+
:transaction_id => "transactionId"
|
138
|
+
})
|
200
139
|
|
140
|
+
#TODO: CHECK IF IS NECESSARY
|
141
|
+
# order.gateway_capture_id = response[:transaction_id]
|
142
|
+
order.gateway_capture_return_code = response[:return_code]
|
143
|
+
order.gateway_capture_status = response[:status]
|
144
|
+
order.gateway_capture_message = response[:message]
|
145
|
+
order.gateway_capture_amount = Braspag::Converter::string_to_decimal(response[:amount])
|
146
|
+
|
147
|
+
response
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.to_void(connection, order)
|
151
|
+
{
|
152
|
+
"merchantId" => connection.merchant_id,
|
153
|
+
"order" => order.id.to_s
|
154
|
+
}
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.from_void(connection, order, params)
|
158
|
+
response = Braspag::Converter::hash_from_xml(params.body, {
|
159
|
+
:order_id => "orderId",
|
160
|
+
:amount => nil,
|
161
|
+
:message => 'message',
|
162
|
+
:return_code => 'returnCode',
|
163
|
+
:status => 'status',
|
164
|
+
:transaction_id => "transactionId"
|
165
|
+
})
|
166
|
+
|
167
|
+
#TODO: CHECK IF IS NECESSARY
|
168
|
+
# order.gateway_void_id = response[:transaction_id]
|
169
|
+
order.gateway_void_return_code = response[:return_code]
|
170
|
+
order.gateway_void_status = response[:status]
|
171
|
+
order.gateway_void_message = response[:message]
|
172
|
+
order.gateway_void_amount = Braspag::Converter::string_to_decimal(response[:amount])
|
173
|
+
|
174
|
+
response
|
201
175
|
end
|
202
176
|
end
|
203
177
|
end
|
data/lib/cbraspag/payment/eft.rb
CHANGED
@@ -14,13 +14,9 @@ module Braspag
|
|
14
14
|
|
15
15
|
|
16
16
|
def self.generate_eft(order, eft)
|
17
|
-
return ::Response.new
|
18
17
|
|
19
|
-
connection = Braspag::Connection.instance
|
20
18
|
params[:merchant_id] = connection.merchant_id
|
21
19
|
|
22
|
-
params = self.normalize_params(params)
|
23
|
-
self.check_params(params)
|
24
20
|
|
25
21
|
data = {}
|
26
22
|
|
@@ -51,18 +47,6 @@ module Braspag
|
|
51
47
|
|
52
48
|
html
|
53
49
|
end
|
54
|
-
|
55
|
-
def self.normalize_params(params)
|
56
|
-
params = super
|
57
|
-
|
58
|
-
params[:installments] = params[:installments].to_i unless params[:installments].nil?
|
59
|
-
params[:installments] ||= 1
|
60
|
-
|
61
|
-
params[:has_interest] = params[:has_interest] == true ? "1" : "0"
|
62
|
-
|
63
|
-
params
|
64
|
-
end
|
65
|
-
|
66
50
|
end
|
67
51
|
|
68
52
|
class EFT
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Braspag
|
2
|
+
class Connection
|
3
|
+
PROTECTED_CARD_MAPPING = {
|
4
|
+
:request_id => "RequestId",
|
5
|
+
:merchant_id => "MerchantKey",
|
6
|
+
:customer_name => "CustomerName",
|
7
|
+
:holder => "CardHolder",
|
8
|
+
:card_number => "CardNumber",
|
9
|
+
:expiration => "CardExpiration"
|
10
|
+
}
|
11
|
+
|
12
|
+
JUST_CLICK_MAPPING = {
|
13
|
+
:request_id => "RequestId",
|
14
|
+
:merchant_id => "MerchantKey",
|
15
|
+
:customer_name => "CustomerName",
|
16
|
+
:order_id => "OrderId",
|
17
|
+
:amount => "Amount",
|
18
|
+
:payment_method => "PaymentMethod",
|
19
|
+
:number_installments => "NumberInstallments",
|
20
|
+
:payment_type => "PaymentType",
|
21
|
+
:just_click_key => "JustClickKey",
|
22
|
+
:security_code => "SecurityCode"
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
# saves credit card in Braspag PCI Compliant
|
27
|
+
def archive(credit_card, customer, request_id)
|
28
|
+
|
29
|
+
self.check_protected_card_params(params)
|
30
|
+
|
31
|
+
data = { 'saveCreditCardRequestWS' => {} }
|
32
|
+
|
33
|
+
PROTECTED_CARD_MAPPING.each do |k, v|
|
34
|
+
data['saveCreditCardRequestWS'][v] = params[k] || ""
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
client = Savon::Client.new(self.save_protected_card_url)
|
39
|
+
response = client.request(:web, :save_credit_card) do
|
40
|
+
soap.body = data
|
41
|
+
end
|
42
|
+
|
43
|
+
response.to_hash[:save_credit_card_response][:save_credit_card_result]
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# request the credit card info in Braspag PCI Compliant
|
48
|
+
def get_recurrency(credit_card)
|
49
|
+
|
50
|
+
raise InvalidJustClickKey unless valid_just_click_key?(just_click_key)
|
51
|
+
|
52
|
+
data = { 'getCreditCardRequestWS' => {:loja => connection.merchant_id, :justClickKey => just_click_key} }
|
53
|
+
|
54
|
+
request = ::HTTPI::Request.new(self.get_protected_card_url)
|
55
|
+
request.body = { 'getCreditCardRequestWS' => {:loja => connection.merchant_id, :justClickKey => just_click_key} }
|
56
|
+
|
57
|
+
response = ::HTTPI.post(request)
|
58
|
+
|
59
|
+
response = Utils::convert_to_map(response.body, {
|
60
|
+
:holder => "CardHolder",
|
61
|
+
:card_number => "CardNumber",
|
62
|
+
:expiration => "CardExpiration",
|
63
|
+
:masked_card_number => "MaskedCardNumber"
|
64
|
+
})
|
65
|
+
|
66
|
+
raise UnknownError if response[:card_number].nil?
|
67
|
+
response
|
68
|
+
end
|
69
|
+
|
70
|
+
def recurrency(order, credit_card, request_id)
|
71
|
+
|
72
|
+
self.check_just_click_shop_params(params)
|
73
|
+
|
74
|
+
order_id = params[:order_id]
|
75
|
+
raise InvalidOrderId unless self.valid_order_id?(order_id)
|
76
|
+
|
77
|
+
data = { 'justClickShopRequestWS' => {} }
|
78
|
+
|
79
|
+
JUST_CLICK_MAPPING.each do |k, v|
|
80
|
+
case k
|
81
|
+
when :payment_method
|
82
|
+
data['justClickShopRequestWS'][v] = Braspag::Connection.instance.homologation? ? PAYMENT_METHODS[:braspag] : PAYMENT_METHODS[params[:payment_method]]
|
83
|
+
else
|
84
|
+
data['justClickShopRequestWS'][v] = params[k] || ""
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
client = Savon::Client.new(self.just_click_shop_url)
|
89
|
+
response = client.request(:web, :just_click_shop) do
|
90
|
+
soap.body = data
|
91
|
+
end
|
92
|
+
|
93
|
+
response.to_hash[:just_click_shop_response][:just_click_shop_result]
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|