[Home] [Help]
PACKAGE BODY: APPS.ASO_PAYMENT_INT
Source
1 PACKAGE BODY ASO_PAYMENT_INT as
2 /* $Header: asoipayb.pls 120.25 2006/04/19 11:27:39 skulkarn ship $ */
3 -- Start of Comments
4 -- Package name : ASO_PAYMENT_INT
5 -- Purpose :
6 -- History :
7 -- NOTE :
8 -- End of Comments
9
10
11 G_APP_ID CONSTANT NUMBER := 697;
12 G_AUTH_ERROR CONSTANT NUMBER := 3;
13 G_PKG_NAME CONSTANT VARCHAR2(30) := 'ASO_PAYMENT_INT';
14 G_FILE_NAME CONSTANT VARCHAR2(12) := 'asoipayb.pls';
15
16
17
18 FUNCTION Get_payment_term_id ( p_qte_header_id NUMBER,
19 p_qte_line_id NUMBER
20 ) RETURN NUMBER
21 IS
22
23 cursor c_pay_term1 is
24 select payment_term_id from aso_payments
25 where quote_line_id = p_qte_line_id
26 and quote_header_id = p_qte_header_id;
27
28 cursor c_pay_term2 is
29 select payment_term_id from aso_payments
30 where quote_header_id = p_qte_header_id;
31
32 l_payment_term_id NUMBER;
33
34 BEGIN
35
36 OPEN c_pay_term1;
37 FETCH c_pay_term1 INTO l_payment_term_id;
38
39 IF c_pay_term1%FOUND and l_payment_term_id IS NOT NULL and l_payment_term_id <> FND_API.G_MISS_NUM THEN
40
41 CLOSE c_pay_term1;
42 return l_payment_term_id;
43
44 END IF;
45 CLOSE c_pay_term1;
46
47 OPEN c_pay_term2;
48 FETCH c_pay_term2 INTO l_payment_term_id;
49
50 IF c_pay_term2%FOUND and l_payment_term_id IS NOT NULL and l_payment_term_id <> FND_API.G_MISS_NUM THEN
51
52 CLOSE c_pay_term2;
53 return l_payment_term_id;
54
55 END IF;
56 CLOSE c_pay_term2;
57
58 return l_payment_term_id;
59
60 END Get_payment_term_id;
61
62
63 PROCEDURE create_iby_payment(p_payment_rec IN aso_quote_pub.payment_rec_type,
64 db_payment_rec IN aso_quote_pub.payment_rec_type := aso_quote_pub.G_MISS_PAYMENT_REC,
65 p_payer IN IBY_FNDCPT_COMMON_PUB.PayerContext_rec_type,
66 x_payment_rec OUT NOCOPY aso_quote_pub.payment_rec_type,
67 x_return_status OUT NOCOPY varchar2,
68 x_msg_count OUT NOCOPY number,
69 x_msg_data OUT NOCOPY varchar2)
70 IS
71 l_payer IBY_FNDCPT_COMMON_PUB.PayerContext_rec_type;
72 l_credit_card IBY_FNDCPT_SETUP_PUB.CreditCard_rec_type;
73 l_assignment_attribs IBY_FNDCPT_SETUP_PUB.PmtInstrAssignment_rec_type;
74 lx_response IBY_FNDCPT_COMMON_PUB.Result_rec_type;
75 lx_assign_id number;
76 lx_entity_id number;
77 l_trxn_attribs IBY_FNDCPT_TRXN_PUB.TrxnExtension_rec_type;
78 l_payment_rec aso_quote_pub.payment_rec_type := p_payment_rec;
79 l_api_name varchar2(1000) := 'create_iby_payment';
80 l_qte_header_rec ASO_QUOTE_PUB.Qte_Header_Rec_Type;
81 l_qte_line_rec ASO_QUOTE_PUB.Qte_Line_Rec_Type;
82
83 Begin
84
85 SAVEPOINT CREATE_IBY_PAYMENT_INT;
86
87 aso_debug_pub.g_debug_flag := nvl(fnd_profile.value('ASO_ENABLE_DEBUG'),'N');
88
89 IF aso_debug_pub.g_debug_flag = 'Y' THEN
90 aso_debug_pub.add('Begin create_iby_payment ', 1, 'Y');
91 END IF;
92
93 x_return_status := FND_API.G_RET_STS_SUCCESS;
94
95 x_payment_rec := l_payment_rec;
96
97 l_qte_header_rec := ASO_UTILITY_PVT.Query_Header_Row (l_payment_rec.Quote_Header_Id );
98
99 IF ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
100 l_qte_line_rec := ASO_UTILITY_PVT.Query_Qte_Line_Row ( l_payment_rec.Quote_Line_Id );
101 END IF;
102
103
104
105 if (l_payment_rec.payment_type_code = 'CREDIT_CARD'
106 or ( l_payment_rec.payment_type_code = fnd_api.g_miss_char and db_payment_rec.payment_type_code = 'CREDIT_CARD'))
107 and
108 l_payment_rec.payment_ref_number is not null and
109 l_payment_rec.payment_ref_number <> fnd_api.g_miss_char then
110
111 IF aso_debug_pub.g_debug_flag = 'Y' THEN
112 aso_debug_pub.add('Inside if for payment type credit card', 1, 'Y');
113 END IF;
114
115 If (l_payment_rec.instr_assignment_id is null or l_payment_rec.instr_assignment_id = fnd_api.g_miss_num ) then
116
117 l_credit_card.card_id := null;
118
119 If ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
120 l_credit_card.owner_id := l_qte_line_rec.invoice_to_cust_party_id;
121 l_credit_card.billing_address_id := l_qte_line_rec.invoice_to_party_site_id;
122 Else
123 l_credit_card.owner_id := l_qte_header_rec.invoice_to_cust_party_id;
124 l_credit_card.billing_address_id := l_qte_header_rec.invoice_to_party_site_id;
125 End If;
126
127 l_credit_card.card_number := l_payment_rec.payment_ref_number;
128 l_credit_card.expiration_date := last_day(l_payment_rec.credit_card_expiration_date);
129 l_credit_card.instrument_type := 'CREDITCARD';
130 l_credit_card.purchasecard_subtype := null;
131 l_credit_card.PurchaseCard_Flag := 'N';
132 l_credit_card.card_issuer := l_payment_rec.credit_card_code;
133 l_credit_card.card_holder_name := l_payment_rec.credit_card_holder_name;
134 l_credit_card.fi_name := null;
135 l_credit_card.single_use_flag := 'N';
136 l_credit_card.info_only_flag := 'N';
137 l_credit_card.card_purpose := null;
138 l_credit_card.card_description := null;
139 l_credit_card.inactive_date := null;
140
141 l_assignment_attribs.assignment_id := null;
142 l_assignment_attribs.instrument.instrument_type := 'CREDITCARD';
143 l_assignment_attribs.instrument.instrument_id := null;
144 l_assignment_attribs.priority := null;
145 l_assignment_attribs.start_date := sysdate;
146 l_assignment_attribs.end_date := null;
147
148 IF aso_debug_pub.g_debug_flag = 'Y' THEN
149 aso_debug_pub.add('Before calling IBY_FNDCPT_SETUP_PUB.Process_Credit_Card ', 1, 'Y');
150 aso_debug_pub.add('l_credit_card.card_number: '|| l_credit_card.card_number, 1, 'Y');
151 aso_debug_pub.add('l_credit_card.expiration_date: '|| l_credit_card.expiration_date, 1, 'Y');
152 aso_debug_pub.add('l_credit_card.card_issuer: '|| l_credit_card.card_issuer, 1, 'Y');
153 aso_debug_pub.add('l_credit_card.card_holder_name:'|| l_credit_card.card_holder_name, 1, 'Y');
154 aso_debug_pub.add('l_credit_card.owner_id: '|| l_credit_card.owner_id, 1, 'Y');
155 aso_debug_pub.add('p_payer.party_id: '|| p_payer.party_id, 1, 'Y');
156 END IF;
157
158 IBY_FNDCPT_SETUP_PUB.Process_Credit_Card
159 (
160 p_api_version => 1.0,
161 p_init_msg_list => FND_API.G_FALSE,
162 p_commit => FND_API.G_FALSE,
163 x_return_status => x_return_status,
164 x_msg_count => x_msg_count,
165 x_msg_data => x_msg_data,
166 p_payer => p_payer,
167 p_credit_card => l_credit_card,
168 p_assignment_attribs => l_assignment_attribs,
169 x_assign_id => lx_assign_id,
170 x_response => lx_response);
171
172 IF aso_debug_pub.g_debug_flag = 'Y' THEN
173 aso_debug_pub.add('after calling IBY_FNDCPT_SETUP_PUB.Process_Credit_Card ', 1, 'Y');
174 aso_debug_pub.add('IBY Process_Credit_Card Return Status: '||x_return_status, 1, 'Y');
175 aso_debug_pub.add('IBY Process_Credit_Card x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
176 aso_debug_pub.add('IBY Process_Credit_Card x_response.result_category: '|| to_char(lx_response.result_category), 1, 'Y');
177 aso_debug_pub.add('IBY Process_Credit_Card x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
178 aso_debug_pub.add('IBY Process_Credit_Card x_assign_id: '|| to_char(lx_assign_id), 1, 'Y');
179 END IF;
180
181 if x_return_status <> fnd_api.g_ret_sts_success then
182 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
183 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
184 FND_MESSAGE.Set_Token('API', 'IBY_FNDCPT_SETUP_PUB.Process_Credit_Card ', FALSE);
185 FND_MSG_PUB.ADD;
186 END IF;
187 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
188 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
189 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
190 RAISE FND_API.G_EXC_ERROR;
191 END IF;
192 end if;
193
194 x_payment_rec.instr_assignment_id := lx_assign_id;
195
196 end if;-- for instrument id check
197 end if; -- for payment type check
198
199 IF ASO_DEBUG_PUB.G_Debug_Flag = 'Y' THEN
200 aso_debug_pub.ADD ('END create_iby_payment',1,'N');
201 END IF;
202
203 EXCEPTION
204 WHEN FND_API.G_EXC_ERROR THEN
205 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
206 P_API_NAME => L_API_NAME
207 ,P_PKG_NAME => G_PKG_NAME
208 ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_ERROR
209 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
210 ,X_MSG_COUNT => X_MSG_COUNT
211 ,X_MSG_DATA => X_MSG_DATA
212 ,X_RETURN_STATUS => X_RETURN_STATUS);
213
214 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
215 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
216 P_API_NAME => L_API_NAME
217 ,P_PKG_NAME => G_PKG_NAME
218 ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR
219 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
220 ,X_MSG_COUNT => X_MSG_COUNT
221 ,X_MSG_DATA => X_MSG_DATA
222 ,X_RETURN_STATUS => X_RETURN_STATUS);
223
224 WHEN OTHERS THEN
225 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
226 P_API_NAME => L_API_NAME
227 ,P_PKG_NAME => G_PKG_NAME
228 ,P_EXCEPTION_LEVEL => ASO_UTILITY_PVT.G_EXC_OTHERS
229 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
230 ,X_MSG_COUNT => X_MSG_COUNT
231 ,X_MSG_DATA => X_MSG_DATA
232 ,X_RETURN_STATUS => X_RETURN_STATUS);
233 End create_iby_payment;
234
235
236
237 PROCEDURE create_payment_row(p_payment_rec IN aso_quote_pub.payment_rec_type,
238 x_payment_rec OUT NOCOPY aso_quote_pub.payment_rec_type,
239 x_return_status OUT NOCOPY varchar2,
240 x_msg_count OUT NOCOPY number,
241 x_msg_data OUT NOCOPY varchar2)
242 IS
243 l_payer IBY_FNDCPT_COMMON_PUB.PayerContext_rec_type;
244 l_credit_card IBY_FNDCPT_SETUP_PUB.CreditCard_rec_type;
245 l_assignment_attribs IBY_FNDCPT_SETUP_PUB.PmtInstrAssignment_rec_type;
246 lx_response IBY_FNDCPT_COMMON_PUB.Result_rec_type;
247 lx_assign_id number;
248 lx_entity_id number;
249 l_trxn_attribs IBY_FNDCPT_TRXN_PUB.TrxnExtension_rec_type;
250 l_payment_rec aso_quote_pub.payment_rec_type := p_payment_rec;
251 l_api_name varchar2(1000) := 'create_payment_row';
252 l_qte_header_rec ASO_QUOTE_PUB.Qte_Header_Rec_Type;
253 l_qte_line_rec ASO_QUOTE_PUB.Qte_Line_Rec_Type;
254 lx_channel_attrib_uses IBY_FNDCPT_SETUP_PUB.PmtChannel_AttribUses_rec_type;
255 l_payment_ref_number varchar2(240);
256
257 Cursor c_get_payer_id ( p_assignment_id NUMBER) is
258 select party_id
259 from iby_fndcpt_payer_assgn_instr_v
260 where instr_assignment_id = p_assignment_id;
261
262 Cursor c_get_payment_id is
263 SELECT ASO_PAYMENTS_S.nextval FROM sys.dual;
264
265 Cursor c_get_db_hdr_payment (p_qte_hdr_id NUMBER) is
266 select payment_id
267 from aso_payments
268 where quote_header_id = p_qte_hdr_id
269 and quote_line_id is null;
270
271 Cursor c_get_db_line_payment (p_qte_hdr_id NUMBER, p_qte_line_id NUMBER) is
272 select payment_id
273 from aso_payments
274 where quote_header_id = p_qte_hdr_id
275 and quote_line_id = p_qte_line_id;
276
277 l_existing_payment_id number;
278
279 Begin
280
281 SAVEPOINT CREATE_PAYMENT_ROW_INT;
282
283 aso_debug_pub.g_debug_flag := nvl(fnd_profile.value('ASO_ENABLE_DEBUG'),'N');
284
285 IF aso_debug_pub.g_debug_flag = 'Y' THEN
286 aso_debug_pub.add('Begin create_payment_row ', 1, 'Y');
287 END IF;
288
289 x_return_status := FND_API.G_RET_STS_SUCCESS;
290
291 IF aso_debug_pub.g_debug_flag = 'Y' THEN
292 aso_debug_pub.add('l_payment_rec.Quote_Header_Id: '||l_payment_rec.Quote_Header_Id, 1, 'Y');
293 aso_debug_pub.add('l_payment_rec.Quote_Line_Id: '||l_payment_rec.Quote_Line_Id, 1, 'Y');
294 aso_debug_pub.add('l_payment_rec.payment_type_code: '||l_payment_rec.payment_type_code, 1, 'Y');
295 aso_debug_pub.add('l_payment_rec.instr_assignment_id: '||l_payment_rec.instr_assignment_id, 1, 'Y');
296 END IF;
297
298 -- Check for duplicate payments see bug 5118000
299 IF ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
300 IF aso_debug_pub.g_debug_flag = 'Y' THEN
301 aso_debug_pub.add('Checking for duplicate payment records at line level', 1, 'Y');
302 END IF;
303 open c_get_db_line_payment(l_payment_rec.Quote_Header_Id,l_payment_rec.Quote_Line_Id);
304 fetch c_get_db_line_payment into l_existing_payment_id;
305 if c_get_db_line_payment%FOUND THEN
306 x_return_status := FND_API.G_RET_STS_ERROR;
307 close c_get_db_line_payment;
308 FND_MESSAGE.Set_Name('ASO', 'ASO_API_MULTIPLE_PAYMENTS');
309 FND_MSG_PUB.ADD;
310 RAISE FND_API.G_EXC_ERROR;
311 end if;
312 close c_get_db_line_payment;
313 ELSE
314 IF aso_debug_pub.g_debug_flag = 'Y' THEN
318 fetch c_get_db_hdr_payment into l_existing_payment_id;
315 aso_debug_pub.add('Checking for duplicate payment records at Header level', 1, 'Y');
316 END IF;
317 open c_get_db_hdr_payment(l_payment_rec.Quote_Header_Id);
319 if c_get_db_hdr_payment%FOUND THEN
320 x_return_status := FND_API.G_RET_STS_ERROR;
321 close c_get_db_hdr_payment;
322 FND_MESSAGE.Set_Name('ASO', 'ASO_API_MULTIPLE_PAYMENTS');
323 FND_MSG_PUB.ADD;
324 RAISE FND_API.G_EXC_ERROR;
325 end if;
326 close c_get_db_hdr_payment;
327 END IF;
328
329
330 l_qte_header_rec := ASO_UTILITY_PVT.Query_Header_Row (l_payment_rec.Quote_Header_Id );
331
332 IF aso_debug_pub.g_debug_flag = 'Y' THEN
333 aso_debug_pub.add('After querying the header row', 1, 'Y');
334 aso_debug_pub.add('l_qte_header_rec.quote_header_id: ' || l_qte_header_rec.quote_header_id, 1, 'Y');
335 END IF;
336
337 IF ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
338 l_qte_line_rec := ASO_UTILITY_PVT.Query_Qte_Line_Row ( l_payment_rec.Quote_Line_Id );
339 END IF;
340
341 IF aso_debug_pub.g_debug_flag = 'Y' THEN
342 aso_debug_pub.add('After querying the line row', 1, 'Y');
343 END IF;
344
345 if ( l_payment_rec.payment_type_code = 'CREDIT_CARD' and
346 ((l_payment_rec.payment_ref_number is not null and l_payment_rec.payment_ref_number <> fnd_api.g_miss_char) or
347 (l_payment_rec.instr_assignment_id is not null and l_payment_rec.instr_assignment_id <> fnd_api.g_miss_num)) ) then
348
349 IF aso_debug_pub.g_debug_flag = 'Y' THEN
350 aso_debug_pub.add('Inside if for payment type credit card', 1, 'Y');
351 END IF;
352
353 -- do the validation for the payment record
354 IF aso_debug_pub.g_debug_flag = 'Y' THEN
355 aso_debug_pub.add('Before calling Validate_cc_info ', 1, 'Y');
356 END IF;
357 aso_validate_pvt.Validate_cc_info
358 (
359 p_init_msg_list => fnd_api.g_false,
360 p_payment_rec => l_payment_rec,
361 p_qte_header_rec => l_qte_header_rec,
362 P_Qte_Line_rec => l_qte_line_rec,
363 x_return_status => x_return_status,
364 x_msg_count => x_msg_count,
365 x_msg_data => x_msg_data);
366
367 IF aso_debug_pub.g_debug_flag = 'Y' THEN
368 aso_debug_pub.add('after calling Validate_cc_info ', 1, 'Y');
369 aso_debug_pub.add('Validate_cc_info Return Status: '||x_return_status, 1, 'Y');
370 END IF;
371
372 if x_return_status <> fnd_api.g_ret_sts_success then
373 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
374 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
375 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
376 RAISE FND_API.G_EXC_ERROR;
377 ELSE
378 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
379 END IF;
380 end if;
381
382 l_payer.cust_account_id := null;
383 l_payer.account_site_id := null;
384 l_payer.payment_function := 'CUSTOMER_PAYMENT';
385
386 if (p_payment_rec.instr_assignment_id is null or p_payment_rec.instr_assignment_id = fnd_api.g_miss_num) then
387 -- this is the Quoting flow
388
389 If ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
390 l_payer.party_id := l_qte_line_rec.invoice_to_cust_party_id;
391 Else
392 l_payer.party_id := l_qte_header_rec.invoice_to_cust_party_id;
393 End If;
394
395 -- call api to create credit card and assigment , if needed
396 IF aso_debug_pub.g_debug_flag = 'Y' THEN
397 aso_debug_pub.add('Before calling create_iby_payment' , 1, 'Y');
398 END IF;
399
400 aso_payment_int.create_iby_payment(p_payment_rec => p_payment_rec,
401 p_payer => l_payer,
402 x_payment_rec => l_payment_rec,
403 x_return_status => x_return_status ,
404 x_msg_count => x_msg_count,
405 x_msg_data => x_msg_data);
406
407 IF aso_debug_pub.g_debug_flag = 'Y' THEN
408 aso_debug_pub.add('after calling create_iby_payment ', 1, 'Y');
409 aso_debug_pub.add('create_iby_payment Return Status: '||x_return_status, 1, 'Y');
410 END IF;
411
412 if x_return_status <> fnd_api.g_ret_sts_success then
413 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
414 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
415 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
416 RAISE FND_API.G_EXC_ERROR;
417 ELSE
418 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
419 END IF;
420 end if;
421 else
422 -- this is the iStore Flow
423 open c_get_payer_id(p_payment_rec.instr_assignment_id);
424 fetch c_get_payer_id into l_payer.party_id;
428 aso_debug_pub.add('l_payer.party_id: '|| l_payer.party_id, 1, 'Y');
425 close c_get_payer_id;
426
427 IF aso_debug_pub.g_debug_flag = 'Y' THEN
429 END IF;
430
431 end if;
432
433 -- generate the payment id if it is not passed, this is possible
434 -- when quote is being created first time and payment rec is created at same time
435 if (l_payment_rec.payment_id is null or l_payment_rec.payment_id = fnd_api.g_miss_num) then
436 open c_get_payment_id;
437 fetch c_get_payment_id into l_payment_rec.payment_id;
438 close c_get_payment_id;
439 end if;
440
441 l_trxn_attribs.Originating_Application_Id := 697;
442 l_trxn_attribs.Order_Id := to_char(l_payment_rec.payment_id)||'-'||l_qte_header_rec.quote_number;
443 l_trxn_attribs.PO_Number := null;
444 l_trxn_attribs.PO_Line_Number := null;
445 l_trxn_attribs.Trxn_Ref_Number1 := l_payment_rec.quote_header_id;
446 IF l_payment_rec.quote_line_id = fnd_api.g_miss_num then
447 l_trxn_attribs.Trxn_Ref_Number2 := null;
448 Else
449 l_trxn_attribs.Trxn_Ref_Number2 := l_payment_rec.quote_line_id;
450 End if;
451
452 -- Check to see if cvv2 is mandatory or not
453 IF aso_debug_pub.g_debug_flag = 'Y' THEN
454 aso_debug_pub.add('Before calling IBY_FNDCPT_TRXN_PUB.Get_Payment_Channel_Attribs ', 1, 'Y');
455 END IF;
456
457 IBY_FNDCPT_SETUP_PUB.Get_Payment_Channel_Attribs
458 (
459 p_api_version => 1.0,
460 p_init_msg_list => FND_API.G_FALSE,
461 x_return_status => x_return_status,
462 x_msg_count => x_msg_count,
463 x_msg_data => x_msg_data,
464 p_channel_code => 'CREDIT_CARD',
465 x_channel_attrib_uses => lx_channel_attrib_uses,
466 x_response => lx_response);
467
468 IF aso_debug_pub.g_debug_flag = 'Y' THEN
469 aso_debug_pub.add('after calling IBY_FNDCPT_TRXN_PUB.Get_Payment_Channel_Attribs ', 1, 'Y');
470 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
471 aso_debug_pub.add('cvv2 use: '||lx_channel_attrib_uses.Instr_SecCode_Use, 1, 'Y');
472 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
473 aso_debug_pub.add('x_response.result_category:'|| to_char(lx_response.result_category), 1, 'Y');
474 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
475 END IF;
476
477 IF (nvl(lx_channel_attrib_uses.Instr_SecCode_Use,'null') = 'REQUIRED' and
478 (l_payment_rec.cvv2 is null or l_payment_rec.cvv2 = fnd_api.g_miss_char)) then
479
480 x_return_status := FND_API.G_RET_STS_ERROR;
481 FND_MESSAGE.Set_Name('ASO', 'ASO_CC_INVALID');
482 FND_MSG_PUB.ADD;
483 RAISE FND_API.G_EXC_ERROR;
484 END IF;
485
486
487 if l_payment_rec.cvv2 = fnd_api.g_miss_char then
488 l_trxn_attribs.Instrument_Security_Code := null;
489 else
490 l_trxn_attribs.Instrument_Security_Code := l_payment_rec.cvv2;
491 end if;
492
493 l_trxn_attribs.VoiceAuth_Flag := null;
494 l_trxn_attribs.VoiceAuth_Date := null;
495 l_trxn_attribs.VoiceAuth_Code := null;
496 l_trxn_attribs.Additional_Info := null;
497
498
499 IF aso_debug_pub.g_debug_flag = 'Y' THEN
500 aso_debug_pub.add('Before calling IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', 1, 'Y');
501 aso_debug_pub.add('Instrument Assignment id: '|| l_payment_rec.instr_assignment_id, 1, 'Y');
502 END IF;
503
504 IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension
505 (
506 p_api_version => 1.0,
507 p_init_msg_list => FND_API.G_FALSE,
508 p_commit => FND_API.G_FALSE,
509 x_return_status => x_return_status,
510 x_msg_count => x_msg_count,
511 x_msg_data => x_msg_data,
512 p_payer => l_payer,
513 p_payer_equivalency => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
514 p_pmt_channel => l_payment_rec.payment_type_code,
515 p_instr_assignment => l_payment_rec.instr_assignment_id,
516 p_trxn_attribs => l_trxn_attribs,
517 x_entity_id => lx_entity_id,
518 x_response => lx_response);
519
520 IF aso_debug_pub.g_debug_flag = 'Y' THEN
521 aso_debug_pub.add('after calling IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', 1, 'Y');
522 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
523 aso_debug_pub.add('lx_entity_id: '||lx_entity_id, 1, 'Y');
524 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
525 aso_debug_pub.add('x_response.result_category:'|| to_char(lx_response.result_category), 1, 'Y');
526 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
527 END IF;
528
532 FND_MESSAGE.Set_Token('API', 'IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', FALSE);
529 if x_return_status <> fnd_api.g_ret_sts_success then
530 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
531 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
533 FND_MSG_PUB.ADD;
534 END IF;
535 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
536 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
537 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
538 RAISE FND_API.G_EXC_ERROR;
539 END IF;
540 end if;
541
542 end if;
543
544
545
546 IF l_payment_rec.PAYMENT_TYPE_CODE = 'CREDIT_CARD' then
547 l_payment_ref_number := null;
548 else
549 l_payment_ref_number := l_payment_rec.PAYMENT_REF_NUMBER;
550 END IF;
551
552
553 IF aso_debug_pub.g_debug_flag = 'Y' THEN
554 aso_debug_pub.add('Before calling the table handler to insert the data ', 1, 'Y');
555 END IF;
556
557
558 ASO_PAYMENTS_PKG.Insert_Row(
559 px_PAYMENT_ID => l_payment_rec.PAYMENT_ID,
560 p_CREATION_DATE => SYSDATE,
561 p_CREATED_BY => fnd_global.USER_ID,
562 p_LAST_UPDATE_DATE => SYSDATE,
563 p_LAST_UPDATED_BY => fnd_global.USER_ID,
564 p_LAST_UPDATE_LOGIN => FND_GLOBAL.CONC_LOGIN_ID,
565 p_REQUEST_ID => l_payment_rec.REQUEST_ID,
566 p_PROGRAM_APPLICATION_ID => l_payment_rec.PROGRAM_APPLICATION_ID,
567 p_PROGRAM_ID => l_payment_rec.PROGRAM_ID,
568 p_PROGRAM_UPDATE_DATE => l_payment_rec.PROGRAM_UPDATE_DATE,
569 p_QUOTE_HEADER_ID => l_payment_rec.QUOTE_HEADER_ID,
570 p_QUOTE_LINE_ID => l_payment_rec.QUOTE_LINE_ID,
571 p_QUOTE_SHIPMENT_ID => l_payment_rec.QUOTE_SHIPMENT_ID ,
572 p_PAYMENT_TYPE_CODE => l_payment_rec.PAYMENT_TYPE_CODE,
573 p_PAYMENT_REF_NUMBER => l_payment_ref_number,
574 p_PAYMENT_OPTION => l_payment_rec.PAYMENT_OPTION,
575 p_PAYMENT_TERM_ID => l_payment_rec.PAYMENT_TERM_ID,
576 p_CREDIT_CARD_CODE => null,
577 p_CREDIT_CARD_HOLDER_NAME => null,
578 p_CREDIT_CARD_EXPIRATION_DATE => null,
579 p_CREDIT_CARD_APPROVAL_CODE => null,
580 p_CREDIT_CARD_APPROVAL_DATE => null,
581 p_PAYMENT_AMOUNT => l_payment_rec.PAYMENT_AMOUNT,
582 p_ATTRIBUTE_CATEGORY => l_payment_rec.ATTRIBUTE_CATEGORY,
583 p_ATTRIBUTE1 => l_payment_rec.ATTRIBUTE1,
584 p_ATTRIBUTE2 => l_payment_rec.ATTRIBUTE2,
585 p_ATTRIBUTE3 => l_payment_rec.ATTRIBUTE3,
586 p_ATTRIBUTE4 => l_payment_rec.ATTRIBUTE4,
587 p_ATTRIBUTE5 => l_payment_rec.ATTRIBUTE5,
588 p_ATTRIBUTE6 => l_payment_rec.ATTRIBUTE6,
589 p_ATTRIBUTE7 => l_payment_rec.ATTRIBUTE7,
590 p_ATTRIBUTE8 => l_payment_rec.ATTRIBUTE8,
591 p_ATTRIBUTE9 => l_payment_rec.ATTRIBUTE9,
592 p_ATTRIBUTE10 => l_payment_rec.ATTRIBUTE10,
593 p_ATTRIBUTE11 => l_payment_rec.ATTRIBUTE11,
594 p_ATTRIBUTE12 => l_payment_rec.ATTRIBUTE12,
595 p_ATTRIBUTE13 => l_payment_rec.ATTRIBUTE13,
596 p_ATTRIBUTE14 => l_payment_rec.ATTRIBUTE14,
597 p_ATTRIBUTE15 => l_payment_rec.ATTRIBUTE15,
598 p_ATTRIBUTE16 => l_payment_rec.ATTRIBUTE16,
599 p_ATTRIBUTE17 => l_payment_rec.ATTRIBUTE17,
600 p_ATTRIBUTE18 => l_payment_rec.ATTRIBUTE18,
601 p_ATTRIBUTE19 => l_payment_rec.ATTRIBUTE19,
602 p_ATTRIBUTE20 => l_payment_rec.ATTRIBUTE20,
603 p_CUST_PO_NUMBER => l_payment_rec.CUST_PO_NUMBER,
604 p_PAYMENT_TERM_ID_FROM => l_payment_rec.PAYMENT_TERM_ID_FROM,
605 p_OBJECT_VERSION_NUMBER => l_payment_rec.OBJECT_VERSION_NUMBER,
606 p_CUST_PO_LINE_NUMBER => l_payment_rec.CUST_PO_LINE_NUMBER,
607 p_trxn_extension_id => lx_entity_id
608 );
609
610 x_payment_rec := l_payment_rec;
611
612
613 -- Standard call to get message count and if count is 1, get message info.
614 FND_MSG_PUB.Count_And_Get
615 ( p_count => x_msg_count,
616 p_data => x_msg_data
617 );
618
619 IF ASO_DEBUG_PUB.G_Debug_Flag = 'Y' THEN
620 aso_debug_pub.ADD ('END create_payment_row',1,'N');
621 END IF;
622
623 EXCEPTION
624 WHEN FND_API.G_EXC_ERROR THEN
625 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
626 P_API_NAME => L_API_NAME
627 ,P_PKG_NAME => G_PKG_NAME
628 ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_ERROR
629 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
630 ,X_MSG_COUNT => X_MSG_COUNT
631 ,X_MSG_DATA => X_MSG_DATA
635 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
632 ,X_RETURN_STATUS => X_RETURN_STATUS);
633
634 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
636 P_API_NAME => L_API_NAME
637 ,P_PKG_NAME => G_PKG_NAME
638 ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR
639 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
640 ,X_MSG_COUNT => X_MSG_COUNT
641 ,X_MSG_DATA => X_MSG_DATA
642 ,X_RETURN_STATUS => X_RETURN_STATUS);
643
644 WHEN OTHERS THEN
645 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
646 P_API_NAME => L_API_NAME
647 ,P_PKG_NAME => G_PKG_NAME
648 ,P_EXCEPTION_LEVEL => ASO_UTILITY_PVT.G_EXC_OTHERS
649 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
650 ,X_MSG_COUNT => X_MSG_COUNT
651 ,X_MSG_DATA => X_MSG_DATA
652 ,X_RETURN_STATUS => X_RETURN_STATUS);
653 End create_payment_row;
654
655
656
657 PROCEDURE update_payment_row(p_payment_rec IN aso_quote_pub.payment_rec_type,
658 x_payment_rec OUT NOCOPY aso_quote_pub.payment_rec_type,
659 x_return_status OUT NOCOPY varchar2,
660 x_msg_count OUT NOCOPY number,
661 x_msg_data OUT NOCOPY varchar2) is
662
663 l_api_name varchar2(1000) := 'update_payment_row';
664 l_payer IBY_FNDCPT_COMMON_PUB.PayerContext_rec_type;
665 l_credit_card IBY_FNDCPT_SETUP_PUB.CreditCard_rec_type;
666 l_assignment_attribs IBY_FNDCPT_SETUP_PUB.PmtInstrAssignment_rec_type;
667 lx_response IBY_FNDCPT_COMMON_PUB.Result_rec_type;
668 lx_assign_id number;
669 lx_entity_id number;
670 l_trxn_attribs IBY_FNDCPT_TRXN_PUB.TrxnExtension_rec_type;
671 l_payment_rec aso_quote_pub.payment_rec_type := p_payment_rec;
672 l_db_payment_rec aso_quote_pub.payment_rec_type;
673 l_payment_tbl ASO_QUOTE_PUB.Payment_Tbl_Type;
674 l_qte_header_rec ASO_QUOTE_PUB.Qte_Header_Rec_Type;
675 l_qte_line_rec ASO_QUOTE_PUB.Qte_Line_Rec_Type;
676 l_card_instrument IBY_FNDCPT_SETUP_PUB.CreditCard_rec_type;
677 lx_channel_attrib_uses IBY_FNDCPT_SETUP_PUB.PmtChannel_AttribUses_rec_type;
678 l_payment_ref_number varchar2(240);
679 l_shared_cart_scenario varchar2(1) := 'N';
680 l_orig_party_id number;
681
682
683 Cursor c_get_payer_id ( p_assignment_id NUMBER) is
684 select party_id
685 from iby_fndcpt_payer_assgn_instr_v
686 where instr_assignment_id = p_assignment_id;
687
688 Cursor c_get_payer_from_trxn(p_trxn_extension_id number) is
689 select a.party_id
690 from iby_fndcpt_payer_assgn_instr_v a, IBY_TRXN_EXTENSIONS_V b
694 Begin
691 where a.instr_assignment_id = b.instr_assignment_id
692 and b.trxn_extension_id = p_trxn_extension_id;
693
695
696 SAVEPOINT UPDATE_PAYMENT_ROW_INT;
697
698 aso_debug_pub.g_debug_flag := nvl(fnd_profile.value('ASO_ENABLE_DEBUG'),'N');
699
700 IF aso_debug_pub.g_debug_flag = 'Y' THEN
701 aso_debug_pub.add('Begin update_payment_row ', 1, 'Y');
702 END IF;
703
704 x_return_status := FND_API.G_RET_STS_SUCCESS;
705
706
707
708 -- Start API Body
709 l_qte_header_rec := ASO_UTILITY_PVT.Query_Header_Row (l_payment_rec.Quote_Header_Id );
710
711 IF ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
712 l_qte_line_rec := ASO_UTILITY_PVT.Query_Qte_Line_Row ( l_payment_rec.Quote_Line_Id );
713 END IF;
714
715 --Get the databse payment record and assign it to l_db_payment_rec
716 IF ( l_payment_rec.Quote_Line_Id = fnd_api.g_miss_num) then
717 l_payment_rec.quote_line_id := null;
718 END IF;
719 l_payment_tbl := aso_utility_pvt.Query_Payment_Rows(l_payment_rec.quote_header_id,l_payment_rec.quote_line_id);
720 l_db_payment_rec := l_payment_tbl(1);
721
722
723 IF aso_debug_pub.g_debug_flag = 'Y' THEN
724 aso_debug_pub.add('Database payment_type_code is : '||l_db_payment_rec.payment_type_code, 1, 'Y');
725 aso_debug_pub.add('Database trxn_extension_id is : '||l_db_payment_rec.trxn_extension_id, 1, 'Y');
726 aso_debug_pub.add('Input payment_type_code is : '|| l_payment_rec.payment_type_code, 1, 'Y');
727 aso_debug_pub.add('Input instr_assignment_id is : '|| l_payment_rec.instr_assignment_id, 1, 'Y');
728 aso_debug_pub.add('Input payment_ref_number is : '|| l_payment_rec.payment_ref_number, 1, 'Y');
729 aso_debug_pub.add('Input trxn_extension_id is : '|| l_payment_rec.trxn_extension_id, 1, 'Y');
730 aso_debug_pub.add('Input instrument_id is : '|| l_payment_rec.instrument_id, 1, 'Y');
731 aso_debug_pub.add('Input cvv2 is : '|| l_payment_rec.cvv2, 1, 'Y');
732 END IF;
733
734
735 -- do the validation for the payment record
736 IF l_payment_rec.payment_type_code = 'CREDIT_CARD' THEN
737 IF aso_debug_pub.g_debug_flag = 'Y' THEN
738 aso_debug_pub.add('Before calling Validate_cc_info ', 1, 'Y');
739 END IF;
740 aso_validate_pvt.Validate_cc_info
741 (
742 p_init_msg_list => fnd_api.g_false,
743 p_payment_rec => l_payment_rec,
744 p_qte_header_rec => l_qte_header_rec,
745 P_Qte_Line_rec => l_qte_line_rec,
746 x_return_status => x_return_status,
747 x_msg_count => x_msg_count,
748 x_msg_data => x_msg_data);
749
750 IF aso_debug_pub.g_debug_flag = 'Y' THEN
751 aso_debug_pub.add('after calling Validate_cc_info ', 1, 'Y');
752 aso_debug_pub.add('Validate_cc_info Return Status: '||x_return_status, 1, 'Y');
753 END IF;
754
755 if x_return_status <> fnd_api.g_ret_sts_success then
756 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
757 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
758 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
759 RAISE FND_API.G_EXC_ERROR;
760 ELSE
761 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
762 END IF;
763 end if;
764 END IF;
765
766 -- setting the payer record as it is used in no of cases below
767 l_payer.payment_function := 'CUSTOMER_PAYMENT';
768 l_payer.cust_account_id := null;
769 l_payer.account_site_id := null;
770
771 If (nvl(l_db_payment_rec.payment_type_code,'NULL') <> 'CREDIT_CARD' and l_payment_rec.payment_type_code = 'CREDIT_CARD') then
772
773 -- this is similar to the create flow
774
775 If (l_payment_rec.instr_assignment_id is null or l_payment_rec.instr_assignment_id = fnd_api.g_miss_num ) then
776 -- this is quoting flow
777 -- call api to create credit card and assigment , if needed
778 IF aso_debug_pub.g_debug_flag = 'Y' THEN
779 aso_debug_pub.add('Before calling create_iby_payment' , 1, 'Y');
780 END IF;
781
782 If ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
783 l_payer.party_id := l_qte_line_rec.invoice_to_cust_party_id;
784 Else
785 l_payer.party_id := l_qte_header_rec.invoice_to_cust_party_id;
786 End If;
787
788 aso_payment_int.create_iby_payment(p_payment_rec => p_payment_rec,
789 p_payer => l_payer,
790 x_payment_rec => l_payment_rec,
791 x_return_status => x_return_status ,
792 x_msg_count => x_msg_count,
793 x_msg_data => x_msg_data);
794
795 IF aso_debug_pub.g_debug_flag = 'Y' THEN
796 aso_debug_pub.add('after calling create_iby_payment ', 1, 'Y');
797 aso_debug_pub.add('create_iby_payment Return Status: '||x_return_status, 1, 'Y');
798 END IF;
799
800 if x_return_status <> fnd_api.g_ret_sts_success then
801 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
802 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
803 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
804 RAISE FND_API.G_EXC_ERROR;
805 ELSE
809 else
806 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
807 END IF;
808 end if;
810 -- this is the iStore Flow
811 open c_get_payer_id(p_payment_rec.instr_assignment_id);
812 fetch c_get_payer_id into l_payer.party_id;
813 close c_get_payer_id;
814 end if;
815
816 l_trxn_attribs.Originating_Application_Id := 697;
817 l_trxn_attribs.Order_Id := to_char(l_payment_rec.payment_id)||'-'||l_qte_header_rec.quote_number;
818 l_trxn_attribs.PO_Number := null;
819 l_trxn_attribs.PO_Line_Number := null;
820 l_trxn_attribs.Trxn_Ref_Number1 := l_payment_rec.quote_header_id;
821
822 IF l_payment_rec.quote_line_id = fnd_api.g_miss_num then
823 l_trxn_attribs.Trxn_Ref_Number2 := null;
824 Else
825 l_trxn_attribs.Trxn_Ref_Number2 := l_payment_rec.quote_line_id;
826 End if;
827
828
829 -- Check to see if cvv2 is mandatory or not
830 IF aso_debug_pub.g_debug_flag = 'Y' THEN
831 aso_debug_pub.add('Before calling IBY_FNDCPT_TRXN_PUB.Get_Payment_Channel_Attribs ', 1, 'Y');
832 END IF;
833
834 IBY_FNDCPT_SETUP_PUB.Get_Payment_Channel_Attribs
835 (
836 p_api_version => 1.0,
837 p_init_msg_list => FND_API.G_FALSE,
838 x_return_status => x_return_status,
839 x_msg_count => x_msg_count,
840 x_msg_data => x_msg_data,
841 p_channel_code => 'CREDIT_CARD',
842 x_channel_attrib_uses => lx_channel_attrib_uses,
843 x_response => lx_response);
844
845 IF aso_debug_pub.g_debug_flag = 'Y' THEN
846 aso_debug_pub.add('after calling IBY_FNDCPT_TRXN_PUB.Get_Payment_Channel_Attribs ', 1, 'Y');
847 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
848 aso_debug_pub.add('cvv2 use: '||lx_channel_attrib_uses.Instr_SecCode_Use, 1, 'Y');
849 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
850 aso_debug_pub.add('x_response.result_category:'|| to_char(lx_response.result_category), 1, 'Y');
851 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
852 END IF;
853
854 IF (nvl(lx_channel_attrib_uses.Instr_SecCode_Use,'null') = 'REQUIRED' and
855 (l_payment_rec.cvv2 is null or l_payment_rec.cvv2 = fnd_api.g_miss_char)) then
856
857 x_return_status := FND_API.G_RET_STS_ERROR;
858 FND_MESSAGE.Set_Name('ASO', 'ASO_CC_INVALID');
859 FND_MSG_PUB.ADD;
860 RAISE FND_API.G_EXC_ERROR;
861 END IF;
862
863 if l_payment_rec.cvv2 = fnd_api.g_miss_char then
864 l_trxn_attribs.Instrument_Security_Code := null;
865 else
866 l_trxn_attribs.Instrument_Security_Code := l_payment_rec.cvv2;
867 end if;
868
869 l_trxn_attribs.VoiceAuth_Flag := null;
870 l_trxn_attribs.VoiceAuth_Date := null;
871 l_trxn_attribs.VoiceAuth_Code := null;
872 l_trxn_attribs.Additional_Info := null;
873
874
875 IF aso_debug_pub.g_debug_flag = 'Y' THEN
876 aso_debug_pub.add('Before calling IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', 1, 'Y');
877 aso_debug_pub.add('Instrument Assignment id: '|| l_payment_rec.instr_assignment_id, 1, 'Y');
878 END IF;
879
880 --bug 5154775
881 IF (l_payment_rec.instr_assignment_id is not null and l_payment_rec.instr_assignment_id <> fnd_api.g_miss_num) then
882 IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension
883 (
884 p_api_version => 1.0,
885 p_init_msg_list => FND_API.G_FALSE,
886 p_commit => FND_API.G_FALSE,
887 x_return_status => x_return_status,
888 x_msg_count => x_msg_count,
889 x_msg_data => x_msg_data,
890 p_payer => l_payer,
891 p_payer_equivalency => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
892 p_pmt_channel => l_payment_rec.payment_type_code,
893 p_instr_assignment => l_payment_rec.instr_assignment_id,
894 p_trxn_attribs => l_trxn_attribs,
895 x_entity_id => lx_entity_id,
896 x_response => lx_response);
897
898 IF aso_debug_pub.g_debug_flag = 'Y' THEN
899 aso_debug_pub.add('after calling IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', 1, 'Y');
900 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
901 aso_debug_pub.add('lx_entity_id: '||lx_entity_id, 1, 'Y');
902 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
903 aso_debug_pub.add('x_response.result_category: '|| to_char(lx_response.result_category), 1, 'Y');
904 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
905 END IF;
906
907 if x_return_status <> fnd_api.g_ret_sts_success then
908 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
909 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
910 FND_MESSAGE.Set_Token('API', 'IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', FALSE);
911 FND_MSG_PUB.ADD;
912 END IF;
913 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
914 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
915 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
916 RAISE FND_API.G_EXC_ERROR;
920 END IF; -- end if for the instr_assignment_id null check
917 END IF;
918 end if;
919 l_payment_rec.trxn_extension_id := lx_entity_id;
921
922 elsif (l_db_payment_rec.payment_type_code = 'CREDIT_CARD' and nvl(l_payment_rec.payment_type_code,'NULL') <> 'CREDIT_CARD'
923 and nvl(l_payment_rec.payment_type_code,'NULL') <> FND_API.G_MISS_CHAR) then
924
925 -- similar to delete flow, delete the trxn extension for the cc in the db
926 open c_get_payer_from_trxn(l_db_payment_rec.trxn_extension_id);
927 fetch c_get_payer_from_trxn into l_payer.party_id;
928 close c_get_payer_from_trxn;
929
930 IF aso_debug_pub.g_debug_flag = 'Y' THEN
931 aso_debug_pub.add('Before Calling IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension ', 1, 'Y');
932 aso_debug_pub.add('l_payer.party_id: '|| l_payer.party_id, 1, 'Y');
933 aso_debug_pub.add('l_payment_rec.trxn_extension_id: '|| l_db_payment_rec.trxn_extension_id, 1, 'Y');
934 END IF;
935
936 IF (l_db_payment_rec.trxn_extension_id is not null and l_db_payment_rec.trxn_extension_id <> fnd_api.g_miss_num ) then
937 IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension
938 (
939 p_api_version => 1.0,
940 p_init_msg_list => FND_API.G_FALSE,
941 p_commit => FND_API.G_FALSE,
942 x_return_status => x_return_status,
943 x_msg_count => x_msg_count,
944 x_msg_data => x_msg_data,
945 p_payer => l_payer,
946 p_entity_id => l_db_payment_rec.trxn_extension_id,
947 p_payer_equivalency => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
948 x_response => lx_response
949 );
950
951 IF aso_debug_pub.g_debug_flag = 'Y' THEN
952 aso_debug_pub.add('After Calling IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension ', 1, 'Y');
953 aso_debug_pub.add('Return Status from IBY Delete API: '||x_return_status, 1, 'Y');
954 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
955 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_category: '|| to_char(lx_response.result_category), 1, 'Y');
956 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
957 END IF;
958
959 if x_return_status <> fnd_api.g_ret_sts_success then
960 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
961 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
962 FND_MESSAGE.Set_Token('API', ' IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension', FALSE);
963 FND_MSG_PUB.ADD;
964 END IF;
965 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
966 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
967 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
968 RAISE FND_API.G_EXC_ERROR;
969 END IF;
970 end if;
971 end if; -- end if for the trxn ext id null check
972 l_payment_rec.trxn_extension_id := null;
973
974 elsif ( (nvl(l_db_payment_rec.payment_type_code,'NULL') = 'CREDIT_CARD') and
975 ((l_payment_rec.payment_type_code = 'CREDIT_CARD') OR (l_payment_rec.payment_type_code = fnd_api.g_miss_char))) then
976
977
978 if ((l_payment_rec.instr_assignment_id is null or l_payment_rec.instr_assignment_id = fnd_api.g_miss_num)
979 and (l_payment_rec.instrument_id is null or l_payment_rec.instrument_id = fnd_api.g_miss_num) )then
980 -- bug 5154775
981 if (l_payment_rec.payment_ref_number is not null and l_payment_rec.payment_ref_number <> fnd_api.g_miss_char ) then
982 -- this is again similar to create flow , create card and assignment, if needed and update extension
983 -- this is the quoting flow
984 -- call api to create credit card and assigment , if needed
985 IF aso_debug_pub.g_debug_flag = 'Y' THEN
986 aso_debug_pub.add('Before calling create_iby_payment' , 1, 'Y');
987 END IF;
988
989 If ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
990 l_payer.party_id := l_qte_line_rec.invoice_to_cust_party_id;
991 Else
992 l_payer.party_id := l_qte_header_rec.invoice_to_cust_party_id;
993 End If;
994
995 aso_payment_int.create_iby_payment(p_payment_rec => p_payment_rec,
996 db_payment_rec => l_db_payment_rec,
997 p_payer => l_payer,
998 x_payment_rec => l_payment_rec,
999 x_return_status => x_return_status ,
1000 x_msg_count => x_msg_count,
1001 x_msg_data => x_msg_data);
1002
1003 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1004 aso_debug_pub.add('after calling create_iby_payment ', 1, 'Y');
1005 aso_debug_pub.add('create_iby_payment Return Status: '||x_return_status, 1, 'Y');
1006 END IF;
1007
1008 if x_return_status <> fnd_api.g_ret_sts_success then
1009 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1010 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1011 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1012 RAISE FND_API.G_EXC_ERROR;
1013 ELSE
1014 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1015 END IF;
1016 end if;
1017 else
1018 -- this means the input cc is a fax cc
1022 fetch c_get_payer_from_trxn into l_orig_party_id;
1019 l_shared_cart_scenario := 'Y';
1020 IF (l_db_payment_rec.trxn_extension_id is not null and l_db_payment_rec.trxn_extension_id <> fnd_api.g_miss_num) then
1021 open c_get_payer_from_trxn(l_db_payment_rec.trxn_extension_id);
1023 close c_get_payer_from_trxn;
1024 END IF;
1025 end if; -- check for payment ref num
1026 elsif ((l_payment_rec.instr_assignment_id is not null and l_payment_rec.instr_assignment_id <> fnd_api.g_miss_num)
1027 and (l_payment_rec.instrument_id is not null and l_payment_rec.instrument_id <> fnd_api.g_miss_num) )then
1028
1029 -- this means card has been updated, this is the quoting flow
1030 If ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
1031 l_payer.party_id := l_qte_line_rec.invoice_to_cust_party_id;
1032 Else
1033 l_payer.party_id := l_qte_header_rec.invoice_to_cust_party_id;
1034 End If;
1035
1036 l_card_instrument.card_id := l_payment_rec.instrument_id;
1037
1038 -- user can possibly change exp date and name on the card
1039 if l_payment_rec.credit_card_expiration_date = fnd_api.g_miss_date then
1040 l_card_instrument.expiration_date := null;
1041 else
1042 l_card_instrument.expiration_date := last_day(l_payment_rec.credit_card_expiration_date);
1043 end if;
1044
1045 if l_payment_rec.credit_card_holder_name = fnd_api.g_miss_char then
1046 l_card_instrument.card_holder_name := null;
1047 else
1048 l_card_instrument.card_holder_name := l_payment_rec.credit_card_holder_name;
1049 end if;
1050
1051 if l_payment_rec.credit_card_code = fnd_api.g_miss_char then
1052 l_card_instrument.card_issuer := null;
1053 else
1054 l_card_instrument.card_issuer := l_payment_rec.credit_card_code;
1055 end if;
1056
1057
1058 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1059 aso_debug_pub.add('Before calling IBY_FNDCPT_SETUP_PUB.Update_Card', 1, 'Y');
1060 aso_debug_pub.add('Instrument id: '|| l_payment_rec.instrument_id, 1, 'Y');
1061 END IF;
1062 IBY_FNDCPT_SETUP_PUB.Update_Card
1063 (
1064 p_api_version => 1.0,
1065 p_init_msg_list => FND_API.G_FALSE,
1066 p_commit => FND_API.G_FALSE,
1067 x_return_status => x_return_status,
1068 x_msg_count => x_msg_count,
1069 x_msg_data => x_msg_data,
1070 p_card_instrument => l_card_instrument,
1071 x_response => lx_response);
1072 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1073 aso_debug_pub.add('after calling IBY_FNDCPT_SETUP_PUB.Update_Card', 1, 'Y');
1074 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
1075 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
1076 aso_debug_pub.add('x_response.result_category: '|| to_char(lx_response.result_category), 1, 'Y');
1077 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
1078 END IF;
1079
1080 if x_return_status <> fnd_api.g_ret_sts_success then
1081 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1082 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
1083 FND_MESSAGE.Set_Token('API', 'IBY_FNDCPT_SETUP_PUB.Update_Card', FALSE);
1084 FND_MSG_PUB.ADD;
1085 END IF;
1086 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1087 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1088 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1089 RAISE FND_API.G_EXC_ERROR;
1090 END IF;
1091 end if;
1092
1093 else
1094 -- this is the iStore Flow
1095 open c_get_payer_id(l_payment_rec.instr_assignment_id);
1096 fetch c_get_payer_id into l_payer.party_id;
1097 close c_get_payer_id;
1098 -- fix for bug 4767905
1099 IF (l_db_payment_rec.trxn_extension_id is not null and l_db_payment_rec.trxn_extension_id <> fnd_api.g_miss_num) then
1100 open c_get_payer_from_trxn(l_db_payment_rec.trxn_extension_id);
1101 fetch c_get_payer_from_trxn into l_orig_party_id;
1102 close c_get_payer_from_trxn;
1103
1104 IF ( nvl(l_payer.party_id,0) <> nvl(l_orig_party_id,0) ) THEN
1105 l_shared_cart_scenario := 'Y';
1106 END IF;
1107
1108 END IF; -- trxn_extension_id not null check
1109 end if;
1110
1111 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1112 aso_debug_pub.add('l_payer.party_id: '|| l_payer.party_id, 1, 'Y');
1113 aso_debug_pub.add('l_orig_party_id: '|| l_orig_party_id, 1, 'Y');
1114 aso_debug_pub.add('l_shared_cart_scenario: '|| l_shared_cart_scenario, 1, 'Y');
1115 END IF;
1116
1117 l_trxn_attribs.Originating_Application_Id := 697;
1118 l_trxn_attribs.Order_Id := to_char(l_payment_rec.payment_id)||'-'||l_qte_header_rec.quote_number;
1119 l_trxn_attribs.PO_Number := null;
1120 l_trxn_attribs.PO_Line_Number := null;
1121 l_trxn_attribs.Trxn_Ref_Number1 := l_payment_rec.quote_header_id;
1122 If l_payment_rec.quote_line_id = fnd_api.g_miss_num then
1123 l_trxn_attribs.Trxn_Ref_Number2 := null;
1124 Else
1125 l_trxn_attribs.Trxn_Ref_Number2 := l_payment_rec.quote_line_id;
1126 End if;
1127
1131 aso_debug_pub.add('Before calling IBY_FNDCPT_TRXN_PUB.Get_Payment_Channel_Attribs ', 1, 'Y');
1128 -- Check to see if cvv2 is mandatory or not
1129 /* In case of updating the trxn no need to check for cvv2 see bug 4746260
1130 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1132 END IF;
1133
1134 IBY_FNDCPT_SETUP_PUB.Get_Payment_Channel_Attribs
1135 (
1136 p_api_version => 1.0,
1137 p_init_msg_list => FND_API.G_FALSE,
1138 x_return_status => x_return_status,
1139 x_msg_count => x_msg_count,
1140 x_msg_data => x_msg_data,
1141 p_channel_code => 'CREDIT_CARD',
1142 x_channel_attrib_uses => lx_channel_attrib_uses,
1143 x_response => lx_response);
1144
1145 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1146 aso_debug_pub.add('after calling IBY_FNDCPT_TRXN_PUB.Get_Payment_Channel_Attribs ', 1, 'Y');
1147 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
1148 aso_debug_pub.add('cvv2 use: '||lx_channel_attrib_uses.Instr_SecCode_Use, 1, 'Y');
1149 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
1150 aso_debug_pub.add('x_response.result_category:'|| to_char(lx_response.result_category), 1, 'Y');
1151 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
1152 END IF;
1153
1154 IF (nvl(lx_channel_attrib_uses.Instr_SecCode_Use,'null') = 'REQUIRED' and
1155 (l_payment_rec.cvv2 is null or l_payment_rec.cvv2 = fnd_api.g_miss_char)) then
1156
1157 x_return_status := FND_API.G_RET_STS_ERROR;
1158 FND_MESSAGE.Set_Name('ASO', 'ASO_CC_INVALID');
1159 FND_MSG_PUB.ADD;
1160 RAISE FND_API.G_EXC_ERROR;
1161 END IF;
1162 */
1163
1164 if l_payment_rec.cvv2 = fnd_api.g_miss_char then
1165 l_trxn_attribs.Instrument_Security_Code := null;
1166 else
1167 l_trxn_attribs.Instrument_Security_Code := l_payment_rec.cvv2;
1168 end if;
1169
1170 l_trxn_attribs.VoiceAuth_Flag := null;
1171 l_trxn_attribs.VoiceAuth_Date := null;
1172 l_trxn_attribs.VoiceAuth_Code := null;
1173 l_trxn_attribs.Additional_Info := null;
1174
1175
1176 --bug 5154775
1177 IF ( (l_db_payment_rec.trxn_extension_id is not null and l_db_payment_rec.trxn_extension_id <> fnd_api.g_miss_num) and
1178 (l_payment_rec.instr_assignment_id IS NOT NULL AND l_payment_rec.instr_assignment_id <> fnd_api.g_miss_num) and
1179 (l_shared_cart_scenario = 'N')) then
1180
1181 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1182 aso_debug_pub.add('Before calling IBY_FNDCPT_TRXN_PUB.Update_Transaction_Extension ', 1, 'Y');
1183 aso_debug_pub.add('Instrument Assignment id: '|| l_payment_rec.instr_assignment_id, 1, 'Y');
1184 END IF;
1185
1186 IBY_FNDCPT_TRXN_PUB.Update_Transaction_Extension
1187 (
1188 p_api_version => 1.0,
1189 p_init_msg_list => FND_API.G_FALSE,
1190 p_commit => FND_API.G_FALSE,
1191 x_return_status => x_return_status,
1192 x_msg_count => x_msg_count,
1193 x_msg_data => x_msg_data,
1194 p_payer => l_payer,
1195 p_payer_equivalency => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
1196 p_entity_id => l_db_payment_rec.trxn_extension_id,
1197 p_pmt_channel => l_db_payment_rec.payment_type_code,
1198 p_instr_assignment => l_payment_rec.instr_assignment_id,
1199 p_trxn_attribs => l_trxn_attribs,
1200 x_response => lx_response);
1201
1202 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1203 aso_debug_pub.add('after calling IBY_FNDCPT_TRXN_PUB.Update_Transaction_Extension ', 1, 'Y');
1204 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
1205 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
1206 aso_debug_pub.add('x_response.result_category: '|| to_char(lx_response.result_category), 1, 'Y');
1207 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
1208 END IF;
1209
1210 IF x_return_status <> fnd_api.g_ret_sts_success then
1211 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1212 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
1213 FND_MESSAGE.Set_Token('API', 'IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', FALSE);
1214 FND_MSG_PUB.ADD;
1215 END IF;
1216 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1217 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1218 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1219 RAISE FND_API.G_EXC_ERROR;
1220 END IF;
1221 END IF;
1222
1223 ELSE -- else condition for trxn id not null
1224 -- fix for bug 4767905 and 5154775
1225 -- if cc has been created by shared user, then delete the previous extension
1226 if ( l_shared_cart_scenario = 'Y' and l_db_payment_rec.trxn_extension_id is not null
1227 and l_db_payment_rec.trxn_extension_id <> fnd_api.g_miss_num ) THEN
1228
1229 -- set the party id to that of the orig user for deleting the trxn
1233 aso_debug_pub.add('l_payer.party_id: '|| l_payer.party_id, 1, 'Y');
1230 l_payer.party_id := l_orig_party_id;
1231 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1232 aso_debug_pub.add('Before Calling IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension ', 1, 'Y');
1234 aso_debug_pub.add('l_db_payment_rec.trxn_extension_id: '|| l_db_payment_rec.trxn_extension_id, 1, 'Y');
1235 END IF;
1236
1237 IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension
1238 (
1239 p_api_version => 1.0,
1240 p_init_msg_list => FND_API.G_FALSE,
1241 p_commit => FND_API.G_FALSE,
1242 x_return_status => x_return_status,
1243 x_msg_count => x_msg_count,
1244 x_msg_data => x_msg_data,
1245 p_payer => l_payer,
1246 p_entity_id => l_db_payment_rec.trxn_extension_id,
1247 p_payer_equivalency => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
1248 x_response => lx_response
1249 );
1250
1251 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1252 aso_debug_pub.add('After Calling IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension ', 1, 'Y');
1253 aso_debug_pub.add('Return Status from IBY Delete API: '||x_return_status, 1, 'Y');
1254 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
1255 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_category: '|| to_char(lx_response.result_category), 1, 'Y');
1256 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
1257 END IF;
1258
1259 if x_return_status <> fnd_api.g_ret_sts_success then
1260 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1261 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
1262 FND_MESSAGE.Set_Token('API', ' IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension', FALSE);
1263 FND_MSG_PUB.ADD;
1264 END IF;
1265 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1266 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1267 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1268 RAISE FND_API.G_EXC_ERROR;
1269 END IF;
1270 end if;
1271 -- reset the party id to that of the shared user
1272 open c_get_payer_id(l_payment_rec.instr_assignment_id);
1273 fetch c_get_payer_id into l_payer.party_id;
1274 close c_get_payer_id;
1275 -- set the trxn ext id to null
1276 l_payment_rec.trxn_extension_id := null;
1277
1278 end if; -- end if for the l_shared_cart_scenario flag check
1279
1280 -- The earlier card stored in the db had no transaction ext id so it must be an Istore Fax CC scenario
1281 -- or this is a shared card scenario and cc has been created by shared user, hence create a new trxn ext
1282 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1283 aso_debug_pub.add('No trx ext id exists for cc iStore Fax CC being updated ', 1, 'Y');
1284 aso_debug_pub.add('Before calling IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', 1, 'Y');
1285 aso_debug_pub.add('Instrument Assignment id: '|| l_payment_rec.instr_assignment_id, 1, 'Y');
1286 aso_debug_pub.add('l_payer.party_id: '|| l_payer.party_id,1,'Y');
1287 END IF;
1288
1289 -- Check to see if cvv2 is mandatory or not
1290 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1291 aso_debug_pub.add('Before calling IBY_FNDCPT_TRXN_PUB.Get_Payment_Channel_Attribs ', 1, 'Y');
1292 END IF;
1293
1294 IBY_FNDCPT_SETUP_PUB.Get_Payment_Channel_Attribs
1295 (
1296 p_api_version => 1.0,
1297 p_init_msg_list => FND_API.G_FALSE,
1298 x_return_status => x_return_status,
1299 x_msg_count => x_msg_count,
1300 x_msg_data => x_msg_data,
1301 p_channel_code => 'CREDIT_CARD',
1302 x_channel_attrib_uses => lx_channel_attrib_uses,
1303 x_response => lx_response);
1304
1305 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1306 aso_debug_pub.add('after calling IBY_FNDCPT_TRXN_PUB.Get_Payment_Channel_Attribs ', 1, 'Y');
1307 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
1308 aso_debug_pub.add('cvv2 use: '||lx_channel_attrib_uses.Instr_SecCode_Use, 1, 'Y');
1309 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
1310 aso_debug_pub.add('x_response.result_category:'|| to_char(lx_response.result_category), 1, 'Y');
1311 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
1312 END IF;
1313
1314 IF (nvl(lx_channel_attrib_uses.Instr_SecCode_Use,'null') = 'REQUIRED' and
1315 (l_payment_rec.cvv2 is null or l_payment_rec.cvv2 = fnd_api.g_miss_char)) then
1316
1317 x_return_status := FND_API.G_RET_STS_ERROR;
1318 FND_MESSAGE.Set_Name('ASO', 'ASO_CC_INVALID');
1319 FND_MSG_PUB.ADD;
1320 RAISE FND_API.G_EXC_ERROR;
1321 END IF;
1322
1326 p_api_version => 1.0,
1323 if (l_payment_rec.instr_assignment_id is not null and l_payment_rec.instr_assignment_id <> fnd_api.g_miss_num) then
1324 IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension
1325 (
1327 p_init_msg_list => FND_API.G_FALSE,
1328 p_commit => FND_API.G_FALSE,
1329 x_return_status => x_return_status,
1330 x_msg_count => x_msg_count,
1331 x_msg_data => x_msg_data,
1332 p_payer => l_payer,
1333 p_payer_equivalency => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
1334 p_pmt_channel => l_payment_rec.payment_type_code,
1335 p_instr_assignment => l_payment_rec.instr_assignment_id,
1336 p_trxn_attribs => l_trxn_attribs,
1337 x_entity_id => lx_entity_id,
1338 x_response => lx_response);
1339
1340 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1341 aso_debug_pub.add('after calling IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', 1, 'Y');
1342 aso_debug_pub.add('Return Status: '||x_return_status, 1, 'Y');
1343 aso_debug_pub.add('lx_entity_id: '||lx_entity_id, 1, 'Y');
1344 aso_debug_pub.add('x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
1345 aso_debug_pub.add('x_response.result_category:'|| to_char(lx_response.result_category), 1, 'Y');
1346 aso_debug_pub.add('x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
1347 END IF;
1348
1349 if x_return_status <> fnd_api.g_ret_sts_success then
1350 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1351 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
1352 FND_MESSAGE.Set_Token('API', 'IBY_FNDCPT_TRXN_PUB.Create_Transaction_Extension ', FALSE);
1353 FND_MSG_PUB.ADD;
1354 END IF;
1355 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1356 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1357 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1358 RAISE FND_API.G_EXC_ERROR;
1359 END IF;
1360 end if;
1361 l_payment_rec.trxn_extension_id := lx_entity_id;
1362 end if; -- end if for the instr_assignment_id check
1363
1364 end if; -- check for trxn extension id
1365 end if;
1366
1367
1368 IF ((l_payment_rec.PAYMENT_TYPE_CODE = 'CREDIT_CARD') or
1369 ( l_db_payment_rec.payment_type_code = 'CREDIT_CARD' and l_payment_rec.PAYMENT_TYPE_CODE = fnd_api.g_miss_char)) then
1370 l_payment_ref_number := null;
1371 else
1372 l_payment_ref_number := l_payment_rec.PAYMENT_REF_NUMBER;
1373 END IF;
1374
1375 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1376 aso_debug_pub.add('before calling the table handler to update the data ', 1, 'Y');
1377 END IF;
1378
1379 ASO_PAYMENTS_PKG.Update_Row(
1380 p_PAYMENT_ID => l_payment_rec.PAYMENT_ID,
1381 p_CREATION_DATE => l_payment_rec.creation_date,
1382 p_CREATED_BY => fnd_global.USER_ID,
1383 p_LAST_UPDATE_DATE => sysdate,
1384 p_LAST_UPDATED_BY => fnd_global.USER_ID,
1385 p_LAST_UPDATE_LOGIN => FND_GLOBAL.CONC_LOGIN_ID,
1386 p_REQUEST_ID => l_payment_rec.REQUEST_ID,
1387 p_PROGRAM_APPLICATION_ID => l_payment_rec.PROGRAM_APPLICATION_ID,
1388 p_PROGRAM_ID => l_payment_rec.PROGRAM_ID,
1389 p_PROGRAM_UPDATE_DATE => l_payment_rec.PROGRAM_UPDATE_DATE,
1390 p_QUOTE_HEADER_ID => l_payment_rec.quote_header_id,
1391 p_QUOTE_LINE_ID => l_payment_rec.QUOTE_LINE_ID,
1392 p_PAYMENT_TYPE_CODE => l_payment_rec.PAYMENT_TYPE_CODE,
1393 p_PAYMENT_REF_NUMBER => l_payment_ref_number,
1394 p_PAYMENT_OPTION => l_payment_rec.PAYMENT_OPTION,
1395 p_PAYMENT_TERM_ID => l_payment_rec.PAYMENT_TERM_ID,
1396 p_CREDIT_CARD_CODE => null,
1397 p_CREDIT_CARD_HOLDER_NAME => null,
1398 p_CREDIT_CARD_EXPIRATION_DATE => null,
1399 p_CREDIT_CARD_APPROVAL_CODE => null,
1400 p_CREDIT_CARD_APPROVAL_DATE => null,
1401 p_PAYMENT_AMOUNT => l_payment_rec.PAYMENT_AMOUNT,
1402 p_ATTRIBUTE_CATEGORY => l_payment_rec.ATTRIBUTE_CATEGORY,
1403 p_ATTRIBUTE1 => l_payment_rec.ATTRIBUTE1,
1404 p_ATTRIBUTE2 => l_payment_rec.ATTRIBUTE2,
1405 p_ATTRIBUTE3 => l_payment_rec.ATTRIBUTE3,
1406 p_ATTRIBUTE4 => l_payment_rec.ATTRIBUTE4,
1407 p_ATTRIBUTE5 => l_payment_rec.ATTRIBUTE5,
1408 p_ATTRIBUTE6 => l_payment_rec.ATTRIBUTE6,
1409 p_ATTRIBUTE7 => l_payment_rec.ATTRIBUTE7,
1410 p_ATTRIBUTE8 => l_payment_rec.ATTRIBUTE8,
1411 p_ATTRIBUTE9 => l_payment_rec.ATTRIBUTE9,
1412 p_ATTRIBUTE10 => l_payment_rec.ATTRIBUTE10,
1413 p_ATTRIBUTE11 => l_payment_rec.ATTRIBUTE11,
1414 p_ATTRIBUTE12 => l_payment_rec.ATTRIBUTE12,
1415 p_ATTRIBUTE13 => l_payment_rec.ATTRIBUTE13,
1416 p_ATTRIBUTE14 => l_payment_rec.ATTRIBUTE14,
1417 p_ATTRIBUTE15 => l_payment_rec.ATTRIBUTE15,
1421 p_ATTRIBUTE19 => l_payment_rec.ATTRIBUTE19,
1418 p_ATTRIBUTE16 => l_payment_rec.ATTRIBUTE16,
1419 p_ATTRIBUTE17 => l_payment_rec.ATTRIBUTE17,
1420 p_ATTRIBUTE18 => l_payment_rec.ATTRIBUTE18,
1422 p_ATTRIBUTE20 => l_payment_rec.ATTRIBUTE20,
1423 p_QUOTE_SHIPMENT_ID => l_payment_rec.QUOTE_SHIPMENT_ID,
1424 p_CUST_PO_NUMBER => l_payment_rec.CUST_PO_NUMBER,
1425 p_PAYMENT_TERM_ID_FROM => l_payment_rec.PAYMENT_TERM_ID_FROM,
1426 p_OBJECT_VERSION_NUMBER => l_payment_rec.OBJECT_VERSION_NUMBER,
1427 p_CUST_PO_LINE_NUMBER => l_payment_rec.CUST_PO_LINE_NUMBER,
1428 p_TRXN_EXTENSION_ID => l_payment_rec.trxn_extension_id
1429 );
1430
1431 x_payment_rec := l_payment_rec;
1432
1433
1434 -- End API Body
1435
1436
1437 -- Standard check for p_commit
1438 /*IF FND_API.to_Boolean( p_commit )
1439 THEN
1440 COMMIT WORK;
1441 END IF; */
1442
1443 -- Standard call to get message count and if count is 1, get message info.
1444 FND_MSG_PUB.Count_And_Get
1445 ( p_count => x_msg_count,
1446 p_data => x_msg_data
1447 );
1448
1449 IF ASO_DEBUG_PUB.G_Debug_Flag = 'Y' THEN
1450 aso_debug_pub.ADD ('END update_payment_row',1,'N');
1451 END IF;
1452
1453 EXCEPTION
1454 WHEN FND_API.G_EXC_ERROR THEN
1455 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
1456 P_API_NAME => L_API_NAME
1457 ,P_PKG_NAME => G_PKG_NAME
1458 ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_ERROR
1459 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
1460 ,X_MSG_COUNT => X_MSG_COUNT
1461 ,X_MSG_DATA => X_MSG_DATA
1462 ,X_RETURN_STATUS => X_RETURN_STATUS);
1463
1464 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1465 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
1466 P_API_NAME => L_API_NAME
1467 ,P_PKG_NAME => G_PKG_NAME
1468 ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR
1469 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
1470 ,X_MSG_COUNT => X_MSG_COUNT
1471 ,X_MSG_DATA => X_MSG_DATA
1472 ,X_RETURN_STATUS => X_RETURN_STATUS);
1473
1474 WHEN OTHERS THEN
1475 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
1476 P_API_NAME => L_API_NAME
1477 ,P_PKG_NAME => G_PKG_NAME
1478 ,P_EXCEPTION_LEVEL => ASO_UTILITY_PVT.G_EXC_OTHERS
1479 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
1480 ,X_MSG_COUNT => X_MSG_COUNT
1481 ,X_MSG_DATA => X_MSG_DATA
1482 ,X_RETURN_STATUS => X_RETURN_STATUS);
1483 end update_payment_row;
1484
1485
1486 PROCEDURE delete_payment_row(p_payment_rec IN aso_quote_pub.payment_rec_type,
1487 x_return_status OUT NOCOPY varchar2,
1488 x_msg_count OUT NOCOPY number,
1489 x_msg_data OUT NOCOPY varchar2)
1490 IS
1491
1492 L_API_NAME varchar2(1000) := 'delete_payment_row';
1493 l_payer IBY_FNDCPT_COMMON_PUB.PayerContext_rec_type;
1494 l_payment_rec aso_quote_pub.payment_rec_type := p_payment_rec;
1495 l_payment_tbl ASO_QUOTE_PUB.Payment_Tbl_Type;
1496 lx_response IBY_FNDCPT_COMMON_PUB.Result_rec_type;
1497 l_qte_header_rec ASO_QUOTE_PUB.Qte_Header_Rec_Type;
1498 l_qte_line_rec ASO_QUOTE_PUB.Qte_Line_Rec_Type;
1499
1500
1501 Cursor c_get_payer_from_trxn(p_trxn_extension_id number) is
1502 select a.party_id
1503 from iby_fndcpt_payer_assgn_instr_v a, IBY_TRXN_EXTENSIONS_V b
1504 where a.instr_assignment_id = b.instr_assignment_id
1505 and b.trxn_extension_id = p_trxn_extension_id;
1506
1507 Begin
1508
1509 SAVEPOINT DELETE_PAYMENT_ROW_INT;
1510 aso_debug_pub.g_debug_flag := nvl(fnd_profile.value('ASO_ENABLE_DEBUG'),'N');
1511
1512 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1513 aso_debug_pub.add('Begin delete_payment_row ', 1, 'Y');
1514 END IF;
1515
1516 x_return_status := FND_API.G_RET_STS_SUCCESS;
1517
1518 l_qte_header_rec := ASO_UTILITY_PVT.Query_Header_Row (l_payment_rec.Quote_Header_Id );
1519
1520 IF ( l_payment_rec.Quote_Line_Id IS NOT NULL and l_payment_rec.Quote_Line_Id <> fnd_api.g_miss_num) then
1521 l_qte_line_rec := ASO_UTILITY_PVT.Query_Qte_Line_Row ( l_payment_rec.Quote_Line_Id );
1522 END IF;
1523
1524 --Get the databse payment record and assign it to l_payment_rec
1525 IF ( l_payment_rec.Quote_Line_Id = fnd_api.g_miss_num) then
1526 l_payment_rec.quote_line_id := null;
1527 END IF;
1528
1529 l_payment_tbl := aso_utility_pvt.Query_Payment_Rows(l_payment_rec.quote_header_id,l_payment_rec.quote_line_id);
1530 l_payment_rec := l_payment_tbl(1);
1531
1532 if l_payment_tbl.count > 0 and l_payment_rec.payment_type_code = 'CREDIT_CARD' then
1533
1534 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1535 aso_debug_pub.add('Database payment_type_code is : '|| l_payment_rec.payment_type_code, 1, 'Y');
1536 END IF;
1537
1538 l_payer.payment_function := 'CUSTOMER_PAYMENT';
1539 l_payer.cust_account_id := null;
1540 l_payer.account_site_id := null;
1541
1542 open c_get_payer_from_trxn(l_payment_rec.trxn_extension_id);
1543 fetch c_get_payer_from_trxn into l_payer.party_id;
1544 close c_get_payer_from_trxn;
1545
1546
1547 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1551 END IF;
1548 aso_debug_pub.add('Before Calling IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension ', 1, 'Y');
1549 aso_debug_pub.add('l_payer.party_id: '|| l_payer.party_id, 1, 'Y');
1550 aso_debug_pub.add('l_payment_rec.trxn_extension_id: '|| l_payment_rec.trxn_extension_id, 1, 'Y');
1552
1553 IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension
1554 (
1555 p_api_version => 1.0,
1556 p_init_msg_list => FND_API.G_FALSE,
1557 p_commit => FND_API.G_FALSE,
1558 x_return_status => x_return_status,
1559 x_msg_count => x_msg_count,
1560 x_msg_data => x_msg_data,
1561 p_payer => l_payer,
1562 p_entity_id => l_payment_rec.trxn_extension_id,
1563 p_payer_equivalency => IBY_FNDCPT_COMMON_PUB.G_PAYER_EQUIV_UPWARD,
1564 x_response => lx_response
1565 );
1566
1567 IF aso_debug_pub.g_debug_flag = 'Y' THEN
1568 aso_debug_pub.add('After Calling IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension ', 1, 'Y');
1569 aso_debug_pub.add('Return Status from IBY Delete API: '||x_return_status, 1, 'Y');
1570 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_code: '|| to_char(lx_response.result_code), 1, 'Y');
1571 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_category: '|| to_char(lx_response.result_category), 1, 'Y');
1572 aso_debug_pub.add('Delete_Transaction_Extension x_response.result_message: '|| to_char(lx_response.result_message), 1, 'Y');
1573 END IF;
1574
1575 if x_return_status <> fnd_api.g_ret_sts_success then
1576 IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1577 FND_MESSAGE.Set_Name('ASO', 'ERROR_RETURNED');
1578 FND_MESSAGE.Set_Token('API', ' IBY_FNDCPT_TRXN_PUB.Delete_Transaction_Extension', FALSE);
1579 FND_MSG_PUB.ADD;
1580 END IF;
1581 IF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1582 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1583 ELSIF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1584 RAISE FND_API.G_EXC_ERROR;
1585 END IF;
1586 end if;
1587 end if;
1588
1589 ASO_PAYMENTS_PKG.Delete_Row(p_PAYMENT_ID => p_payment_rec.PAYMENT_ID);
1590
1591 -- Standard check for p_commit
1592 /*IF FND_API.to_Boolean( p_commit )
1593 THEN
1594 COMMIT WORK;
1595 END IF; */
1596
1597 -- Standard call to get message count and if count is 1, get message info.
1598 FND_MSG_PUB.Count_And_Get
1599 ( p_count => x_msg_count,
1600 p_data => x_msg_data
1601 );
1602
1603 IF ASO_DEBUG_PUB.G_Debug_Flag = 'Y' THEN
1604 aso_debug_pub.ADD ('END delete_payment_row',1,'N');
1605 END IF;
1606
1607 EXCEPTION
1608 WHEN FND_API.G_EXC_ERROR THEN
1609 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
1610 P_API_NAME => L_API_NAME
1611 ,P_PKG_NAME => G_PKG_NAME
1612 ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_ERROR
1613 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
1614 ,X_MSG_COUNT => X_MSG_COUNT
1615 ,X_MSG_DATA => X_MSG_DATA
1616 ,X_RETURN_STATUS => X_RETURN_STATUS);
1617
1618 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1619 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
1620 P_API_NAME => L_API_NAME
1621 ,P_PKG_NAME => G_PKG_NAME
1622 ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR
1623 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
1624 ,X_MSG_COUNT => X_MSG_COUNT
1625 ,X_MSG_DATA => X_MSG_DATA
1626 ,X_RETURN_STATUS => X_RETURN_STATUS);
1627
1628 WHEN OTHERS THEN
1629 ASO_UTILITY_PVT.HANDLE_EXCEPTIONS(
1630 P_API_NAME => L_API_NAME
1631 ,P_PKG_NAME => G_PKG_NAME
1632 ,P_EXCEPTION_LEVEL => ASO_UTILITY_PVT.G_EXC_OTHERS
1633 ,P_PACKAGE_TYPE => ASO_UTILITY_PVT.G_INT
1634 ,X_MSG_COUNT => X_MSG_COUNT
1635 ,X_MSG_DATA => X_MSG_DATA
1636 ,X_RETURN_STATUS => X_RETURN_STATUS);
1637 End delete_payment_row;
1638
1639
1640
1641 End ASO_PAYMENT_INT;