DBA Data[Home] [Help]

PACKAGE BODY: APPS.AR_PMT_PROCESS_WRAPPER

Source


1 package body AR_PMT_PROCESS_WRAPPER AS
2 /* $Header: ARIPAYWB.pls 120.3 2005/09/14 11:21:25 sgnagara noship $ */
3 
4  /*=======================================================================+
5  |  Package Global Constants
6  +=======================================================================*/
7  PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
8 
9  /*========================================================================
10  | PUBLIC PROCEDURE Authorize_Payment
11  |
12  | DESCRIPTION
13  |      This procedure makes a  call to iPayment's API for Authorization
14  |      IBY_Payment_Adapter_pub.OraPmtReq.
15  |
16  |
17  | PSEUDO CODE/LOGIC
18  |
19  | PARAMETERS
20  |      p_receipt_info_rec IN
21  |         This parameter is for capturing certain receipt related information
22  |         that could be useful in customizations.
23  |
24  |      p_authorize_input_rec      IN
25  |         This parameter is for capturing all the information that is required
26  |         to send to iPayment for Authorizations.
27  |
28  |      x_authorize_output_rec     OUT
29  |         This is the output record and comprises of the output record
30  |         returned by iPayment API IBY_Payment_Adapter_pub.ReqResp_rec_type
31  |
32  |
33  | KNOWN ISSUES
34  |
35  |
36  |
37  | NOTES
38  |
39  |
40  |
41  | MODIFICATION HISTORY
42  | Date                  Author            Description of Changes
43  | 15-MAR-2004           Jyoti Pandey      Created
44  | 14-JUN-2004           Jyoti Pandey      Bug 3672953 Pass unique reference
45  |                                         for AUTH
46  *=======================================================================*/
47   PROCEDURE Authorize_Payment (
48    p_receipt_info_rec IN receipt_info_rec,
49    p_authorize_input_rec IN authorize_input_rec,
50    x_authorize_output_rec OUT NOCOPY authorize_output_rec,
51    x_return_status OUT NOCOPY VARCHAR2,
52    x_msg_count OUT NOCOPY NUMBER,
53    x_msg_data OUT NOCOPY VARCHAR2) IS
54 
55   /*-----------------------------------------------------------------------+
56    | Local Variable Declarations and initializations                       |
57    +-----------------------------------------------------------------------*/
58   l_payee_rec       IBY_Payment_Adapter_pub.Payee_Rec_type;
59   l_customer_rec    IBY_Payment_Adapter_pub.Payer_Rec_type;
60   l_tangible_rec    IBY_Payment_Adapter_pub.Tangible_Rec_type;
61   l_pmtreqtrxn_rec  IBY_Payment_Adapter_pub.PmtReqTrxn_Rec_type;
62   l_pmtinstr_rec    IBY_payment_adapter_pub.PmtInstr_Rec_type;
63   /* Bug-4606039
64   l_cc_instr_rec    IBY_Payment_Adapter_pub.CreditCardInstr_Rec_Type; */
65   l_reqresp_rec     IBY_Payment_Adapter_pub.ReqResp_rec_type;
66   l_riskinfo_rec    IBY_Payment_Adapter_pub.RiskInfo_rec_type;
67 
68   l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
69   l_msg_count NUMBER;
70   l_msg_data  VARCHAR2(2000);
71 
72 BEGIN
73 
74   IF PG_DEBUG in ('Y', 'C') THEN
75     arp_standard.debug('AR_PMT_PROCESS_WRAPPER.Authorize_Payment(+)');
76   END IF;
77 
78   -- set up payee record:
79   l_payee_rec.payee_id := p_authorize_input_rec.merchant_ref;
80 
81   -- set up payer (=customer) record
82   /* Bug-4606039
86   /* Bug-4606039
83   l_customer_rec.payer_name := p_authorize_input_rec.cus_bank_act_name; */
84 
85   -- set up cc instrument record
87   l_cc_instr_rec.cc_num     := p_authorize_input_rec.cus_bank_act_num;
88   l_cc_instr_rec.cc_ExpDate := p_authorize_input_rec.cus_bank_exp_date;
89   l_cc_instr_rec.cc_HolderName := p_authorize_input_rec.cus_bank_act_name; */
90 
91   -- set the credit card as the payment instrument
92   /* Bug-4606039
93   l_pmtinstr_rec.creditcardinstr:= l_cc_instr_rec; */
94 
95   --set the tangible record
96   l_tangible_rec.tangible_id:= p_authorize_input_rec.payment_server_order_num;
97   l_tangible_rec.tangible_amount := p_authorize_input_rec.receipt_amount;
98   l_tangible_rec.currency_code   := p_authorize_input_rec.currency_code;
99   l_tangible_rec.refinfo         := p_authorize_input_rec.receipt_number;
100 
101   l_pmtreqtrxn_rec.pmtmode   := 'ONLINE';
102   l_pmtreqtrxn_rec.auth_type := 'AUTHONLY';
103 
104   ---Bug 3672953 Pass Unique reference for Auth
105   l_pmtreqtrxn_rec.TrxnRef   := p_authorize_input_rec.unique_reference;
106 
107   -- call to iPayment API OraPmtReq to authorize funds
108   IF PG_DEBUG in ('Y', 'C') THEN
109     arp_standard.debug('Calling OraPmtReq');
110     arp_standard.debug('l_pmtreqtrxn_rec.pmtmode: '||
111                         l_pmtreqtrxn_rec.pmtmode);
112     arp_standard.debug('l_pmtreqtrxn_rec.auth_type: '||
113                         l_pmtreqtrxn_rec.auth_type);
114 
115     ---Bug 3672953 Pass Unique reference for Auth
116     arp_standard.debug('l_pmtreqtrxn_rec.TrxnRef: '||
117                         l_pmtreqtrxn_rec.TrxnRef);
118 
119     arp_standard.debug('l_tangible_rec.tangible_id: '||
120                         p_authorize_input_rec.payment_server_order_num);
121     arp_standard.debug('l_tangible_rec.tangible_amount: ' ||
122                         to_char(l_tangible_rec.tangible_amount) );
123     arp_standard.debug('l_tangible_rec.currency_code: ' ||
124                         l_tangible_rec.currency_code );
125     arp_standard.debug('l_tangible_rec.refinfo: ' || l_tangible_rec.refinfo);
126   /* Bug-4606039
127     arp_standard.debug('l_cc_instr_rec.cc_num: ' ||l_cc_instr_rec.cc_num );
128     arp_standard.debug('l_cc_instr_rec.cc_ExpDate: ' ||
129                         to_char(l_cc_instr_rec.cc_ExpDate));
130     arp_standard.debug('l_cc_instr_rec.cc_HolderName: ' ||
131                         l_cc_instr_rec.cc_HolderName ); */
132     arp_standard.debug('l_payee_rec.payee_id: ' ||l_payee_rec.payee_id );
133   /* Bug-4606039
134     arp_standard.debug('l_customer_rec.payer_name: ' ||
135                         l_customer_rec.payer_name); */
136   END IF;
137 
138   IBY_Payment_Adapter_pub.OraPmtReq(
139      p_api_version 	=> 1.0,
140      p_init_msg_list 	=> FND_API.G_TRUE,
141      p_commit       	=> FND_API.G_FALSE,
142      p_validation_level   => FND_API.G_VALID_LEVEL_FULL,
143      p_ecapp_id           => 222,  -- AR product id
144      x_return_status      => l_return_status,
145      x_msg_count          => l_msg_count,
146      x_msg_data           => l_msg_data,
147      p_payee_rec          => l_payee_rec,
148      p_payer_rec          => l_customer_rec,
149      p_pmtinstr_rec       => l_pmtinstr_rec,
150      p_tangible_rec       => l_tangible_rec,
151      p_pmtreqtrxn_rec     => l_pmtreqtrxn_rec,
152      p_riskinfo_rec       => l_riskinfo_rec,
153      x_reqresp_rec        => l_reqresp_rec);
154 
155 
156     --Asssign the values to OUT Parameters
157     x_return_status       := l_return_status;
158     x_msg_count           := l_msg_count;
159     x_msg_data            := l_msg_data;
160     x_authorize_output_rec.x_reqresp_rec := l_reqresp_rec;
161 
162     ---previously p_response_error_code was an OUT parameter
163     x_authorize_output_rec.x_reqresp_rec.response.errcode :=
164                     l_reqresp_rec.response.errcode;
165 
166 
167     IF PG_DEBUG in ('Y', 'C') THEN
168        arp_standard.debug(  '-------------------------------------');
169        arp_standard.debug(  'x_return_status: ' || x_return_status);
170        arp_standard.debug(  'l_reqresp_rec.response.errcode: ' ||
171                              l_reqresp_rec.response.errcode);
172        arp_standard.debug(  'l_reqresp_rec.response.errmessage: ' ||
173                              l_reqresp_rec.response.errmessage);
174        arp_standard.debug(  'l_reqresp_rec.errorlocation: ' ||
175                              l_reqresp_rec.errorlocation);
176        arp_standard.debug(  'l_reqresp_rec.beperrcode: ' ||
177                              l_reqresp_rec.beperrcode);
178        arp_standard.debug(  'l_reqresp_rec.beperrmessage: ' ||
179                              l_reqresp_rec.beperrmessage);
180        arp_standard.debug(  'NVL(l_reqresp_rec.response.status,0): ' ||
181                           to_char(NVL(l_reqresp_rec.response.status,0)));
182        arp_standard.debug(  'Authcode: ' || l_reqresp_rec.authcode);
183        arp_standard.debug(  'Trxn ID: ' || l_reqresp_rec.Trxn_ID);
184        arp_standard.debug(  '-------------------------------------');
185     END IF;
186 
187    IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
188           FND_MESSAGE.set_name('AR', 'AR_CC_AUTH_FAILED');
189           FND_MSG_PUB.Add;
190           x_return_status := l_return_status;
191           RETURN;
192    END IF;
193 
194 
195   IF PG_DEBUG in ('Y', 'C') THEN
196     arp_standard.debug('AR_PMT_PROCESS_WRAPPER.Authorize_Payment(-)');
197   END IF;
198 
199 
200 END Authorize_payment;
201 
202  /*========================================================================
203  | PUBLIC PROCEDURE Capture_Payment
204  |
205  | DESCRIPTION
206  |      This procedure makes a  call to iPayment's API for Capture
207  |      IBY_Payment_Adapter_pub.OraPmtCapture
208  |
209  |
213  |      p_receipt_info_rec IN
210  | PSEUDO CODE/LOGIC
211  |
212  | PARAMETERS
214  |         This parameter is for capturing certain receipt related information
215  |         that could be useful in customizations.
216  |
217  |      p_capture_input_rec      IN
218  |         This parameter is for capturing all the information that is required
219  |         to send to iPayment for Capture.
220  |
221  |      x_capture_output_rec     OUT
222  |        This is the output record and comprises of the output record
223  |        returned by iPayment API IBY_Payment_Adapter_pub.CaptureResp_rec_type
224  |
225  | KNOWN ISSUES
226  |
227  |
228  |
229  | NOTES
230  |
231  |
232  |
233  | MODIFICATION HISTORY
234  | Date                  Author            Description of Changes
235  | 15-MAR-2004           Jyoti Pandey      Created
236  |
237  *=======================================================================*/
238  PROCEDURE Capture_payment (
239   p_receipt_info_rec IN receipt_info_rec,
240   p_capture_input_rec        IN capture_input_rec,
241   x_capture_output_rec       OUT NOCOPY capture_output_rec,
242   x_return_status            OUT NOCOPY VARCHAR2,
243   x_msg_count                OUT NOCOPY NUMBER,
244   x_msg_data                 OUT NOCOPY VARCHAR2) IS
245 
246    /*-----------------------------------------------------------------------+
247    | Cursor Declarations                                                    |
248    +-----------------------------------------------------------------------*/
249 
250    CURSOR iby_trxn_id_cur(l_payment_server_order_num IN VARCHAR2) IS
251    SELECT DISTINCT transactionid
252    FROM iby_trans_all_v
253    WHERE tangibleid = l_payment_server_order_num;
254 
255   /*-----------------------------------------------------------------------+
256    | Local Variable Declarations and initializations                       |
257    +-----------------------------------------------------------------------*/
258 
259   l_capturetrxn_rec     IBY_Payment_Adapter_pub.CaptureTrxn_rec_type;
260   l_capresp_rec         IBY_Payment_Adapter_pub.CaptureResp_rec_type;
261   iby_trxn_id		NUMBER;
262 
263   l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
264   l_msg_count NUMBER;
265   l_msg_data  VARCHAR2(2000);
266 
267 BEGIN
268 
269   IF PG_DEBUG in ('Y', 'C') THEN
270     arp_standard.debug('AR_PMT_PROCESS_WRAPPER.Capture_Payment(+)');
271   END IF;
272 
273   --get the trx_id
274    IF p_capture_input_rec.payment_server_order_num IS NOT NULL THEN
275       OPEN iby_trxn_id_cur(p_capture_input_rec.payment_server_order_num);
276        FETCH iby_trxn_id_cur INTO iby_trxn_id;
277           IF iby_trxn_id_cur%NOTFOUND then
278               IF PG_DEBUG in ('Y', 'C') THEN
279                  arp_util.debug('Process_Credit_Card: ' ||
280                                 'PSON passed is Invalid..Need to re-authorize');
281               END IF;
282               l_return_status := FND_API.G_RET_STS_ERROR;
283               RETURN;
284 
285           END IF;
286           CLOSE iby_trxn_id_cur;
287 
288       IF iby_trxn_id is not null then
289 
290          l_capturetrxn_rec.Trxn_ID := iby_trxn_id;
291          l_capturetrxn_rec.currency := p_capture_input_rec.currency_code;
292          l_capturetrxn_rec.price :=    p_capture_input_rec.receipt_amount;
293          l_capturetrxn_rec.TrxnRef :=  p_capture_input_rec.TrxnRef;
294          l_capturetrxn_rec.PmtMode := 'ONLINE';
295 
296          IF PG_DEBUG in ('Y', 'C') THEN
297             arp_standard.debug('Calling OraPmtReq');
298             arp_standard.debug('l_capturetrxn_rec.Trxn_ID: '||
299                                 l_capturetrxn_rec.Trxn_ID);
300             arp_standard.debug('l_capturetrxn_rec.currency: '||
301                                 l_capturetrxn_rec.currency);
302             arp_standard.debug('l_capturetrxn_rec.price: ' ||
303                                 to_char(l_capturetrxn_rec.price) );
304             arp_standard.debug('l_capturetrxn_rec.TrxnRef: ' ||
305                                 l_capturetrxn_rec.TrxnRef );
306             arp_standard.debug('l_capturetrxn_rec.PmtMode: ' ||
307                                 l_capturetrxn_rec.PmtMode );
308          END IF;
309 
310          IBY_Payment_Adapter_pub.OraPmtCapture(
311            p_api_version        => 1.0,
312            p_init_msg_list      => FND_API.G_FALSE,
313            p_commit             => FND_API.G_FALSE,
314    	       p_validation_level   => FND_API.G_VALID_LEVEL_FULL,
315 	       p_ecapp_id           => 222,  -- AR product id
316            x_return_status      => l_return_status,
317            x_msg_count          => l_msg_count,
318            x_msg_data           => l_msg_data,
319            p_capturetrxn_rec    => l_capturetrxn_rec,
320            x_capresp_rec        => l_capresp_rec);
321 
322           --Asssign the values to OUT Parameters
323           x_return_status       := l_return_status;
324           x_msg_count           := l_msg_count;
325           x_msg_data            := l_msg_data;
326           x_capture_output_rec.x_capresp_rec := l_capresp_rec;
327 
328 	    IF PG_DEBUG in ('Y', 'C') THEN
329 	        arp_standard.debug(  '-------------------------------------');
330             arp_standard.debug(  'x_return_status: ' || x_return_status);
331             arp_standard.debug(  'l_capresp_rec.response.errcode: ' || l_capresp_rec.response.errcode);
332             arp_standard.debug(  'l_capresp_rec.response.errmessage: ' || l_capresp_rec.response.errmessage);
333             arp_standard.debug(  'l_capresp_rec.errorlocation: ' || l_capresp_rec.errorlocation);
334             arp_standard.debug(  'l_capresp_rec.beperrcode: ' || l_capresp_rec.beperrcode);
335             arp_standard.debug(  'l_capresp_rec.beperrmessage: ' || l_capresp_rec.beperrmessage);
336             arp_standard.debug(  'NVL(l_capresp_rec.response.status,0): ' || to_char(NVL(l_capresp_rec.response.status,0)));
337             arp_standard.debug(  'PmtInstr_Type: ' || l_capresp_rec.PmtInstr_Type);
338             arp_standard.debug(  'Trxn ID: ' || l_capresp_rec.Trxn_ID);
339             arp_standard.debug(  '-------------------------------------');
340 
341 	    END IF;
342 
343 
344         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
345           FND_MESSAGE.set_name('AR', 'AR_CC_CAPTURE_FAILED');
346           FND_MSG_PUB.Add;
347           x_return_status := l_return_status;
348           RETURN;
349         END IF;
350 
351       END IF;
352 
353   END IF; --pson not null
354 
355 
356   IF PG_DEBUG in ('Y', 'C') THEN
357     arp_standard.debug('AR_PMT_PROCESS_WRAPPER.Capture_Payment(-)');
358   END IF;
359 end;
360 
361 end AR_PMT_PROCESS_WRAPPER;