Skip to content

Commit

Permalink
vPos: Adding Panal Credit Card type
Browse files Browse the repository at this point in the history
Summary:
------------------------------
Add the panal credit card type and enables it for
vPos gateway

Unit Tests:
------------------------------
Finished in 38.864306 seconds.
5542 tests, 77546 assertions, 0 failures, 0 errors,
0 pendings, 0 omissions, 0 notifications
100% passed

RuboCop:
------------------------------
760 files inspected, no offenses detectednitial commit
  • Loading branch information
jherreraa authored and naashton committed Jul 5, 2023
1 parent 997d88e commit 9c393c2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/active_merchant/billing/credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Billing #:nodoc:
# * Edenred
# * Anda
# * Creditos directos (Tarjeta D)
# * Panal
#
# For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
# validations, allowing you to focus on your core concerns until you're ready to be more concerned
Expand Down Expand Up @@ -130,6 +131,7 @@ def number=(value)
# * +'edenred'+
# * +'anda'+
# * +'tarjeta-d'+
# * +'panal'+
#
# Or, if you wish to test your implementation, +'bogus'+.
#
Expand Down
8 changes: 6 additions & 2 deletions lib/active_merchant/billing/credit_card_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ module CreditCardMethods
'edenred' => ->(num) { num =~ /^637483\d{10}$/ },
'anda' => ->(num) { num =~ /^603199\d{10}$/ },
'tarjeta-d' => ->(num) { num =~ /^601828\d{10}$/ },
'hipercard' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), HIPERCARD_RANGES) }
'hipercard' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), HIPERCARD_RANGES) },
'panal' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), PANAL_RANGES) }
}

SODEXO_NO_LUHN = ->(num) { num =~ /^(505864|505865)\d{10}$/ }
Expand Down Expand Up @@ -182,7 +183,8 @@ module CreditCardMethods
(601256..601276),
(601640..601652),
(601689..601700),
(602011..602050),
(602011..602048),
[602050],
(630400..630499),
(639000..639099),
(670000..679999),
Expand Down Expand Up @@ -247,6 +249,8 @@ module CreditCardMethods
637568..637568, 637599..637599, 637609..637609, 637612..637612
]

PANAL_RANGES = [[602049]]

def self.included(base)
base.extend(ClassMethods)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/vpos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class VposGateway < Gateway

self.supported_countries = ['PY']
self.default_currency = 'PYG'
self.supported_cardtypes = %i[visa master]
self.supported_cardtypes = %i[visa master panal]

self.homepage_url = 'https://comercios.bancard.com.py'
self.display_name = 'vPOS'
Expand Down
4 changes: 4 additions & 0 deletions test/unit/credit_card_methods_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ def test_electron_cards
assert_false electron_test.call('42496200000000000')
end

def test_should_detect_panal_card
assert_equal 'panal', CreditCard.brand?('6020490000000000')
end

def test_credit_card?
assert credit_card.credit_card?
end
Expand Down

0 comments on commit 9c393c2

Please sign in to comment.