braspag-pagador 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.md +23 -0
  6. data/README.md +532 -0
  7. data/RELEASES.md +20 -0
  8. data/Rakefile +6 -0
  9. data/braspag-pagador.gemspec +32 -0
  10. data/coverage/.resultset.json +2732 -0
  11. data/coverage/assets/0.5.3/app.js +88 -0
  12. data/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
  13. data/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
  14. data/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
  15. data/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
  16. data/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
  17. data/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
  18. data/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
  19. data/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
  20. data/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
  21. data/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
  22. data/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
  23. data/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
  24. data/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
  25. data/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
  26. data/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
  27. data/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
  28. data/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
  29. data/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
  30. data/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
  31. data/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
  32. data/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +363 -0
  33. data/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  34. data/coverage/assets/0.5.3/favicon_green.png +0 -0
  35. data/coverage/assets/0.5.3/favicon_red.png +0 -0
  36. data/coverage/assets/0.5.3/favicon_yellow.png +0 -0
  37. data/coverage/assets/0.5.3/highlight.css +129 -0
  38. data/coverage/assets/0.5.3/highlight.pack.js +1 -0
  39. data/coverage/assets/0.5.3/jquery-1.6.2.min.js +18 -0
  40. data/coverage/assets/0.5.3/jquery.dataTables.min.js +152 -0
  41. data/coverage/assets/0.5.3/jquery.timeago.js +141 -0
  42. data/coverage/assets/0.5.3/jquery.url.js +174 -0
  43. data/coverage/assets/0.5.3/loading.gif +0 -0
  44. data/coverage/assets/0.5.3/magnify.png +0 -0
  45. data/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  46. data/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  47. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  48. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  49. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  50. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  51. data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  52. data/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  53. data/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
  54. data/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  55. data/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
  56. data/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
  57. data/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  58. data/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  59. data/coverage/assets/0.5.3/stylesheet.css +383 -0
  60. data/coverage/index.html +17219 -0
  61. data/lib/braspag.rb +96 -0
  62. data/lib/braspag/core/connection.rb +112 -0
  63. data/lib/braspag/core/converter.rb +63 -0
  64. data/lib/braspag/core/customer.rb +13 -0
  65. data/lib/braspag/core/order.rb +286 -0
  66. data/lib/braspag/core/poster.rb +40 -0
  67. data/lib/braspag/crypto/no_crypto.rb +6 -0
  68. data/lib/braspag/crypto/webservice.rb +63 -0
  69. data/lib/braspag/payment/billet.rb +79 -0
  70. data/lib/braspag/payment/credit_card.rb +190 -0
  71. data/lib/braspag/payment/eft.rb +65 -0
  72. data/lib/braspag/payment/recurrency_credit_card.rb +15 -0
  73. data/lib/braspag/templates/crypto/decrypt.xml.erb +10 -0
  74. data/lib/braspag/templates/crypto/encrypt.xml.erb +14 -0
  75. data/lib/braspag/templates/justclick/archive.xml.erb +16 -0
  76. data/lib/braspag/templates/justclick/get_recurrency.xml.erb +12 -0
  77. data/lib/braspag/templates/justclick/recurrency.xml.erb +23 -0
  78. data/lib/braspag/version.rb +3 -0
  79. data/spec/core/connection_spec.rb +149 -0
  80. data/spec/core/converter_spec.rb +123 -0
  81. data/spec/core/customer_spec.rb +49 -0
  82. data/spec/core/order_spec.rb +504 -0
  83. data/spec/core/poster_spec.rb +63 -0
  84. data/spec/crypto/webservice_spec.rb +136 -0
  85. data/spec/integration/billet_spec.rb +38 -0
  86. data/spec/integration/credit_card_spec.rb +0 -0
  87. data/spec/payment/billet_spec.rb +205 -0
  88. data/spec/payment/credit_card_spec.rb +385 -0
  89. data/spec/payment/eft_spec.rb +88 -0
  90. data/spec/payment/recurrency_credit_card_spec.rb +100 -0
  91. data/spec/spec_helper.rb +24 -0
  92. metadata +292 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 80b855a49d710c369a3edf4efdad286b8a901382
4
+ data.tar.gz: 764727b7d53e994d75d03ed784cd4024c596b3a0
5
+ SHA512:
6
+ metadata.gz: 112f138e782e1e25d06475799faaac7d2b39274ede15d79d56d7d8a2cda1db4bf713a4f1a249d5439ca5c700e1776818374b3b2ff571fc289a7048523b984572
7
+ data.tar.gz: a7a88a9fe0154d2c0dff81f2dde94bdd6940706d47871e830237eb3dda681d54fe52dd83b928a79d64eac95ff79498289288120fc092b40f4d9d72ec33384d40
@@ -0,0 +1,9 @@
1
+ nbproject
2
+ pkg
3
+ doc
4
+ tags
5
+ *.sw*
6
+ .bundle
7
+ .rvmrc
8
+ Gemfile.lock
9
+
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in braspag.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2012 - Codeminer42 contato(at)codeminer42.com
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 NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
@@ -0,0 +1,532 @@
1
+ # braspag-pagador
2
+
3
+ braspag-pagador gem to use Braspag gateway
4
+
5
+ - Support most operations in gateway
6
+ - Compatible with Active Merchant response object
7
+ - Support multiple connections easy
8
+
9
+ ## RUN INTEGRATION TEST
10
+
11
+ BRASPAG_MERCHANT_ID={YOUR_MECHANT_ID} be rspec -t integration
12
+
13
+ ## Usage CreditCard
14
+
15
+ This simple example demonstrates how a purchase can be made using a person's
16
+ credit card details.
17
+
18
+ require 'rubygems'
19
+ require 'braspag'
20
+
21
+ gateway = Braspag::Connection.new(
22
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
23
+ :environment => :homologation
24
+ )
25
+
26
+ # The card verification value is also known as CVV2, CVC2, or CID
27
+ credit_card = Braspag::CreditCard.new(
28
+ :holder_name => 'Bob Bobsen',
29
+ :number => '4242424242424242',
30
+ :month => '8',
31
+ :year => '2012',
32
+ :verification_value => '123'
33
+ )
34
+
35
+ customer = Braspag::Customer.new(
36
+ :name => 'Bob Dela Bobsen'
37
+ )
38
+
39
+ order = Braspag::Order.new(
40
+ :payment_method => Braspag::PAYMENT_METHOD[:redecard],
41
+ :id => 11,
42
+ :amount => 10.00, # $10.00 (accepts all amounts as Integer values in cents)
43
+ :customer => customer,
44
+ :installments => 1,
45
+ :installments_type => Braspag::INTEREST[:no]
46
+ )
47
+
48
+ # Validating the card automatically detects the card type
49
+ if credit_card.valid?(:purchase) && customer.valid?(:purchase) && order.valid?(:purchase)
50
+ # Capture $10 from the credit card
51
+ response = gateway.purchase(order, credit_card)
52
+
53
+ if response.success?
54
+ puts "Successfully charged $#{sprintf("%.2f", order.amount / 100)} to the credit card #{order.gateway_id}"
55
+ else
56
+ raise StandardError, response.message
57
+ end
58
+ end
59
+
60
+ ## Usage Billet
61
+
62
+ This simple example demonstrates how create billet to a person.
63
+
64
+ require 'rubygems'
65
+ require 'braspag'
66
+
67
+ gateway = Braspag::Connection.new(
68
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
69
+ :environment => :homologation
70
+ )
71
+
72
+ billet = Braspag::Billet.new(
73
+ :id => '123456', # (optional if configured in gateway)
74
+ :instructions => 'does not accepted after due date', # (optional)
75
+ :due_date_on => Date.parse('2012-01-01')
76
+ )
77
+
78
+ customer = Braspag::Customer.new(
79
+ :document => '21473696240', # (OPTIONAL)
80
+ :name => 'Bob Dela Bobsen',
81
+ :email => 'bob@mailinator.com' # send email to consumer (OPTIONAL)
82
+ )
83
+
84
+ order = Braspag::Order.new(
85
+ :payment_method => Braspag::PAYMENT_METHOD[:billet_bradesco],
86
+ :id => 11,
87
+ :amount => 10.00, # $10.00 (accepts all amounts as Integer values in cents)
88
+ :customer => customer
89
+ )
90
+
91
+ # Validating the card automatically detects the card type
92
+ if billet.valid?(:generate) && customer.valid?(:generate) && order.valid?(:generate)
93
+ response = gateway.generate_billet(order, billet)
94
+
95
+ if response.success?
96
+ puts "Successfully created billet, open in:#{billet.url}"
97
+ else
98
+ raise StandardError, response.message
99
+ end
100
+ end
101
+
102
+ ## Usage EFT (Eletronic Founds Transfer)
103
+
104
+ This simple example demonstrates how create eft to a person.
105
+
106
+ require 'rubygems'
107
+ require 'braspag'
108
+
109
+ gateway = Braspag::Connection.new(
110
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
111
+ :environment => :homologation
112
+ )
113
+
114
+ #USING Braspag Webservice
115
+ eft = Braspag::EFT.new(
116
+ :crypto => Braspag::Crypto::Webservice.new
117
+ )
118
+
119
+ #Without Crypto
120
+ eft = Braspag::EFT.new(
121
+ :crypto => Braspag::Crypto::NoCrypto.new
122
+ )
123
+
124
+ customer = Braspag::Customer.new(
125
+ :name => 'Bob Dela Bobsen'
126
+ )
127
+
128
+ order = Braspag::Order.new(
129
+ :payment_method => Braspag::PAYMENT_METHOD[:eft_itau],
130
+ :id => 1234,
131
+ :amount => '1000', # $10.00 (accepts all amounts as Integer values in cents)
132
+ :customer => customer
133
+ )
134
+
135
+ # Validating the card automatically detects the card type
136
+ if eft.valid?(:generate) && customer.valid?(:generate) && order.valid?(:generate)
137
+ response = gateway.generate_eft(order, eft)
138
+
139
+ if response.success?
140
+ puts "Successfully created eft, continue in:#{eft.code}"
141
+ else
142
+ raise StandardError, response.message
143
+ end
144
+ end
145
+
146
+ ## CREDITCARD AUTHORIZE
147
+
148
+ This simple example demonstrates how a authorize can be made using a person's
149
+ credit card details.
150
+
151
+ require 'rubygems'
152
+ require 'braspag'
153
+
154
+ gateway = Braspag::Connection.new(
155
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
156
+ :environment => :homologation
157
+ )
158
+
159
+ # The card verification value is also known as CVV2, CVC2, or CID
160
+ credit_card = Braspag::CreditCard.new(
161
+ :holder_name => 'Bob Bobsen',
162
+ :number => '4242424242424242',
163
+ :month => '8',
164
+ :year => '2012',
165
+ :verification_value => '123'
166
+ )
167
+
168
+ customer = Braspag::Customer.new(
169
+ :name => 'Bob Dela Bobsen'
170
+ )
171
+
172
+ order = Braspag::Order.new(
173
+ :payment_method => Braspag::PAYMENT_METHOD[:redecard],
174
+ :id => 11,
175
+ :amount => '1000', # $10.00 (accepts all amounts as Integer values in cents)
176
+ :customer => customer,
177
+ :installments => 1,
178
+ :installments_type => Braspag::INTEREST[:no]
179
+ )
180
+
181
+ # Validating the card automatically detects the card type
182
+ if credit_card.valid?(:authorize) && customer.valid?(:authorize) && order.valid?(:authorize)
183
+ # Authorize $10 from the credit card
184
+ response = gateway.authorize(order, credit_card)
185
+
186
+ if response.success?
187
+ puts "Successfully authorized $#{sprintf("%.2f", order.amount / 100)} to the credit card #{order.gateway_id}"
188
+ else
189
+ raise StandardError, response.message
190
+ end
191
+ end
192
+
193
+ ## CREDITCARD CAPTURE
194
+
195
+ This simple example demonstrates how a capture can be made, after authorize.
196
+
197
+ require 'rubygems'
198
+ require 'braspag'
199
+
200
+ gateway = Braspag::Connection.new(
201
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
202
+ :environment => :homologation
203
+ )
204
+
205
+ order = Braspag::Order.new(
206
+ :id => 11
207
+ )
208
+
209
+ # Capture $10 from the credit card
210
+ response = gateway.capture(order)
211
+
212
+ if response.success?
213
+ puts "Successfully charged #{order.id}"
214
+ else
215
+ raise StandardError, response.message
216
+ end
217
+
218
+ ## CREDITCARD VOID
219
+
220
+ This simple example demonstrates how a void transaction can be made.
221
+
222
+ require 'rubygems'
223
+ require 'braspag'
224
+
225
+ gateway = Braspag::Connection.new(
226
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
227
+ :environment => :homologation
228
+ )
229
+
230
+ order = Braspag::Order.new(
231
+ :id => 11
232
+ )
233
+
234
+ response = gateway.void(order)
235
+
236
+ if response.success?
237
+ puts "Successfully charged #{order.id}"
238
+ else
239
+ raise StandardError, response.message
240
+ end
241
+
242
+ ### Partial Void
243
+
244
+ If need specify partial amount
245
+
246
+
247
+ response = gateway.void(order, '500')
248
+
249
+
250
+
251
+ ## ORDER INFO
252
+
253
+ Sometimes your need get status in braspag
254
+
255
+ > order = Order.new(:id => "1234")
256
+ > response = gateway.get(order)
257
+
258
+ > if response.success?
259
+ > puts order.authorization
260
+ > "148519"
261
+
262
+ > puts order.payment_method_name
263
+ > "Boleto Santander"
264
+
265
+ > puts order.payment_method
266
+ > "06"
267
+
268
+ > puts Braspag::Converter.payment_method_name?(order.payment_method)
269
+ > :billet_bradesco
270
+
271
+ > puts order.installments
272
+ > 1
273
+
274
+ > puts order.status
275
+ > 4
276
+
277
+ > puts Braspag::Converter.status_name?(order.status)
278
+ > :cancelled
279
+
280
+ > puts order.amount
281
+ > 500
282
+
283
+ > # Kind a datetime
284
+ > puts order.gateway_cancelled_at
285
+ > 2012-10-13 03:30:15 -0300
286
+
287
+ > # Kind a datetime
288
+ > puts order.gateway_paid_at
289
+ > 2012-10-12 13:42:30 -0300
290
+
291
+ > # Kind a datetime
292
+ > puts order.gateway_created_at
293
+ > 2012-10-11 17:44:23 -0300
294
+
295
+ > puts order.transaction_id
296
+ > "342818"
297
+
298
+ > puts order.gateway_id
299
+ > "02ff02e2-f1ce-4c2b-a874-a20bb98fb97e<"
300
+
301
+ > else
302
+ > puts response.code
303
+ > "XPTO"
304
+
305
+ > puts response.message
306
+ > puts "ERROR XPTO"
307
+ > end
308
+
309
+
310
+
311
+ ### CREDITCARD DETAILS
312
+
313
+ If order is a credit card, extras fields returning:
314
+
315
+ > order = Order.new(:id => "1234")
316
+ > response = gateway.get(order)
317
+
318
+ > puts order.credit_card.checking_number
319
+ > "342818"
320
+
321
+ > puts order.credit_card.avs
322
+ > false
323
+
324
+ > puts order.credit_card.autorization_number
325
+ > "148519"
326
+
327
+ > puts order.credit_card.card_number
328
+ > "345678*****0007"
329
+
330
+ > puts order.credit_card.transaction_number
331
+ > "101014343175"
332
+
333
+ > puts order.credit_card.avs_response
334
+ > "XPX RESPONSE"
335
+
336
+ > puts order.credit_card.issuing
337
+ > "XPX"
338
+
339
+ > puts order.credit_card.authenticated_number
340
+ > "112934"
341
+
342
+
343
+ ### BILL DETAILS
344
+
345
+ If order is a billet, extras fields returning:
346
+
347
+ > order = Order.new(:id => "1234")
348
+ > response = gateway.get(order)
349
+
350
+ > puts order.customer.name
351
+ > "Teste"
352
+
353
+ > puts order.billet.id
354
+ > "00070475"
355
+
356
+ > puts order.billet.code
357
+ > "35690.00361 03962.030007 00000.704759 6 54930000010000"
358
+
359
+ > # Kind a date
360
+ > puts order.billet.created_at
361
+ > 2012-10-11
362
+
363
+ > # Kind a date
364
+ > puts order.billet.due_date_on
365
+ > 2012-10-13
366
+
367
+ > puts order.billet.receiver
368
+ > "Codeminer42"
369
+
370
+ > puts order.billet.bank
371
+ > "356-5"
372
+
373
+ > puts order.billet.agency
374
+ > "0003"
375
+
376
+ > puts order.billet.account
377
+ > "6039620"
378
+
379
+ > puts order.billet.wallet
380
+ > "57"
381
+
382
+ > puts order.billet.amount
383
+ > 100.00
384
+
385
+ > puts order.billet.amount_paid
386
+ > 100.00
387
+
388
+ > # Kind a date
389
+ > puts order.billet.paid_at
390
+ > 2012-10-12
391
+
392
+ ## CREDITCARD RECURRING SAVE
393
+
394
+ Save credit card in Braspag PCI Compliant
395
+
396
+ require 'rubygems'
397
+ require 'braspag'
398
+
399
+ gateway = Braspag::Connection.new(
400
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
401
+ :environment => :homologation
402
+ )
403
+
404
+ # The card verification value is also known as CVV2, CVC2, or CID
405
+ credit_card = Braspag::CreditCard.new(
406
+ :holder_name => 'Bob Bobsen',
407
+ :number => '4242424242424242',
408
+ :month => '8',
409
+ :year => '2012',
410
+ :alias => 'Card Visa' #(OPTIONAL)
411
+ )
412
+
413
+ customer = Braspag::Customer.new(
414
+ :name => 'Bob Dela Bobsen'
415
+ :document => '21473696240' #(OPTIONAL)
416
+ )
417
+
418
+ # Validating the card automatically detects the card type
419
+ if credit_card.valid?(:archive) && customer.valid?(:archive)
420
+ response = gateway.archive(credit_card, customer, "00000000-0000-0000-0000-000000000044")
421
+
422
+ if response.success?
423
+ puts "Successfully saved credit_card! The just key #{credit_card.id}"
424
+ else
425
+ raise StandardError, response.message
426
+ end
427
+ end
428
+
429
+ ## CREDITCARD RECURRING GET
430
+
431
+ Request the credit card info in Braspag PCI Compliant
432
+
433
+ require 'rubygems'
434
+ require 'braspag'
435
+
436
+ gateway = Braspag::Connection.new(
437
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
438
+ :environment => :homologation
439
+ )
440
+
441
+ # The card verification value is also known as CVV2, CVC2, or CID
442
+ credit_card = Braspag::CreditCard.new(
443
+ :id => '123123123123123',
444
+ :alias => 'Card Visa' #(OPTIONAL)
445
+ )
446
+
447
+ # Validating the card automatically detects the card type
448
+ if credit_card.valid?(:get_recurrency)
449
+ response = gateway.get_recurrency(credit_card)
450
+
451
+ if response.success?
452
+ puts "Successfully get credit!"
453
+ puts "Holder: #{credit_card.holder_name}"
454
+ puts "Number: #{credit_card.number}"
455
+ puts "Month: #{credit_card.month}"
456
+ puts "Year: #{credit_card.year}"
457
+ else
458
+ raise StandardError, response.message
459
+ end
460
+ end
461
+
462
+
463
+ ## CREDITCARD RECURRING PURCHASE
464
+
465
+ Purchase order using recurrence
466
+
467
+ require 'rubygems'
468
+ require 'braspag'
469
+
470
+ gateway = Braspag::Connection.new(
471
+ :merchant_id => '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}',
472
+ :environment => :homologation
473
+ )
474
+
475
+ # The card verification value is also known as CVV2, CVC2, or CID
476
+ credit_card = Braspag::CreditCard.new(
477
+ :id => '123415',
478
+ :verification_value => '123',
479
+ :alias => 'Card Visa' #(OPTIONAL)
480
+ )
481
+
482
+ customer = Braspag::Customer.new(
483
+ :name => 'Bob Dela Bobsen'
484
+ )
485
+
486
+ order = Braspag::Order.new(
487
+ :payment_method => Braspag::PAYMENT_METHOD[:redecard],
488
+ :id => 11,
489
+ :amount => 10.00, # $10.00 (accepts all amounts as Integer values in cents)
490
+ :customer => customer,
491
+ :installments => 1,
492
+ :installments_type => Braspag::INTEREST[:no]
493
+ )
494
+
495
+ # Validating the card automatically detects the card type
496
+ if credit_card.valid?(:recurrency) && customer.valid?(:recurrency) && order.valid?(:recurrency)
497
+ # Capture $10 from the credit card
498
+ response = gateway.recurrency(order, credit_card, "00000000-0000-0000-0000-000000000044")
499
+
500
+ if response.success?
501
+ puts "Successfully charged $#{sprintf("%.2f", order.amount / 100)} to the credit card #{credit_card.id}"
502
+ else
503
+ raise StandardError, response.message
504
+ end
505
+ en
506
+
507
+
508
+ # License
509
+
510
+ (The MIT License)
511
+
512
+ Copyright (c) 2012 - Codeminer42 contato(at)codeminer42.com
513
+
514
+ Permission is hereby granted, free of charge, to any person obtaining
515
+ a copy of this software and associated documentation files (the
516
+ 'Software'), to deal in the Software without restriction, including
517
+ without limitation the rights to use, copy, modify, merge, publish,
518
+ distribute, sublicense, and/or sell copies of the Software, and to
519
+ permit persons to whom the Software is furnished to do so, subject to
520
+ the following conditions:
521
+
522
+ The above copyright notice and this permission notice shall be
523
+ included in all copies or substantial portions of the Software.
524
+
525
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
526
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
527
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
528
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
529
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
530
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
531
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
532
+