braspag-pagador 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +164 -162
- data/braspag-pagador.gemspec +3 -3
- data/coverage/.resultset.json +69 -26
- data/coverage/index.html +1431 -1147
- data/lib/{braspag.rb → braspag-pagador.rb} +14 -14
- data/lib/{braspag → braspag-pagador}/core/connection.rb +5 -3
- data/lib/{braspag → braspag-pagador}/core/converter.rb +4 -4
- data/lib/{braspag → braspag-pagador}/core/customer.rb +2 -2
- data/lib/{braspag → braspag-pagador}/core/order.rb +51 -51
- data/lib/{braspag → braspag-pagador}/core/poster.rb +1 -1
- data/lib/{braspag → braspag-pagador}/crypto/no_crypto.rb +2 -2
- data/lib/{braspag → braspag-pagador}/crypto/webservice.rb +10 -10
- data/lib/{braspag → braspag-pagador}/payment/billet.rb +10 -10
- data/lib/{braspag → braspag-pagador}/payment/credit_card.rb +8 -8
- data/lib/{braspag → braspag-pagador}/payment/eft.rb +3 -3
- data/lib/{braspag → braspag-pagador}/payment/recurrency_credit_card.rb +1 -1
- data/lib/{braspag → braspag-pagador}/templates/crypto/decrypt.xml.erb +0 -0
- data/lib/{braspag → braspag-pagador}/templates/crypto/encrypt.xml.erb +0 -0
- data/lib/{braspag → braspag-pagador}/templates/justclick/archive.xml.erb +0 -0
- data/lib/{braspag → braspag-pagador}/templates/justclick/get_recurrency.xml.erb +0 -0
- data/lib/{braspag → braspag-pagador}/templates/justclick/recurrency.xml.erb +0 -0
- data/lib/braspag-pagador/version.rb +3 -0
- data/spec/core/connection_spec.rb +50 -50
- data/spec/core/converter_spec.rb +41 -41
- data/spec/core/customer_spec.rb +2 -2
- data/spec/core/order_spec.rb +78 -78
- data/spec/core/poster_spec.rb +8 -8
- data/spec/crypto/webservice_spec.rb +23 -23
- data/spec/integration/billet_spec.rb +11 -11
- data/spec/payment/billet_spec.rb +48 -48
- data/spec/payment/credit_card_spec.rb +82 -82
- data/spec/payment/eft_spec.rb +25 -25
- data/spec/payment/recurrency_credit_card_spec.rb +11 -11
- data/spec/spec_helper.rb +5 -5
- metadata +20 -20
- data/lib/braspag/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f06155846ca19f7ce7df707c5977f92b032cb775
|
4
|
+
data.tar.gz: 492b3624ff1e90a2e50965342ddf16c536e654de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fe8a71ef53a3252a5df433cae723819bb5f96f9009463df4e0fc7366569525dc4386f0ad54e5865635f749e03b2664427e44c7d8e3bec9b6efd4fea4bf55010
|
7
|
+
data.tar.gz: 852c5a60371a6b7c9c69eb69524425a9d3114e2477fe176de7e12c284b152b121ed3657def7e358f2d6f3023fcd829461bf966e9fa2f6f6239ade3cae78ad807
|
data/README.md
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
|
3
|
+
# braspag-pagador [![Build Status](https://travis-ci.org/raphaelcosta/braspag-pagador.png?branch=master)](https://travis-ci.org/raphaelcosta/braspag-pagador)
|
2
4
|
|
3
5
|
braspag-pagador gem to use Braspag gateway
|
4
|
-
|
6
|
+
|
5
7
|
- Support most operations in gateway
|
6
8
|
- Compatible with Active Merchant response object
|
7
9
|
- Support multiple connections easy
|
8
10
|
|
9
11
|
## RUN INTEGRATION TEST
|
10
|
-
|
12
|
+
|
11
13
|
BRASPAG_MERCHANT_ID={YOUR_MECHANT_ID} be rspec -t integration
|
12
14
|
|
13
15
|
## Usage CreditCard
|
@@ -16,82 +18,82 @@ braspag-pagador gem to use Braspag gateway
|
|
16
18
|
credit card details.
|
17
19
|
|
18
20
|
require 'rubygems'
|
19
|
-
require 'braspag'
|
20
|
-
|
21
|
-
gateway =
|
21
|
+
require 'braspag-pagador'
|
22
|
+
|
23
|
+
gateway = BraspagPagador::Connection.new(
|
22
24
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
23
25
|
:environment => :homologation
|
24
26
|
)
|
25
|
-
|
27
|
+
|
26
28
|
# The card verification value is also known as CVV2, CVC2, or CID
|
27
|
-
credit_card =
|
29
|
+
credit_card = BraspagPagador::CreditCard.new(
|
28
30
|
:holder_name => 'Bob Bobsen',
|
29
31
|
:number => '4242424242424242',
|
30
32
|
:month => '8',
|
31
33
|
:year => '2012',
|
32
34
|
:verification_value => '123'
|
33
35
|
)
|
34
|
-
|
35
|
-
customer =
|
36
|
+
|
37
|
+
customer = BraspagPagador::Customer.new(
|
36
38
|
:name => 'Bob Dela Bobsen'
|
37
39
|
)
|
38
|
-
|
39
|
-
order =
|
40
|
-
:payment_method =>
|
40
|
+
|
41
|
+
order = BraspagPagador::Order.new(
|
42
|
+
:payment_method => BraspagPagador::PAYMENT_METHOD[:redecard],
|
41
43
|
:id => 11,
|
42
44
|
:amount => 10.00, # $10.00 (accepts all amounts as Integer values in cents)
|
43
45
|
:customer => customer,
|
44
46
|
:installments => 1,
|
45
|
-
:installments_type =>
|
47
|
+
:installments_type => BraspagPagador::INTEREST[:no]
|
46
48
|
)
|
47
|
-
|
49
|
+
|
48
50
|
# Validating the card automatically detects the card type
|
49
51
|
if credit_card.valid?(:purchase) && customer.valid?(:purchase) && order.valid?(:purchase)
|
50
52
|
# Capture $10 from the credit card
|
51
53
|
response = gateway.purchase(order, credit_card)
|
52
|
-
|
54
|
+
|
53
55
|
if response.success?
|
54
56
|
puts "Successfully charged $#{sprintf("%.2f", order.amount / 100)} to the credit card #{order.gateway_id}"
|
55
57
|
else
|
56
58
|
raise StandardError, response.message
|
57
59
|
end
|
58
60
|
end
|
59
|
-
|
61
|
+
|
60
62
|
## Usage Billet
|
61
63
|
|
62
64
|
This simple example demonstrates how create billet to a person.
|
63
65
|
|
64
66
|
require 'rubygems'
|
65
|
-
require 'braspag'
|
67
|
+
require 'braspag-pagador'
|
66
68
|
|
67
|
-
gateway =
|
69
|
+
gateway = BraspagPagador::Connection.new(
|
68
70
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
69
71
|
:environment => :homologation
|
70
72
|
)
|
71
|
-
|
72
|
-
billet =
|
73
|
+
|
74
|
+
billet = BraspagPagador::Billet.new(
|
73
75
|
:id => '123456', # (optional if configured in gateway)
|
74
76
|
:instructions => 'does not accepted after due date', # (optional)
|
75
77
|
:due_date_on => Date.parse('2012-01-01')
|
76
78
|
)
|
77
|
-
|
78
|
-
customer =
|
79
|
+
|
80
|
+
customer = BraspagPagador::Customer.new(
|
79
81
|
:document => '21473696240', # (OPTIONAL)
|
80
82
|
:name => 'Bob Dela Bobsen',
|
81
83
|
:email => 'bob@mailinator.com' # send email to consumer (OPTIONAL)
|
82
84
|
)
|
83
|
-
|
84
|
-
order =
|
85
|
-
:payment_method =>
|
85
|
+
|
86
|
+
order = BraspagPagador::Order.new(
|
87
|
+
:payment_method => BraspagPagador::PAYMENT_METHOD[:billet_bradesco],
|
86
88
|
:id => 11,
|
87
89
|
:amount => 10.00, # $10.00 (accepts all amounts as Integer values in cents)
|
88
90
|
:customer => customer
|
89
91
|
)
|
90
|
-
|
92
|
+
|
91
93
|
# Validating the card automatically detects the card type
|
92
94
|
if billet.valid?(:generate) && customer.valid?(:generate) && order.valid?(:generate)
|
93
95
|
response = gateway.generate_billet(order, billet)
|
94
|
-
|
96
|
+
|
95
97
|
if response.success?
|
96
98
|
puts "Successfully created billet, open in:#{billet.url}"
|
97
99
|
else
|
@@ -104,38 +106,38 @@ braspag-pagador gem to use Braspag gateway
|
|
104
106
|
This simple example demonstrates how create eft to a person.
|
105
107
|
|
106
108
|
require 'rubygems'
|
107
|
-
require 'braspag'
|
108
|
-
|
109
|
-
gateway =
|
109
|
+
require 'braspag-pagador'
|
110
|
+
|
111
|
+
gateway = BraspagPagador::Connection.new(
|
110
112
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
111
113
|
:environment => :homologation
|
112
114
|
)
|
113
|
-
|
115
|
+
|
114
116
|
#USING Braspag Webservice
|
115
|
-
eft =
|
116
|
-
:crypto =>
|
117
|
+
eft = BraspagPagador::EFT.new(
|
118
|
+
:crypto => BraspagPagador::Crypto::Webservice.new
|
117
119
|
)
|
118
|
-
|
120
|
+
|
119
121
|
#Without Crypto
|
120
|
-
eft =
|
121
|
-
:crypto =>
|
122
|
+
eft = BraspagPagador::EFT.new(
|
123
|
+
:crypto => BraspagPagador::Crypto::NoCrypto.new
|
122
124
|
)
|
123
|
-
|
124
|
-
customer =
|
125
|
+
|
126
|
+
customer = BraspagPagador::Customer.new(
|
125
127
|
:name => 'Bob Dela Bobsen'
|
126
128
|
)
|
127
|
-
|
128
|
-
order =
|
129
|
-
:payment_method =>
|
129
|
+
|
130
|
+
order = BraspagPagador::Order.new(
|
131
|
+
:payment_method => BraspagPagador::PAYMENT_METHOD[:eft_itau],
|
130
132
|
:id => 1234,
|
131
133
|
:amount => '1000', # $10.00 (accepts all amounts as Integer values in cents)
|
132
134
|
:customer => customer
|
133
135
|
)
|
134
|
-
|
136
|
+
|
135
137
|
# Validating the card automatically detects the card type
|
136
138
|
if eft.valid?(:generate) && customer.valid?(:generate) && order.valid?(:generate)
|
137
139
|
response = gateway.generate_eft(order, eft)
|
138
|
-
|
140
|
+
|
139
141
|
if response.success?
|
140
142
|
puts "Successfully created eft, continue in:#{eft.code}"
|
141
143
|
else
|
@@ -144,45 +146,45 @@ braspag-pagador gem to use Braspag gateway
|
|
144
146
|
end
|
145
147
|
|
146
148
|
## CREDITCARD AUTHORIZE
|
147
|
-
|
149
|
+
|
148
150
|
This simple example demonstrates how a authorize can be made using a person's
|
149
151
|
credit card details.
|
150
152
|
|
151
153
|
require 'rubygems'
|
152
|
-
require 'braspag'
|
153
|
-
|
154
|
-
gateway =
|
154
|
+
require 'braspag-pagador'
|
155
|
+
|
156
|
+
gateway = BraspagPagador::Connection.new(
|
155
157
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
156
158
|
:environment => :homologation
|
157
159
|
)
|
158
|
-
|
160
|
+
|
159
161
|
# The card verification value is also known as CVV2, CVC2, or CID
|
160
|
-
credit_card =
|
162
|
+
credit_card = BraspagPagador::CreditCard.new(
|
161
163
|
:holder_name => 'Bob Bobsen',
|
162
164
|
:number => '4242424242424242',
|
163
165
|
:month => '8',
|
164
166
|
:year => '2012',
|
165
167
|
:verification_value => '123'
|
166
168
|
)
|
167
|
-
|
168
|
-
customer =
|
169
|
+
|
170
|
+
customer = BraspagPagador::Customer.new(
|
169
171
|
:name => 'Bob Dela Bobsen'
|
170
172
|
)
|
171
|
-
|
172
|
-
order =
|
173
|
-
:payment_method =>
|
173
|
+
|
174
|
+
order = BraspagPagador::Order.new(
|
175
|
+
:payment_method => BraspagPagador::PAYMENT_METHOD[:redecard],
|
174
176
|
:id => 11,
|
175
177
|
:amount => '1000', # $10.00 (accepts all amounts as Integer values in cents)
|
176
178
|
:customer => customer,
|
177
179
|
:installments => 1,
|
178
|
-
:installments_type =>
|
180
|
+
:installments_type => BraspagPagador::INTEREST[:no]
|
179
181
|
)
|
180
|
-
|
182
|
+
|
181
183
|
# Validating the card automatically detects the card type
|
182
184
|
if credit_card.valid?(:authorize) && customer.valid?(:authorize) && order.valid?(:authorize)
|
183
185
|
# Authorize $10 from the credit card
|
184
186
|
response = gateway.authorize(order, credit_card)
|
185
|
-
|
187
|
+
|
186
188
|
if response.success?
|
187
189
|
puts "Successfully authorized $#{sprintf("%.2f", order.amount / 100)} to the credit card #{order.gateway_id}"
|
188
190
|
else
|
@@ -195,20 +197,20 @@ braspag-pagador gem to use Braspag gateway
|
|
195
197
|
This simple example demonstrates how a capture can be made, after authorize.
|
196
198
|
|
197
199
|
require 'rubygems'
|
198
|
-
require 'braspag'
|
199
|
-
|
200
|
-
gateway =
|
200
|
+
require 'braspag-pagador'
|
201
|
+
|
202
|
+
gateway = BraspagPagador::Connection.new(
|
201
203
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
202
204
|
:environment => :homologation
|
203
205
|
)
|
204
|
-
|
205
|
-
order =
|
206
|
+
|
207
|
+
order = BraspagPagador::Order.new(
|
206
208
|
:id => 11
|
207
209
|
)
|
208
|
-
|
210
|
+
|
209
211
|
# Capture $10 from the credit card
|
210
212
|
response = gateway.capture(order)
|
211
|
-
|
213
|
+
|
212
214
|
if response.success?
|
213
215
|
puts "Successfully charged #{order.id}"
|
214
216
|
else
|
@@ -216,238 +218,238 @@ braspag-pagador gem to use Braspag gateway
|
|
216
218
|
end
|
217
219
|
|
218
220
|
## CREDITCARD VOID
|
219
|
-
|
221
|
+
|
220
222
|
This simple example demonstrates how a void transaction can be made.
|
221
223
|
|
222
224
|
require 'rubygems'
|
223
|
-
require 'braspag'
|
224
|
-
|
225
|
-
gateway =
|
225
|
+
require 'braspag-pagador'
|
226
|
+
|
227
|
+
gateway = BraspagPagador::Connection.new(
|
226
228
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
227
229
|
:environment => :homologation
|
228
230
|
)
|
229
|
-
|
230
|
-
order =
|
231
|
+
|
232
|
+
order = BraspagPagador::Order.new(
|
231
233
|
:id => 11
|
232
234
|
)
|
233
|
-
|
235
|
+
|
234
236
|
response = gateway.void(order)
|
235
|
-
|
237
|
+
|
236
238
|
if response.success?
|
237
239
|
puts "Successfully charged #{order.id}"
|
238
240
|
else
|
239
241
|
raise StandardError, response.message
|
240
242
|
end
|
241
|
-
|
243
|
+
|
242
244
|
### Partial Void
|
243
245
|
|
244
246
|
If need specify partial amount
|
245
|
-
|
246
|
-
|
247
|
+
|
248
|
+
|
247
249
|
response = gateway.void(order, '500')
|
248
|
-
|
249
|
-
|
250
|
+
|
251
|
+
|
250
252
|
|
251
253
|
## ORDER INFO
|
252
254
|
|
253
255
|
Sometimes your need get status in braspag
|
254
|
-
|
256
|
+
|
255
257
|
> order = Order.new(:id => "1234")
|
256
258
|
> response = gateway.get(order)
|
257
|
-
|
259
|
+
|
258
260
|
> if response.success?
|
259
261
|
> puts order.authorization
|
260
262
|
> "148519"
|
261
|
-
|
263
|
+
|
262
264
|
> puts order.payment_method_name
|
263
265
|
> "Boleto Santander"
|
264
|
-
|
266
|
+
|
265
267
|
> puts order.payment_method
|
266
268
|
> "06"
|
267
|
-
|
268
|
-
> puts
|
269
|
+
|
270
|
+
> puts BraspagPagador::Converter.payment_method_name?(order.payment_method)
|
269
271
|
> :billet_bradesco
|
270
|
-
|
272
|
+
|
271
273
|
> puts order.installments
|
272
274
|
> 1
|
273
|
-
|
275
|
+
|
274
276
|
> puts order.status
|
275
277
|
> 4
|
276
|
-
|
277
|
-
> puts
|
278
|
+
|
279
|
+
> puts BraspagPagador::Converter.status_name?(order.status)
|
278
280
|
> :cancelled
|
279
|
-
|
281
|
+
|
280
282
|
> puts order.amount
|
281
283
|
> 500
|
282
|
-
|
283
|
-
> # Kind a datetime
|
284
|
+
|
285
|
+
> # Kind a datetime
|
284
286
|
> puts order.gateway_cancelled_at
|
285
287
|
> 2012-10-13 03:30:15 -0300
|
286
288
|
|
287
289
|
> # Kind a datetime
|
288
290
|
> puts order.gateway_paid_at
|
289
291
|
> 2012-10-12 13:42:30 -0300
|
290
|
-
|
291
|
-
> # Kind a datetime
|
292
|
+
|
293
|
+
> # Kind a datetime
|
292
294
|
> puts order.gateway_created_at
|
293
295
|
> 2012-10-11 17:44:23 -0300
|
294
|
-
|
296
|
+
|
295
297
|
> puts order.transaction_id
|
296
298
|
> "342818"
|
297
|
-
|
299
|
+
|
298
300
|
> puts order.gateway_id
|
299
301
|
> "02ff02e2-f1ce-4c2b-a874-a20bb98fb97e<"
|
300
|
-
|
302
|
+
|
301
303
|
> else
|
302
304
|
> puts response.code
|
303
305
|
> "XPTO"
|
304
|
-
|
306
|
+
|
305
307
|
> puts response.message
|
306
308
|
> puts "ERROR XPTO"
|
307
309
|
> end
|
308
|
-
|
309
310
|
|
310
|
-
|
311
|
+
|
312
|
+
|
311
313
|
### CREDITCARD DETAILS
|
312
314
|
|
313
315
|
If order is a credit card, extras fields returning:
|
314
|
-
|
316
|
+
|
315
317
|
> order = Order.new(:id => "1234")
|
316
318
|
> response = gateway.get(order)
|
317
|
-
|
319
|
+
|
318
320
|
> puts order.credit_card.checking_number
|
319
321
|
> "342818"
|
320
|
-
|
322
|
+
|
321
323
|
> puts order.credit_card.avs
|
322
324
|
> false
|
323
|
-
|
325
|
+
|
324
326
|
> puts order.credit_card.autorization_number
|
325
327
|
> "148519"
|
326
|
-
|
328
|
+
|
327
329
|
> puts order.credit_card.card_number
|
328
330
|
> "345678*****0007"
|
329
|
-
|
331
|
+
|
330
332
|
> puts order.credit_card.transaction_number
|
331
333
|
> "101014343175"
|
332
|
-
|
334
|
+
|
333
335
|
> puts order.credit_card.avs_response
|
334
336
|
> "XPX RESPONSE"
|
335
|
-
|
337
|
+
|
336
338
|
> puts order.credit_card.issuing
|
337
339
|
> "XPX"
|
338
|
-
|
340
|
+
|
339
341
|
> puts order.credit_card.authenticated_number
|
340
342
|
> "112934"
|
341
|
-
|
343
|
+
|
342
344
|
|
343
345
|
### BILL DETAILS
|
344
346
|
|
345
347
|
If order is a billet, extras fields returning:
|
346
|
-
|
348
|
+
|
347
349
|
> order = Order.new(:id => "1234")
|
348
350
|
> response = gateway.get(order)
|
349
|
-
|
351
|
+
|
350
352
|
> puts order.customer.name
|
351
353
|
> "Teste"
|
352
|
-
|
354
|
+
|
353
355
|
> puts order.billet.id
|
354
356
|
> "00070475"
|
355
|
-
|
357
|
+
|
356
358
|
> puts order.billet.code
|
357
359
|
> "35690.00361 03962.030007 00000.704759 6 54930000010000"
|
358
|
-
|
359
|
-
> # Kind a date
|
360
|
+
|
361
|
+
> # Kind a date
|
360
362
|
> puts order.billet.created_at
|
361
363
|
> 2012-10-11
|
362
364
|
|
363
|
-
> # Kind a date
|
365
|
+
> # Kind a date
|
364
366
|
> puts order.billet.due_date_on
|
365
367
|
> 2012-10-13
|
366
|
-
|
368
|
+
|
367
369
|
> puts order.billet.receiver
|
368
370
|
> "Codeminer42"
|
369
|
-
|
371
|
+
|
370
372
|
> puts order.billet.bank
|
371
373
|
> "356-5"
|
372
|
-
|
374
|
+
|
373
375
|
> puts order.billet.agency
|
374
376
|
> "0003"
|
375
|
-
|
377
|
+
|
376
378
|
> puts order.billet.account
|
377
379
|
> "6039620"
|
378
|
-
|
380
|
+
|
379
381
|
> puts order.billet.wallet
|
380
382
|
> "57"
|
381
|
-
|
383
|
+
|
382
384
|
> puts order.billet.amount
|
383
385
|
> 100.00
|
384
|
-
|
386
|
+
|
385
387
|
> puts order.billet.amount_paid
|
386
388
|
> 100.00
|
387
|
-
|
388
|
-
> # Kind a date
|
389
|
+
|
390
|
+
> # Kind a date
|
389
391
|
> puts order.billet.paid_at
|
390
392
|
> 2012-10-12
|
391
393
|
|
392
394
|
## CREDITCARD RECURRING SAVE
|
393
|
-
|
394
|
-
Save credit card in Braspag PCI Compliant
|
395
|
+
|
396
|
+
Save credit card in Braspag PCI Compliant
|
395
397
|
|
396
398
|
require 'rubygems'
|
397
|
-
require 'braspag'
|
398
|
-
|
399
|
-
gateway =
|
399
|
+
require 'braspag-pagador'
|
400
|
+
|
401
|
+
gateway = BraspagPagador::Connection.new(
|
400
402
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
401
403
|
:environment => :homologation
|
402
404
|
)
|
403
|
-
|
405
|
+
|
404
406
|
# The card verification value is also known as CVV2, CVC2, or CID
|
405
|
-
credit_card =
|
407
|
+
credit_card = BraspagPagador::CreditCard.new(
|
406
408
|
:holder_name => 'Bob Bobsen',
|
407
409
|
:number => '4242424242424242',
|
408
410
|
:month => '8',
|
409
411
|
:year => '2012',
|
410
412
|
:alias => 'Card Visa' #(OPTIONAL)
|
411
413
|
)
|
412
|
-
|
413
|
-
customer =
|
414
|
+
|
415
|
+
customer = BraspagPagador::Customer.new(
|
414
416
|
:name => 'Bob Dela Bobsen'
|
415
417
|
:document => '21473696240' #(OPTIONAL)
|
416
418
|
)
|
417
|
-
|
419
|
+
|
418
420
|
# Validating the card automatically detects the card type
|
419
421
|
if credit_card.valid?(:archive) && customer.valid?(:archive)
|
420
422
|
response = gateway.archive(credit_card, customer, "00000000-0000-0000-0000-000000000044")
|
421
|
-
|
423
|
+
|
422
424
|
if response.success?
|
423
425
|
puts "Successfully saved credit_card! The just key #{credit_card.id}"
|
424
426
|
else
|
425
427
|
raise StandardError, response.message
|
426
428
|
end
|
427
429
|
end
|
428
|
-
|
430
|
+
|
429
431
|
## CREDITCARD RECURRING GET
|
430
432
|
|
431
433
|
Request the credit card info in Braspag PCI Compliant
|
432
|
-
|
434
|
+
|
433
435
|
require 'rubygems'
|
434
|
-
require 'braspag'
|
435
|
-
|
436
|
-
gateway =
|
436
|
+
require 'braspag-pagador'
|
437
|
+
|
438
|
+
gateway = BraspagPagador::Connection.new(
|
437
439
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
438
440
|
:environment => :homologation
|
439
441
|
)
|
440
|
-
|
442
|
+
|
441
443
|
# The card verification value is also known as CVV2, CVC2, or CID
|
442
|
-
credit_card =
|
444
|
+
credit_card = BraspagPagador::CreditCard.new(
|
443
445
|
:id => '123123123123123',
|
444
446
|
:alias => 'Card Visa' #(OPTIONAL)
|
445
447
|
)
|
446
|
-
|
448
|
+
|
447
449
|
# Validating the card automatically detects the card type
|
448
450
|
if credit_card.valid?(:get_recurrency)
|
449
451
|
response = gateway.get_recurrency(credit_card)
|
450
|
-
|
452
|
+
|
451
453
|
if response.success?
|
452
454
|
puts "Successfully get credit!"
|
453
455
|
puts "Holder: #{credit_card.holder_name}"
|
@@ -458,52 +460,52 @@ braspag-pagador gem to use Braspag gateway
|
|
458
460
|
raise StandardError, response.message
|
459
461
|
end
|
460
462
|
end
|
461
|
-
|
462
|
-
|
463
|
+
|
464
|
+
|
463
465
|
## CREDITCARD RECURRING PURCHASE
|
464
466
|
|
465
467
|
Purchase order using recurrence
|
466
|
-
|
468
|
+
|
467
469
|
require 'rubygems'
|
468
|
-
require 'braspag'
|
469
|
-
|
470
|
-
gateway =
|
470
|
+
require 'braspag-pagador'
|
471
|
+
|
472
|
+
gateway = BraspagPagador::Connection.new(
|
471
473
|
:merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
|
472
474
|
:environment => :homologation
|
473
475
|
)
|
474
|
-
|
476
|
+
|
475
477
|
# The card verification value is also known as CVV2, CVC2, or CID
|
476
|
-
credit_card =
|
478
|
+
credit_card = BraspagPagador::CreditCard.new(
|
477
479
|
:id => '123415',
|
478
480
|
:verification_value => '123',
|
479
481
|
:alias => 'Card Visa' #(OPTIONAL)
|
480
482
|
)
|
481
|
-
|
482
|
-
customer =
|
483
|
+
|
484
|
+
customer = BraspagPagador::Customer.new(
|
483
485
|
:name => 'Bob Dela Bobsen'
|
484
486
|
)
|
485
|
-
|
486
|
-
order =
|
487
|
-
:payment_method =>
|
487
|
+
|
488
|
+
order = BraspagPagador::Order.new(
|
489
|
+
:payment_method => BraspagPagador::PAYMENT_METHOD[:redecard],
|
488
490
|
:id => 11,
|
489
491
|
:amount => 10.00, # $10.00 (accepts all amounts as Integer values in cents)
|
490
492
|
:customer => customer,
|
491
493
|
:installments => 1,
|
492
|
-
:installments_type =>
|
494
|
+
:installments_type => BraspagPagador::INTEREST[:no]
|
493
495
|
)
|
494
|
-
|
496
|
+
|
495
497
|
# Validating the card automatically detects the card type
|
496
498
|
if credit_card.valid?(:recurrency) && customer.valid?(:recurrency) && order.valid?(:recurrency)
|
497
499
|
# Capture $10 from the credit card
|
498
500
|
response = gateway.recurrency(order, credit_card, "00000000-0000-0000-0000-000000000044")
|
499
|
-
|
501
|
+
|
500
502
|
if response.success?
|
501
503
|
puts "Successfully charged $#{sprintf("%.2f", order.amount / 100)} to the credit card #{credit_card.id}"
|
502
504
|
else
|
503
505
|
raise StandardError, response.message
|
504
506
|
end
|
505
507
|
en
|
506
|
-
|
508
|
+
|
507
509
|
|
508
510
|
# License
|
509
511
|
|