1 PACKAGE IBY_CC_VALIDATE AUTHID CURRENT_USER AS
2 /* $Header: ibyccvls.pls 120.5.12010000.4 2009/06/16 09:15:44 lyanamal ship $ */
3
4 -------------------------------------------------------------------------
5 --**Defining all DataStructures required by the APIs**--
6
7 -------------------------------------------------------------------------
8
9
10 --OUTPUT DataStructures
11 --1. Credit Card Type: identifies the type of the credit card number
12
13 SUBTYPE CCType IS NUMBER;
14
15
16 --CONSTANTS
17
18 --1. Credit Card Type Constants
19
20 c_InvalidCC CONSTANT CCType := -1; -- invalid; fits pattern but fails test
21 c_UnknownCC CONSTANT CCType := 0; -- fits no known pattern
22 c_McCC CONSTANT CCType := 1; -- Master Card
23 c_VisaCC CONSTANT CCType := 2; -- Visa
24 c_AmexCC CONSTANT CCType := 3; -- American Express
25 c_DClubCC CONSTANT CCType := 4; -- Diner's Club
26 c_DiscoverCC CONSTANT CCType := 5; -- The Discover Card
27 c_EnrouteCC CONSTANT CCType := 6; -- Enroute
28 c_JCBCC CONSTANT CCType := 7; -- JCB
29
30 G_CARD_TYPE_UNKNOWN CONSTANT VARCHAR2(30) := 'UNKNOWN';
31
32 --2. typical credit card number filler characters; i.e. characters
33 ---- interspersed in the number that are used to seperate number
34 ---- blocks for readability and can safely be ignored; each
35 ---- character in the string represents one acceptable filler character
36
37 c_FillerChars CONSTANT VARCHAR2(2) := ' -';
38
39 ---------------------------------------------------------------
40 -- API Signatures--
41 ---------------------------------------------------------------
42
43 --1. name: StripCC
44 ----
45 ---- purpose: strips the CC number of all filler characters
46 ----
47 ---- args:
48 ---- p_cc_id the credit card number, with possible filler chars
49 ---- p_fill_chars string where each character specifies a possible
50 ---- filler character; e.g. '* -' would allow hyphens,
51 ---- astericks, and spaces as filler characters
52 ----
53 ---- return:
54 ---- x_cc_id the credit card number, stripped of all filler
55 ---- chars so that it contains only digits
56
57 PROCEDURE StripCC ( p_api_version IN NUMBER,
58 p_init_msg_list IN VARCHAR2,
59 p_cc_id IN VARCHAR2,
60 p_fill_chars IN VARCHAR2,
61
62 x_return_status OUT NOCOPY VARCHAR2,
63 x_msg_count OUT NOCOPY NUMBER,
64 x_msg_data OUT NOCOPY VARCHAR2,
65 x_cc_id OUT NOCOPY VARCHAR2
66 );
67
68
69 --2. name: StripCC
70 ----
71 ---- purpose: an overloaded version of the above function
72 ---- which uses constant c_FillerChars to specify
73 ---- what filler characters are allowed
74 ----
75
76 PROCEDURE StripCC ( p_api_version IN NUMBER,
77 p_init_msg_list IN VARCHAR2,
78 p_cc_id IN VARCHAR2,
79
80 x_return_status OUT NOCOPY VARCHAR2,
81 x_msg_count OUT NOCOPY NUMBER,
82 x_msg_data OUT NOCOPY VARCHAR2,
83 x_cc_id OUT NOCOPY VARCHAR2
84 );
85
86
87 --2.1 name: StripCC
88 ----
89 ---- purpose: function version of procedure 1
90 ----
91 FUNCTION StripCC ( p_cc_id IN VARCHAR2, p_fill_chars IN VARCHAR2 )
92 RETURN VARCHAR2;
93
94
95 --3. name: GetCCType
96 ----
97 ---- purpose: returns the type of a credit card number
98 ----
99 ---- args:
100 ---- p_cc_id the credit card number, with NO!! filler chars
101 ----
102 ----
103 ---- return:
104 ---- x_cc_type the credit card type of the given credit card
105 ---- number; if the credit card type matches no
106 ---- known pattern then c_UnknownCC is returned;
107 ---- if it matches a pattern but fails some test,
108 ---- then c_InvalidCC is returned
109
110
111 PROCEDURE GetCCType ( p_api_version IN NUMBER,
112 p_init_msg_list IN VARCHAR2,
113 p_cc_id IN VARCHAR2,
114
115 x_return_status OUT NOCOPY VARCHAR2,
116 x_msg_count OUT NOCOPY NUMBER,
117 x_msg_data OUT NOCOPY VARCHAR2,
118 x_cc_type OUT NOCOPY CCType
119 );
120
121 --4. name: ValidateCC
122 ----
123 ---- purpose: indicates if a cc number, expiration date tuple
124 ---- represents a valid, non-expired credit card account
125 ----
126 ---- args:
127 ---- p_cc_id the credit card number, with NO!! filler chars
128 ---- p_expr_date the expiration date of the credit card; note
129 ---- that this date will be moved to the end of the
130 ---- month it represents for the purposes of
131 ---- determing expiration; i.e. 4/5/2000 -> 4/30/2000
132 ----
133 ----
134 ---- return:
135 ---- x_cc_valid true if and only if the credit card number is valid
136 ---- and it has not expired
137 ----
138
139
140 PROCEDURE ValidateCC (p_api_version IN NUMBER,
141 p_init_msg_list IN VARCHAR2,
142 p_cc_id IN VARCHAR2,
143 p_expr_date IN DATE,
144
145 x_return_status OUT NOCOPY VARCHAR2,
146 x_msg_count OUT NOCOPY NUMBER,
147 x_msg_data OUT NOCOPY VARCHAR2,
148 x_cc_valid OUT NOCOPY BOOLEAN
149 );
150
151
152 --5. name: ValidateCC
153 ---- Overloaded form returns a boolean,indicating whether
154 ---- the card is valid or not AND the credit card type.
155 ---- purpose: indicates if a cc number, expiration date tuple
156 ---- represents a valid, non-expired credit card account
157 ----
158 ---- args:
159 ---- p_cc_id the credit card number, with NO!! filler chars
160 ---- p_expr_date the expiration date of the credit card; note
161 ---- that this date will be moved to the end of the
162 ---- month it represents for the purposes of
163 ---- determing expiration; i.e. 4/5/2000 -> 4/30/2000
164 ----
165 ----
166 ---- return:
167 ---- x_cc_valid true if and only if the credit card number is valid
168 ---- and it has not expired
169 ----
170 ---- x_cc_type The credit card type in String.It is one from lookup types
171 ---- defined for the type 'IBY_CARD_TYPES'.
172
173
174 PROCEDURE ValidateCC (p_api_version IN NUMBER,
175 p_init_msg_list IN VARCHAR2,
176 p_cc_id IN VARCHAR2,
177 p_expr_date IN DATE,
178
179 x_return_status OUT NOCOPY VARCHAR2,
180 x_msg_count OUT NOCOPY NUMBER,
181 x_msg_data OUT NOCOPY VARCHAR2,
182 x_cc_valid OUT NOCOPY BOOLEAN,
183 x_cc_type OUT NOCOPY VARCHAR2
184 );
185
186
187
188 --
189 -- Name: Get_CC_Issuer_Range
190 -- Purpose: Finds the card issuer and range for a particular
191 -- credit card number
192 -- Args:
193 -- p_card_number => The credit card number; should already be
194 -- stripped of non-digit characters
195 -- Return:
196 -- x_card_issuer => The card issuer code; UNKNOWN if not a known
197 -- card number
198 -- x_issuer_range => Range of the card number
199 --
200 PROCEDURE Get_CC_Issuer_Range
201 (p_card_number IN iby_creditcard.ccnumber%TYPE,
202 x_card_issuer OUT NOCOPY iby_creditcard_issuers_b.card_issuer_code%TYPE,
203 x_issuer_range OUT NOCOPY iby_cc_issuer_ranges.cc_issuer_range_id%TYPE,
204 x_card_prefix OUT NOCOPY iby_cc_issuer_ranges.card_number_prefix%TYPE,
205 x_digit_check OUT NOCOPY iby_creditcard_issuers_b.digit_check_flag%TYPE
206 );
207
208 --
209 -- Inline wrapper function for the above
210 --
211 FUNCTION Get_CC_Issuer_Range
212 (p_card_number IN iby_creditcard.ccnumber%TYPE)
213 RETURN NUMBER;
214
215 FUNCTION CheckCCDigits( p_cc_id IN VARCHAR2 ) RETURN NUMBER;
216
217
218 -- FP Bug#8581161 FP:8352320
219 -- Name: Get_CC_Issuer_Range - Overloading for multiple ranges
220 -- Purpose: Finds the card issuer and range for a particular
221 -- credit card number
222 -- Args:
223 -- p_card_number => The credit card number; should already be
224 -- stripped of non-digit characters
225 -- Return:
226 -- x_card_issuer => The card issuer code; UNKNOWN if not a known
227 -- card number
228 -- x_issuer_range => Range of the card number
229 --
230 PROCEDURE Get_CC_Issuer_Range
231 (p_card_number IN iby_creditcard.ccnumber%TYPE,
232 x_card_issuer OUT NOCOPY iby_creditcard_issuers_b.card_issuer_code%TYPE,
233 x_issuer_range OUT NOCOPY iby_cc_issuer_ranges.cc_issuer_range_id%TYPE,
234 x_card_prefix OUT NOCOPY iby_cc_issuer_ranges.card_number_prefix%TYPE,
235 x_digit_check OUT NOCOPY iby_creditcard_issuers_b.digit_check_flag%TYPE,
236 p_card_type IN iby_creditcard.card_issuer_code%TYPE
237 );
238
239
240
241 END IBY_CC_VALIDATE;
242