DBA Data[Home] [Help]

PACKAGE: APPS.IBY_CC_VALIDATE

Source


1 PACKAGE IBY_CC_VALIDATE AS
2 /* $Header: ibyccvls.pls 120.5.12010000.2 2008/11/24 14:08:35 cjain 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                         p_char_allowed          IN      VARCHAR2 DEFAULT 'N'
67 			);
68 
69 
70 --2.	name:		StripCC
71 ----
72 ----	purpose:	an overloaded version of the above function
73 ----			which uses constant c_FillerChars to specify
74 ----			what filler characters are allowed
75 ----
76 
77   PROCEDURE StripCC (	p_api_version		IN	NUMBER,
78 			p_init_msg_list		IN	VARCHAR2,
79 			p_cc_id 		IN 	VARCHAR2,
80 
81 			x_return_status		OUT NOCOPY VARCHAR2,
82 			x_msg_count		OUT NOCOPY NUMBER,
83 			x_msg_data		OUT NOCOPY VARCHAR2,
84 			x_cc_id 		OUT NOCOPY VARCHAR2,
85                         p_char_allowed          IN      VARCHAR2 DEFAULT 'N'
86 			);
87 
88 
89 --3.	name:		GetCCType
90 ----
91 ----	purpose:	returns the type of a credit card number
92 ----
93 ----	args:
94 ----	 p_cc_id	the credit card number, with NO!! filler chars
95 ----
96 ----
97 ----	return:
98 ----	 x_cc_type	the credit card type of the given credit card
99 ----			number; if the credit card type matches no
100 ----			known pattern then c_UnknownCC is returned;
101 ----			if it matches a pattern but fails some test,
102 ----			then c_InvalidCC is returned
103 
104 
105   PROCEDURE GetCCType (	p_api_version		IN	NUMBER,
106 			p_init_msg_list		IN	VARCHAR2,
107 			p_cc_id 		IN 	VARCHAR2,
108 
109 			x_return_status		OUT NOCOPY VARCHAR2,
110 			x_msg_count		OUT NOCOPY NUMBER,
111 			x_msg_data		OUT NOCOPY VARCHAR2,
112 			x_cc_type 		OUT NOCOPY CCType
113 			);
114 
115 --4.	name:		ValidateCC
116 ----
117 ----	purpose:	indicates if a cc number, expiration date tuple
118 ----			represents a valid, non-expired credit card account
119 ----
120 ----	args:
121 ----	 p_cc_id	the credit card number, with NO!! filler chars
122 ----	 p_expr_date	the expiration date of the credit card; note
123 ----			that this date will be moved to the end of the
124 ----			month it represents for the purposes of
125 ----			determing expiration; i.e. 4/5/2000 -> 4/30/2000
126 ----
127 ----
128 ----	return:
129 ----	 x_cc_valid	true if and only if the credit card number is valid
130 ----			and it has not expired
131 ----
132 
133 
134   PROCEDURE ValidateCC (p_api_version		IN	NUMBER,
135 			p_init_msg_list		IN	VARCHAR2,
136 			p_cc_id 		IN 	VARCHAR2,
137 			p_expr_date		IN	DATE,
138 
139 			x_return_status		OUT NOCOPY VARCHAR2,
140 			x_msg_count		OUT NOCOPY NUMBER,
141 			x_msg_data		OUT NOCOPY VARCHAR2,
142 			x_cc_valid 		OUT NOCOPY BOOLEAN
143 			);
144 
145 
146 --5.	name:		ValidateCC
147 ----                    Overloaded form returns a boolean,indicating whether
148 ----                    the card is valid or not AND the credit card type.
149 ----	purpose:	indicates if a cc number, expiration date tuple
150 ----			represents a valid, non-expired credit card account
151 ----
152 ----	args:
153 ----	 p_cc_id	the credit card number, with NO!! filler chars
154 ----	 p_expr_date	the expiration date of the credit card; note
155 ----			that this date will be moved to the end of the
156 ----			month it represents for the purposes of
157 ----			determing expiration; i.e. 4/5/2000 -> 4/30/2000
158 ----
159 ----
160 ----	return:
161 ----	 x_cc_valid	true if and only if the credit card number is valid
162 ----			and it has not expired
163 ----
164 ----	 x_cc_type      The credit card type in String.It is one from lookup types
165 ----                    defined for the type 'IBY_CARD_TYPES'.
166 
167 
168   PROCEDURE ValidateCC (p_api_version		IN	NUMBER,
169 			p_init_msg_list		IN	VARCHAR2,
170 			p_cc_id 		IN 	VARCHAR2,
171 			p_expr_date		IN	DATE,
172 
173 			x_return_status		OUT NOCOPY VARCHAR2,
174 			x_msg_count		OUT NOCOPY NUMBER,
175 			x_msg_data		OUT NOCOPY VARCHAR2,
176 			x_cc_valid 		OUT NOCOPY BOOLEAN,
177 			x_cc_type 		OUT NOCOPY VARCHAR2
178 			);
179 
180 
181 
182   --
183   -- Name: Get_CC_Issuer_Range
184   -- Purpose: Finds the card issuer and range for a particular
185   --          credit card number
186   -- Args:
187   --       p_card_number => The credit card number; should already be
188   --                        stripped of non-digit characters
189   -- Return:
190   --       x_card_issuer => The card issuer code; UNKNOWN if not a known
191   --                        card number
192   --       x_issuer_range => Range of the card number
193   --
194   PROCEDURE Get_CC_Issuer_Range
195   (p_card_number     IN     iby_creditcard.ccnumber%TYPE,
196    x_card_issuer     OUT NOCOPY iby_creditcard_issuers_b.card_issuer_code%TYPE,
197    x_issuer_range    OUT NOCOPY iby_cc_issuer_ranges.cc_issuer_range_id%TYPE,
198    x_card_prefix     OUT NOCOPY iby_cc_issuer_ranges.card_number_prefix%TYPE,
199    x_digit_check     OUT NOCOPY iby_creditcard_issuers_b.digit_check_flag%TYPE
200   );
201 
202   --
203   -- Inline wrapper function for the above
204   --
205   FUNCTION Get_CC_Issuer_Range
206   (p_card_number     IN     iby_creditcard.ccnumber%TYPE)
207   RETURN NUMBER;
208 
209   FUNCTION CheckCCDigits( p_cc_id  IN VARCHAR2 ) RETURN NUMBER;
210 
211 END IBY_CC_VALIDATE;
212