Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPos: Adding Panal Credit Card type #4814

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
== HEAD
* Stripe Payment Intents: Add support for new card on file field [aenand] #4807
* Commerce Hub: Add `physicalGoodsIndicator` and `schemeReferenceTransactionId` GSFs [sinourain] #4786
* VPos: Adding Panal Credit Card type [jherreraa] #4814

== Version 1.131.0 (June 21, 2023)
* Redsys: Add supported countries [jcreiff] #4811
Expand Down
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