[libbusiness-creditcard-perl] 01/02: Backport changes from upstream releases 0.34 and 0.35
gregor herrmann
gregoa at debian.org
Tue Jun 7 20:05:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to branch jessie
in repository libbusiness-creditcard-perl.
commit 423278362ee3a9d2bb68c0b668318a9402044e4d
Author: gregor herrmann <gregoa at debian.org>
Date: Tue Jun 7 21:52:04 2016 +0200
Backport changes from upstream releases 0.34 and 0.35
to adjust to changes in credit card ranges and processing of various
companies.
Add the following patches:
- ranges.patch: adjust credit card number ranges
- receipt_cardtype.patch: add new function for new Discover receipt
requirements
- docs.patch: update documentation about processing of different cards in
various countries
Closes: #814479
---
debian/patches/docs.patch | 30 +++++++
debian/patches/ranges.patch | 162 ++++++++++++++++++++++++++++++++++
debian/patches/receipt_cardtype.patch | 46 ++++++++++
debian/patches/series | 3 +
4 files changed, 241 insertions(+)
diff --git a/debian/patches/docs.patch b/debian/patches/docs.patch
new file mode 100644
index 0000000..4d2065b
--- /dev/null
+++ b/debian/patches/docs.patch
@@ -0,0 +1,30 @@
+Description: Update POD to document mapping between card ranges and countries.
+Origin: https://metacpan.org/release/Business-CreditCard, 0.34/0.35
+Bug-Debian: https://bugs.debian.org/814479
+Author: Ivan Kohler <ivan-debian at 420.am>
+Reviewed-by: gregor herrmann <gregoa at debian.org>
+Last-Update: 2016-06-07
+
+--- a/CreditCard.pm
++++ b/CreditCard.pm
+@@ -83,7 +83,7 @@
+ other networks, in which one type of card is processed as another card type.
+
+ By default, Business::CreditCard returns the type the card should be treated as
+-in the US and Canada. You can change this to return the type the card should
++in the US. You can change this to return the type the card should
+ be treated as in a different country by setting
+ C<$Business::CreditCard::Country> to your two-letter country code. This
+ is probably what you want to determine if you accept the card, or which
+@@ -99,9 +99,9 @@
+
+ =item Most Diner's club is now identified as Discover. (This supercedes the earlier identification of some Diner's club cards as MasterCard inside the US and Canada.)
+
+-=item JCB cards in the 3528-3589 range are identified as Discover inside the US and Canada.
++=item JCB cards in the 3528-3589 range are identified as Discover inside the US and territories.
+
+-=item China Union Pay cards are identified as Discover cards outside China.
++=item China Union Pay cards are identified as Discover cards in the US, Mexico and most Caribbean countries.
+
+ =back
+
diff --git a/debian/patches/ranges.patch b/debian/patches/ranges.patch
new file mode 100644
index 0000000..3e41d5d
--- /dev/null
+++ b/debian/patches/ranges.patch
@@ -0,0 +1,162 @@
+Description: Update credit card ranges.
+Origin: https://metacpan.org/release/Business-CreditCard, 0.34/0.35
+Bug-Debian: https://bugs.debian.org/814479
+Author: Ivan Kohler <ivan-debian at 420.am>
+Reviewed-by: gregor herrmann <gregoa at debian.org>
+Last-Update: 2016-06-07
+
+--- a/CreditCard.pm
++++ b/CreditCard.pm
+@@ -194,30 +194,32 @@
+ && 0+$number;
+ }
+
+- return "VISA card" if $number =~ /^4[0-8][\dx]{11}([\dx]{3})?$/o;
++ return "VISA card" if $number =~ /^4[0-8][\dx]{11,17}$/o;
+
+ return "MasterCard"
+- if $number =~ /^5[1-5][\dx]{14}$/o
+- ;# || ( $number =~ /^36[\dx]{12}/ && $Country =~ /^(US|CA)$/oi );
++ if $number =~ /^5[1-5][\dx]{14}$/o
++ || $number =~ /^2 ( 22[1-9] | 2[3-9][\dx] | [3-6][\dx]{2} | 7[0-1][\dx] | 720 ) [\dx]{12}$/xo
++ || $number =~ /^2[2-7]xx[\dx]{12}$/o;
+
+ return "American Express card" if $number =~ /^3[47][\dx]{13}$/o;
+
+ return "Discover card"
+- if $number =~ /^30[0-5][\dx]{11}([\dx]{2})?$/o #diner's: 300-305
+- || $number =~ /^3095[\dx]{10}([\dx]{2})?$/o #diner's: 3095
+- || $number =~ /^3[689][\dx]{12}([\dx]{2})?$/o #diner's: 36 38 and 39
+- || $number =~ /^6011[\dx]{12}$/o
+- || $number =~ /^64[4-9][\dx]{13}$/o
+- || $number =~ /^65[\dx]{14}$/o
+- || ( $number =~ /^62[24-68][\dx]{13}$/o && uc($Country) ne 'CN' ) #CUP
+- || ( $number =~ /^35(2[89]|[3-8][\dx])[\dx]{12}$/o && $Country =~ /^(US|CA)$/oi ); #JCB cards in the 3528-3589 range are identified as Discover inside the US and Canada
++ if $number =~ /^30[0-5][\dx]{13,16}$/o #diner's: 300-305
++ || $number =~ /^3095[\dx]{12}$/o #diner's: 3095
++ || $number =~ /^36[\dx]{12,17}$/o #diner's: 36
++ || $number =~ /^3[89][\dx]{14,17}$/o #diner's: 38 and 39
++ || $number =~ /^6011[\dx]{12,15}$/o
++ || $number =~ /^64[4-9][\dx]{13,16}$/o
++ || $number =~ /^65[\dx]{14,17}$/o
++ || ( $number =~ /^62[24-68][\dx]{13,16}$/o && $Country =~ /^(US|MX|AI|AG|AW|BS|BB|BM|BQ|VG|KY|CW|DM|DO|GD|GP|JM|MQ|MS|BL|KN|LC|VC|MF|SX|TT|TC)$/oi ) #China Union Pay identified as Discover in US, Mexico and Caribbean
++ || ( $number =~ /^35(2[89]|[3-8][\dx])[\dx]{12,15}$/o && $Country =~ /^(US|PR|VI|MP|PW|GU)$/oi ); #JCB cards in the 3528-3589 range are identified as Discover in US, Puerto Rico, US Virgin Islands, Northern Mariana Islands, Palau and Guam
+
+ return "Switch"
+ if $number =~ /^49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})[\dx]{10}([\dx]{2,3})?$/o
+ || $number =~ /^564182[\dx]{10}([\dx]{2,3})?$/o
+ || $number =~ /^6(3(33[0-4][0-9])|759[0-9]{2})[\dx]{10}([\dx]{2,3})?$/o;
+ #redunant with above, catch 49* that's not Switch
+- return "VISA card" if $number =~ /^4[\dx]{12}([\dx]{3})?$/o;
++ return "VISA card" if $number =~ /^4[\dx]{12,18}$/o;
+
+ #return "Diner's Club/Carte Blanche"
+ # if $number =~ /^3(0[0-59]|[68][\dx])[\dx]{11}$/o;
+--- a/t/agreements.t
++++ b/t/agreements.t
+@@ -15,9 +15,9 @@
+ my %cards = (
+ '3528000000000007' => 'Discover card',
+ '3589000000000003' => 'Discover card',
+- '30000000000004' => 'Discover card',
+- '30500000000003' => 'Discover card',
+- '30950000000000' => 'Discover card',
++# '30000000000004' => 'Discover card',
++# '30500000000003' => 'Discover card',
++# '30950000000000' => 'Discover card',
+ #'6200000000000005' => 'Discover card', #is 620 a valid CUP now?
+ '6220000000000008' => 'Discover card',
+ );
+@@ -40,14 +40,23 @@
+ sub test_card_id_ca {
+ local($Business::CreditCard::Country) = 'CA';
+
++# my %cards = (
++# '3528000000000007' => 'Discover card',
++# '3589000000000003' => 'Discover card',
++## '30000000000004' => 'Discover card',
++## '30500000000003' => 'Discover card',
++## '30950000000000' => 'Discover card',
++# #'6200000000000005' => 'Discover card', #is 620 a valid CUP now?
++# '6220000000000008' => 'Discover card',
++# );
+ my %cards = (
+- '3528000000000007' => 'Discover card',
+- '3589000000000003' => 'Discover card',
+- '30000000000004' => 'Discover card',
+- '30500000000003' => 'Discover card',
+- '30950000000000' => 'Discover card',
++ '3528000000000007' => 'JCB',
++ '3589000000000003' => 'JCB',
++# '30000000000004' => 'Discover card',
++# '30500000000003' => 'Discover card',
++# '30950000000000' => 'Discover card',
+ #'6200000000000005' => 'Discover card', #is 620 a valid CUP now?
+- '6220000000000008' => 'Discover card',
++ '6220000000000008' => 'China Union Pay',
+ );
+ test_cards(\%cards);
+ }
+@@ -59,9 +68,9 @@
+ my %cards = (
+ '3528000000000007' => 'JCB',
+ '3589000000000003' => 'JCB',
+- '30000000000004' => 'Discover card',
+- '30500000000003' => 'Discover card',
+- '30950000000000' => 'Discover card',
++# '30000000000004' => 'Discover card',
++# '30500000000003' => 'Discover card',
++# '30950000000000' => 'Discover card',
+ #'6200000000000005' => 'Discover card', #is 620 a valid CUP now?
+ '6220000000000008' => 'Discover card',
+ );
+@@ -74,9 +83,9 @@
+ my %cards = (
+ '3528000000000007' => 'JCB',
+ '3589000000000003' => 'JCB',
+- '30000000000004' => 'Discover card',
+- '30500000000003' => 'Discover card',
+- '30950000000000' => 'Discover card',
++# '30000000000004' => 'Discover card',
++# '30500000000003' => 'Discover card',
++# '30950000000000' => 'Discover card',
+ #'6200000000000005' => 'Discover card', #is 620 a valid CUP now?
+ '6220000000000008' => 'China Union Pay',
+ );
+@@ -89,9 +98,9 @@
+ my %cards = (
+ '3528000000000007' => 'JCB',
+ '3589000000000003' => 'JCB',
+- '30000000000004' => 'Discover card',
+- '30500000000003' => 'Discover card',
+- '30950000000000' => 'Discover card',
++# '30000000000004' => 'Discover card',
++# '30500000000003' => 'Discover card',
++# '30950000000000' => 'Discover card',
+ #'6200000000000005' => 'Discover card', #is 620 a valid CUP now?
+
+ #XXX this is technically an issue ("base" for CUP is still CUP)
+--- a/t/test.t
++++ b/t/test.t
+@@ -13,19 +13,15 @@
+ my %test_table=(
+ '5212345678901234' => 'MasterCard',
+ '5512345678901234' => 'MasterCard',
++ '2512345678901234' => 'MasterCard',
+ '4123456789012' => 'VISA card',
++ '4929492492497' => 'VISA card',
+ '4512345678901234' => 'VISA card',
+ '341234567890123' => 'American Express card',
+ '371234567890123' => 'American Express card',
+- #'30112345678901' => "Diner's Club/Carte Blanche",
+- '30112345678901' => 'Discover card',
+- #'30512345678901' => "Diner's Club/Carte Blanche",
+- '30512345678901' => 'Discover card',
+ #'36123456789012' => "Diner's Club/Carte Blanche",
+ #'36123456789012' => 'MasterCard',
+ '36123456789012' => 'Discover card',
+- #'38123456789012' => "Diner's Club/Carte Blanche",
+- '38123456789012' => 'Discover card',
+ '201412345678901' => 'enRoute',
+ '214912345678901' => 'enRoute',
+ '6011123456789012' => 'Discover card',
diff --git a/debian/patches/receipt_cardtype.patch b/debian/patches/receipt_cardtype.patch
new file mode 100644
index 0000000..5877eeb
--- /dev/null
+++ b/debian/patches/receipt_cardtype.patch
@@ -0,0 +1,46 @@
+Description: Add function receipt_cardtype().
+ Needed for some Discover cards, as explained in the POD below.
+Origin: https://metacpan.org/release/Business-CreditCard, 0.34/0.35
+Bug-Debian: https://bugs.debian.org/814479
+Author: Ivan Kohler <ivan-debian at 420.am>
+Reviewed-by: gregor herrmann <gregoa at debian.org>
+Last-Update: 2016-06-07
+
+--- a/CreditCard.pm
++++ b/CreditCard.pm
+@@ -105,6 +105,13 @@
+
+ =back
+
++=head1 RECEIPT REQUIREMENTS
++
++Discover requires some cards processed on its network to display "PayPal"
++on receipts instead of "Discover". The receipt_cardtype() subroutine will
++return "PayPal card" for these cards only, and otherwise the same output as
++cardtype().
++
+ =head1 NOTE ON INTENDED PURPOSE
+
+ This module is for verifying I<real world> B<credit cards>. It is B<NOT> a
+@@ -246,6 +253,21 @@
+ return "Unknown";
+ }
+
++sub receipt_cardtype {
++ # Allow use as a class method
++ shift if UNIVERSAL::isa( $_[0], 'Business::CreditCard' );
++
++ my ($number) = @_;
++
++ $number =~ s/[\s\-]//go;
++ $number =~ s/[x\*\.\_]/x/gio;
++
++ #ref Discover IIN Bulletin Feb 2015_021715
++ return "PayPal card" if $number =~ /^6(01104|506[01]0)[\dx]{10,13}$/o;
++
++ cardtype($number);
++}
++
+ sub generate_last_digit {
+ # Allow use as a class method
+ shift if UNIVERSAL::isa( $_[0], 'Business::CreditCard' );
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..6bee7a1
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,3 @@
+ranges.patch
+receipt_cardtype.patch
+docs.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libbusiness-creditcard-perl.git
More information about the Pkg-perl-cvs-commits
mailing list