KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > model > PaymentProcessor


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.model;
15
16 import java.sql.*;
17 import java.math.*;
18 import java.io.*;
19 import java.util.*;
20
21 import org.compiere.util.*;
22
23 /**
24  * Payment Processor Abstract Class
25  *
26  * @author Jorg Janke
27  * @version $Id: PaymentProcessor.java,v 1.11 2003/10/04 03:51:50 jjanke Exp $
28  */

29 public abstract class PaymentProcessor
30 {
31     /**
32      * Public Constructor
33      */

34     public PaymentProcessor()
35     {
36     } // PaymentProcessor
37

38     /** Logger */
39     protected Logger log = Logger.getCLogger (getClass());
40     static private Logger s_log = Logger.getCLogger (PaymentProcessor.class);
41
42     /**
43      * Factory
44      * @param mpp payment processor model
45      * @param mp payment model
46      * @return initialized PaymentProcessor or null
47      */

48     public static PaymentProcessor create (MPaymentProcessor mpp, MPayment mp)
49     {
50         s_log.info("create for " + mpp);
51         String JavaDoc className = mpp.getPayProcessorClass();
52         if (className == null || className.length() == 0)
53         {
54             s_log.error("create - no PaymentProcessor class name in " + mpp);
55             return null;
56         }
57         //
58
PaymentProcessor myProcessor = null;
59         try
60         {
61             Class JavaDoc ppClass = Class.forName(className);
62             if (ppClass != null)
63                 myProcessor = (PaymentProcessor)ppClass.newInstance();
64         }
65         catch (Error JavaDoc e1) // NoClassDefFound
66
{
67             s_log.error("create " + className + " - Error=" + e1.getMessage());
68             return null;
69         }
70         catch (Exception JavaDoc e2)
71         {
72             s_log.error("create " + className, e2);
73             return null;
74         }
75         if (myProcessor == null)
76         {
77             s_log.error("create - no class");
78             return null;
79         }
80
81         // Initialize
82
myProcessor.p_mpp = mpp;
83         myProcessor.p_mp = mp;
84         //
85
return myProcessor;
86     } // create
87

88     /*************************************************************************/
89
90     protected MPaymentProcessor p_mpp = null;
91     protected MPayment p_mp = null;
92     //
93
private int m_timeout = 30;
94
95     /*************************************************************************/
96
97     /**
98      * Process CreditCard (no date check)
99      * @return true if processed successfully
100      * @throws IllegalArgumentException
101      */

102     public abstract boolean processCC () throws IllegalArgumentException JavaDoc;
103
104     /**
105      * Payment is procesed successfully
106      * @return true if OK
107      */

108     public abstract boolean isProcessedOK();
109
110     /*************************************************************************/
111
112     /**
113      * Set Timeout
114      * @param newTimeout timeout
115      */

116     public void setTimeout(int newTimeout)
117     {
118         m_timeout = newTimeout;
119     }
120     public int getTimeout()
121     {
122         return m_timeout;
123     }
124
125 } // PaymentProcessor
126
Popular Tags