Merge lp:~serpent-consulting-services/openerp-usa/cim-SerpentCS into lp:openerp-usa/6.1.x

Proposed by Serpent Consulting Services
Status: Merged
Merged at revision: 77
Proposed branch: lp:~serpent-consulting-services/openerp-usa/cim-SerpentCS
Merge into: lp:openerp-usa/6.1.x
Diff against target: 3178 lines (+3064/-0)
22 files modified
account_payment_cim_authdotnet/__init__.py (+29/-0)
account_payment_cim_authdotnet/__openerp__.py (+48/-0)
account_payment_cim_authdotnet/account_voucher.py (+596/-0)
account_payment_cim_authdotnet/account_voucher_view.xml (+31/-0)
account_payment_cim_authdotnet/cim_transaction.py (+133/-0)
account_payment_cim_authdotnet/cim_transaction_view.xml (+89/-0)
account_payment_cim_authdotnet/company_view.xml (+32/-0)
account_payment_cim_authdotnet/partner.py (+218/-0)
account_payment_cim_authdotnet/partner_view.xml (+36/-0)
account_payment_cim_authdotnet/res_company.py (+30/-0)
account_payment_cim_authdotnet/test.py (+202/-0)
account_payment_cim_authdotnet/wizard/__init__.py (+28/-0)
account_payment_cim_authdotnet/wizard/create_payment_profile.py (+328/-0)
account_payment_cim_authdotnet/wizard/create_payment_profile_view.xml (+42/-0)
account_payment_cim_authdotnet/wizard/delete_payment_profile.py (+190/-0)
account_payment_cim_authdotnet/wizard/delete_payment_profile_view.xml (+33/-0)
account_payment_cim_authdotnet/wizard/edit_payment_profile.py (+422/-0)
account_payment_cim_authdotnet/wizard/edit_payment_profile_view.xml (+39/-0)
account_payment_cim_authdotnet/wizard/make_transaction.py (+399/-0)
account_payment_cim_authdotnet/wizard/make_transaction_view.xml (+43/-0)
account_payment_cim_authdotnet/wizard/xml2dic.py (+48/-0)
account_payment_cim_authdotnet/xml2dic.py (+48/-0)
To merge this branch: bzr merge lp:~serpent-consulting-services/openerp-usa/cim-SerpentCS
Reviewer Review Type Date Requested Status
npg Pending
Review via email: mp+121208@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_payment_cim_authdotnet'
2=== added file 'account_payment_cim_authdotnet/Change Log.txt'
3=== added file 'account_payment_cim_authdotnet/__init__.py'
4--- account_payment_cim_authdotnet/__init__.py 1970-01-01 00:00:00 +0000
5+++ account_payment_cim_authdotnet/__init__.py 2012-08-24 15:52:25 +0000
6@@ -0,0 +1,29 @@
7+# -*- coding: utf-8 -*-
8+##############################################################################
9+#
10+# OpenERP, Open Source Management Solution
11+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
12+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
13+#
14+# This program is free software: you can redistribute it and/or modify
15+# it under the terms of the GNU General Public License as published by
16+# the Free Software Foundation, either version 3 of the License, or
17+# (at your option) any later version.
18+#
19+# This program is distributed in the hope that it will be useful,
20+# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+# GNU General Public License for more details.
23+#
24+# You should have received a copy of the GNU General Public License
25+# along with this program. If not, see <http://www.gnu.org/licenses/>
26+#
27+##############################################################################
28+
29+import res_company
30+import partner
31+import account_voucher
32+import cim_transaction
33+import wizard
34+
35+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
36
37=== added file 'account_payment_cim_authdotnet/__openerp__.py'
38--- account_payment_cim_authdotnet/__openerp__.py 1970-01-01 00:00:00 +0000
39+++ account_payment_cim_authdotnet/__openerp__.py 2012-08-24 15:52:25 +0000
40@@ -0,0 +1,48 @@
41+# -*- coding: utf-8 -*-
42+##############################################################################
43+#
44+# OpenERP, Open Source Management Solution
45+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
46+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
47+#
48+# This program is free software: you can redistribute it and/or modify
49+# it under the terms of the GNU General Public License as published by
50+# the Free Software Foundation, either version 3 of the License, or
51+# (at your option) any later version.
52+#
53+# This program is distributed in the hope that it will be useful,
54+# but WITHOUT ANY WARRANTY; without even the implied warranty of
55+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+# GNU General Public License for more details.
57+#
58+# You should have received a copy of the GNU General Public License
59+# along with this program. If not, see <http://www.gnu.org/licenses/>
60+#
61+##############################################################################
62+
63+{
64+ 'name': 'CIM Transaction',
65+ 'version': '1.1',
66+ 'category': 'Generic Modules/Others',
67+ 'description': """
68+ CIM Transactions using authorise.net
69+ """,
70+ 'author': 'NovaPoint Group LLC',
71+ 'website': ' http://www.novapointgroup.com',
72+ 'depends': ['account_payment_ccapi_authdotnet'],
73+ 'init_xml': [],
74+ 'update_xml': ['wizard/edit_payment_profile_view.xml',
75+ 'wizard/make_transaction_view.xml',
76+ 'wizard/delete_payment_profile_view.xml',
77+ 'wizard/create_payment_profile_view.xml',
78+ 'cim_transaction_view.xml',
79+ 'partner_view.xml',
80+ 'company_view.xml',
81+ 'account_voucher_view.xml'
82+ ],
83+ 'demo_xml': [
84+ ],
85+ 'installable': True,
86+ 'auto_install': False,
87+}
88+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
89
90=== added file 'account_payment_cim_authdotnet/account_voucher.py'
91--- account_payment_cim_authdotnet/account_voucher.py 1970-01-01 00:00:00 +0000
92+++ account_payment_cim_authdotnet/account_voucher.py 2012-08-24 15:52:25 +0000
93@@ -0,0 +1,596 @@
94+# -*- coding: utf-8 -*-
95+##############################################################################
96+#
97+# OpenERP, Open Source Management Solution
98+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
99+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
100+#
101+# This program is free software: you can redistribute it and/or modify
102+# it under the terms of the GNU General Public License as published by
103+# the Free Software Foundation, either version 3 of the License, or
104+# (at your option) any later version.
105+#
106+# This program is distributed in the hope that it will be useful,
107+# but WITHOUT ANY WARRANTY; without even the implied warranty of
108+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
109+# GNU General Public License for more details.
110+#
111+# You should have received a copy of the GNU General Public License
112+# along with this program. If not, see <http://www.gnu.org/licenses/>
113+#
114+##############################################################################
115+from osv import osv, fields
116+import httplib
117+from xml.dom.minidom import Document
118+import xml2dic
119+#from time import time
120+import time
121+from tools.translate import _
122+
123+class AuthnetAIMError(Exception):
124+ '''
125+ Class to display exceptions
126+ '''
127+ def __init__(self, value):
128+ self.parameter = value
129+ def __str__(self):
130+ return str(self.parameter)
131+ def setParameter(self, parameters={}, key=None, value=None):
132+
133+ if key != None and value != None and str(key).strip() != '' and str(value).strip() != '':
134+ parameters[key] = str(value).strip()
135+ else:
136+ raise AuthnetAIMError('Incorrect parameters passed to setParameter(): {0}:{1}'.format(key, value))
137+ return parameters
138+
139+class auth_net_cc_api(osv.osv):
140+ _inherit = "auth.net.cc.api"
141+ '''
142+ Class to do credit card transaction
143+ '''
144+ def _setparameter(self, dic, key, value):
145+ ''' Used to input parameters to corresponding dictionary'''
146+ if key == None or value == None :
147+ return
148+ if type(value) == type(''):
149+ dic[key] = value.strip()
150+ else:
151+ dic[key] = value
152+
153+ def createCustomerProfileTransactionRequest(self, dic):
154+
155+ ''' Creates the xml for TransactionRequest and returns the transaction id '''
156+
157+ profile_dictionary = dic
158+ KEYS = dic.keys()
159+ doc1 = Document()
160+ url_path = dic.get('url_extension', False)
161+ url = dic.get('url', False)
162+ xsd = dic.get('xsd', False)
163+ trans_type_list = ['AuthOnly', 'AuthCapture', 'Refund']
164+
165+ createCustomerProfileTransactionRequest = doc1.createElement("createCustomerProfileTransactionRequest")
166+ createCustomerProfileTransactionRequest.setAttribute("xmlns", xsd)
167+ doc1.appendChild(createCustomerProfileTransactionRequest)
168+
169+ merchantAuthentication = doc1.createElement("merchantAuthentication")
170+ createCustomerProfileTransactionRequest.appendChild(merchantAuthentication)
171+
172+ name = doc1.createElement("name")
173+ merchantAuthentication.appendChild(name)
174+
175+ transactionKey = doc1.createElement("transactionKey")
176+ merchantAuthentication.appendChild(transactionKey)
177+
178+ ##Create the Request for creating the customer profile
179+ if 'api_login_id' in KEYS and 'transaction_key' in KEYS:
180+
181+ ptext1 = doc1.createTextNode(self._clean_string(dic['api_login_id']))
182+ name.appendChild(ptext1)
183+
184+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['transaction_key'])))
185+ transactionKey.appendChild(ptext)
186+
187+ transaction = doc1.createElement("transaction")
188+ createCustomerProfileTransactionRequest.appendChild(transaction)
189+ if 'trans_type' in KEYS :
190+ if profile_dictionary.get('trans_type', False) in trans_type_list:
191+ transaction_type_tagname = 'profileTrans' + profile_dictionary.get('trans_type', False)
192+ transaction_type = doc1.createElement(transaction_type_tagname)
193+ transaction.appendChild(transaction_type)
194+
195+ if 'amount' in KEYS :
196+ amount = doc1.createElement('amount')
197+ transaction_type.appendChild(amount)
198+ ptext = doc1.createTextNode(self._clean_string(dic['amount']))
199+ amount.appendChild(ptext)
200+
201+ if 'tax_amount' in KEYS :
202+ tax = doc1.createElement('tax')
203+ transaction_type.appendChild(tax)
204+
205+ tax_amount = doc1.createElement('amount')
206+ tax.appendChild(tax_amount)
207+ ptext = doc1.createTextNode(self._clean_string(dic['tax_amount']))
208+ tax_amount.appendChild(ptext)
209+
210+ tax_name = doc1.createElement('name')
211+ tax.appendChild(tax_name)
212+ ptext = doc1.createTextNode(self._clean_string(dic['tax_name']))
213+ tax_name.appendChild(ptext)
214+
215+ tax_description = doc1.createElement('description')
216+ tax.appendChild(tax_description)
217+ ptext = doc1.createTextNode(self._clean_string(dic['tax_description']))
218+ tax_description.appendChild(ptext)
219+
220+ if 'shipping_amount' in KEYS :
221+ shipping = doc1.createElement('shipping')
222+ transaction_type.appendChild(shipping)
223+
224+ shipping_amount = doc1.createElement('amount')
225+ tax.appendChild(shipping_amount)
226+ ptext = doc1.createTextNode(self._clean_string(dic['shipping_amount']))
227+ shipping_amount.appendChild(ptext)
228+
229+ shipping_name = doc1.createElement('name')
230+ tax.appendChild(shipping_name)
231+ ptext = doc1.createTextNode(self._clean_string(dic['shipping_name']))
232+ shipping_name.appendChild(ptext)
233+
234+ shipping_description = doc1.createElement('description')
235+ tax.appendChild(shipping_description)
236+ ptext = doc1.createTextNode(self._clean_string(dic['shipping_description']))
237+ shipping_description.appendChild(ptext)
238+
239+ if 'duty_amount' in KEYS :
240+ duty = doc1.createElement('duty')
241+ transaction_type.appendChild(duty)
242+
243+ duty_amount = doc1.createElement('amount')
244+ tax.appendChild(duty_amount)
245+ ptext = doc1.createTextNode(self._clean_string(dic['duty_amount']))
246+ duty_amount.appendChild(ptext)
247+
248+ duty_name = doc1.createElement('name')
249+ tax.appendChild(duty_name)
250+ ptext = doc1.createTextNode(self._clean_string(dic['duty_name']))
251+ duty_name.appendChild(ptext)
252+
253+ duty_description = doc1.createElement('description')
254+ tax.appendChild(duty_description)
255+ ptext = doc1.createTextNode(self._clean_string(dic['duty_description']))
256+ duty_description.appendChild(ptext)
257+
258+ if 'items'in KEYS and len(profile_dictionary.get('items')) > 0:
259+ for i in range(0, len(profile_dictionary.get('items'))):
260+ lineItems = doc1.createElement('lineItems')
261+ transaction_type.appendChild(lineItems)
262+
263+ if 'itemId' in profile_dictionary['items'][i].keys():
264+ itemId = doc1.createElement('itemId')
265+ lineItems.appendChild(itemId)
266+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['itemId']))
267+ itemId.appendChild(ptext)
268+
269+ if 'name' in profile_dictionary['items'][i].keys():
270+ name = doc1.createElement('name')
271+ lineItems.appendChild(name)
272+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['name']))
273+ name.appendChild(ptext)
274+
275+ if 'description' in profile_dictionary['items'][i].keys():
276+ description = doc1.createElement('description')
277+ lineItems.appendChild(description)
278+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['description']))
279+ description.appendChild(ptext)
280+
281+ if 'quantity' in profile_dictionary['items'][i].keys():
282+ quantity = doc1.createElement('quantity')
283+ lineItems.appendChild(quantity)
284+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['quantity']))
285+ quantity.appendChild(ptext)
286+
287+ if 'unitPrice' in profile_dictionary['items'][i].keys():
288+ unitPrice = doc1.createElement('unitPrice')
289+ lineItems.appendChild(unitPrice)
290+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['unitPrice']))
291+ unitPrice.appendChild(ptext)
292+
293+ if 'taxable' in profile_dictionary['items'][i].keys():
294+ taxable = doc1.createElement('taxable')
295+ lineItems.appendChild(taxable)
296+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['taxable']))
297+ taxable.appendChild(ptext)
298+
299+ if 'customerProfileId' in KEYS:
300+ customerProfileId = doc1.createElement('customerProfileId')
301+ transaction_type.appendChild(customerProfileId)
302+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerProfileId']))
303+ customerProfileId.appendChild(ptext)
304+
305+ if 'customerPaymentProfileId' in KEYS:
306+ customerProfileId = doc1.createElement('customerPaymentProfileId')
307+ transaction_type.appendChild(customerProfileId)
308+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerPaymentProfileId']))
309+ customerProfileId.appendChild(ptext)
310+
311+ if 'customerShippingAddressId' in KEYS:
312+ customerShippingAddressId = doc1.createElement('customerShippingAddressId')
313+ transaction_type.appendChild(customerShippingAddressId)
314+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerShippingAddressId']))
315+ customerShippingAddressId.appendChild(ptext)
316+
317+ if transaction_type_tagname == 'profileTransRefund':
318+ if 'transId' in KEYS:
319+ transId = doc1.createElement('transId')
320+ transaction_type.appendChild(transId)
321+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['transId']))
322+ transId.appendChild(ptext)
323+ if 'creditCardNumberMasked' in KEYS:
324+ creditCardNumberMasked = doc1.createElement('creditCardNumberMasked')
325+ transaction_type.appendChild(creditCardNumberMasked)
326+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['creditCardNumberMasked']))
327+ creditCardNumberMasked.appendChild(ptext)
328+
329+ Request_string = xml = doc1.toxml(encoding="utf-8")
330+ create_transaction_response_xml = self.request_to_server(Request_string, url, url_path)
331+ create_transaction_response_dictionary = xml2dic.main(create_transaction_response_xml)
332+ parent_resultCode = self.search_dic(create_transaction_response_dictionary, 'resultCode')
333+ if parent_resultCode:
334+ if parent_resultCode['resultCode'] == 'Ok':
335+ parent_directResponse = self.search_dic(create_transaction_response_dictionary, 'directResponse')
336+ li = parent_directResponse['directResponse'].split(',')
337+ li[6]##Transaction ID
338+ li[4]##Authorization code
339+ return li
340+ ret = {}
341+ Error_Code_dic = self.search_dic(create_transaction_response_dictionary, 'code')
342+ if Error_Code_dic.get('code'):
343+ ret['Error_Code'] = Error_Code_dic['code']
344+ Error_message_dic = self.search_dic(create_transaction_response_dictionary, 'text')
345+ if Error_message_dic.get('text'):
346+ ret['Error_Message'] = Error_message_dic['text']
347+ return ret
348+
349+ def getCustomerPaymentProfileRequest(self, dic):
350+ profile_dictionary = dic
351+ KEYS = dic.keys()
352+ doc1 = Document()
353+ url_path = dic.get('url_extension')
354+ url = dic.get('url')
355+ xsd = dic.get('xsd')
356+
357+ getCustomerPaymentProfileRequest = doc1.createElement("getCustomerPaymentProfileRequest")
358+ getCustomerPaymentProfileRequest.setAttribute("xmlns", "AnetApi/xml/v1/schema/AnetApiSchema.xsd")
359+ doc1.appendChild(getCustomerPaymentProfileRequest)
360+
361+ merchantAuthentication = doc1.createElement("merchantAuthentication")
362+ getCustomerPaymentProfileRequest.appendChild(merchantAuthentication)
363+
364+ name = doc1.createElement("name")
365+ merchantAuthentication.appendChild(name)
366+
367+ transactionKey = doc1.createElement("transactionKey")
368+ merchantAuthentication.appendChild(transactionKey)
369+ if 'api_login_id' in KEYS and 'transaction_key' in KEYS:
370+ ptext1 = doc1.createTextNode(self._clean_string(dic['api_login_id']))
371+ name.appendChild(ptext1)
372+
373+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['transaction_key'])))
374+ transactionKey.appendChild(ptext)
375+
376+ if 'customerProfileId' in KEYS:
377+ customerProfileId = doc1.createElement("customerProfileId")
378+ getCustomerPaymentProfileRequest.appendChild(customerProfileId)
379+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerProfileId']))
380+ customerProfileId.appendChild(ptext)
381+
382+ if 'customerPaymentProfileId' in KEYS:
383+ customerPaymentProfileId = doc1.createElement("customerPaymentProfileId")
384+ getCustomerPaymentProfileRequest.appendChild(customerPaymentProfileId)
385+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerPaymentProfileId']))
386+ customerPaymentProfileId.appendChild(ptext)
387+
388+ Request_string = xml = doc1.toxml(encoding="utf-8")
389+
390+ get_profile_response_xml = self.request_to_server(Request_string, url, url_path)
391+ get_profile_response_dictionary = xml2dic.main(get_profile_response_xml)
392+
393+ parent_resultCode = self.search_dic(get_profile_response_dictionary, 'resultCode')
394+
395+ if parent_resultCode:
396+ if parent_resultCode['resultCode'] == 'Ok':
397+ parent_directResponse = self.search_dic(get_profile_response_dictionary, 'cardNumber')
398+ cardNumber = parent_directResponse['cardNumber']
399+ return cardNumber
400+
401+ def validate_sales_reciept(self, cr, uid, ids, context={}):
402+ vouchr_obj = self.pool.get('account.voucher')
403+ if type(ids) == type([]):
404+ voucher_objs = vouchr_obj.browse(cr, uid, ids, context=context)
405+ else:
406+ voucher_objs = vouchr_obj.browse(cr, uid, [ids], context=context)
407+ for voucher_obj in voucher_objs:
408+ rel_sale_order_id = voucher_obj.rel_sale_order_id and voucher_obj.rel_sale_order_id.id
409+ if rel_sale_order_id:
410+ sale_reciepts_ids = vouchr_obj.search(cr, uid, [('type', '=', 'sale'), ('rel_sale_order_id', '=', rel_sale_order_id), ('state', 'in', ['draft'])])
411+
412+ if sale_reciepts_ids:
413+ vouchr_obj.action_move_line_create(cr, uid, sale_reciepts_ids, context=context)
414+ else:
415+ sale_reciepts_id = self.pool.get('sale.order').create_sales_reciept(cr, uid, [rel_sale_order_id], context=context)
416+ vouchr_obj.action_move_line_create(cr, uid, [sale_reciepts_id], context=context)
417+ return True
418+
419+ def _clean_string(self, text):
420+ lis = ['\t', '\n']
421+ if type(text) != type(''):
422+ text = str(text)
423+ for t in lis:
424+ text = text.replace(t, '')
425+ return text
426+
427+ def request_to_server(self, Request_string, url, url_path):
428+ ''' Sends a POST request to url and returns the response from the server'''
429+
430+ conn = httplib.HTTPSConnection(url)
431+ conn.putrequest('POST', url_path)
432+ conn.putheader('content-type', 'text/xml')
433+ conn.putheader('content-length', len(Request_string))
434+ conn.endheaders()
435+ conn.send(Request_string)
436+ response = conn.getresponse()
437+ get_CustomerProfile_response_xml = response.read()
438+ return get_CustomerProfile_response_xml
439+
440+ def search_dic(self, dic, key):
441+ ''' Returns the parent dictionary containing key None on Faliure'''
442+ if key in dic.keys():
443+ return dic
444+ for k in dic.keys():
445+ if type(dic[k]) == type([]):
446+ for i in dic[k]:
447+ if type(i) == type({}):
448+ ret = self.search_dic(i, key)
449+ if ret and key in ret.keys():
450+ return ret
451+ return None
452+
453+ def do_this_transaction(self, cr, uid, ids, refund=False, context=None):
454+ '''
455+ Do credit card transaction
456+ '''
457+ voucher_obj = self.pool.get('account.voucher')
458+ vou_line_obj = self.pool.get('account.voucher.line')
459+ if type([]) == type(ids):
460+ acc_voucher_obj = voucher_obj.browse(cr, uid, ids[0], context={'cc_no':'no_mask'})
461+ else:
462+ acc_voucher_obj = voucher_obj.browse(cr, uid, ids, context={'cc_no':'no_mask'})
463+ if not acc_voucher_obj.payment_profile_id:
464+ raise osv.except_osv(_('No Payment Profile!'), _(" Select Payment Profile."))
465+ ret = False
466+ company = acc_voucher_obj.partner_id and acc_voucher_obj.partner_id.company_id
467+ customer = acc_voucher_obj.partner_id
468+ user = self.pool.get('res.users').browse(cr, uid, uid)
469+ amount = acc_voucher_obj.amount
470+ if amount <= 0.00:
471+ raise osv.except_osv(_('No Amount!'), _(" Enter a Positive Amount"))
472+ if refund:
473+ trans_type = 'Refund'
474+ if acc_voucher_obj.cc_trans_id:
475+ trans_id = acc_voucher_obj.cc_trans_id
476+ if not acc_voucher_obj.cc_trans_id:
477+ raise osv.except_osv(_('No Transaction ID!'), _(" Unable to find transaction id for refund."))
478+ if not acc_voucher_obj.journal_id.cc_allow_refunds:
479+ raise osv.except_osv(_('Unable to do Refund!'), _("Please check \"Allow Credit Card Refunds\" on journal to do refund."))
480+ elif acc_voucher_obj.cc_p_authorize:
481+ trans_type = 'AuthOnly'
482+ elif acc_voucher_obj.cc_charge:
483+ trans_type = 'AuthCapture'
484+ if company and company.auth_config_id:
485+ Login_id = company.auth_config_id.login_id
486+ Trans_key = company.auth_config_id.transaction_key
487+ url_extension = company.auth_config_id.url_extension
488+ xsd = company.auth_config_id.xsd_link
489+ if company.auth_config_id.test_mode == True:
490+ url = company.auth_config_id.url_test
491+ else:
492+ url = company.auth_config_id.url
493+ if acc_voucher_obj.payment_profile_id:
494+ customerPaymentProfileId = acc_voucher_obj.payment_profile_id.name
495+ Customer_Profile_ID = acc_voucher_obj.payment_profile_id.cust_profile_id.name
496+
497+ Param_Dic = {}
498+ if Trans_key and Login_id:
499+ self._setparameter(Param_Dic, 'api_login_id', Login_id)
500+ self._setparameter(Param_Dic, 'transaction_key', Trans_key)
501+
502+ if url:
503+ self._setparameter(Param_Dic, 'url', url)
504+ self._setparameter(Param_Dic, 'url_extension', url_extension)
505+ if xsd:
506+ self._setparameter(Param_Dic, 'xsd', xsd)
507+
508+ self._setparameter(Param_Dic, 'customerProfileId', Customer_Profile_ID)
509+ self._setparameter(Param_Dic, 'customerPaymentProfileId', customerPaymentProfileId)
510+ self._setparameter(Param_Dic, 'amount', amount)
511+ self._setparameter(Param_Dic, 'trans_type', trans_type)
512+
513+ if trans_type in ['Refund', ]:
514+ self._setparameter(Param_Dic, 'transId', trans_id)
515+# creditCardNumberMasked = self.getCustomerPaymentProfileRequest(Param_Dic)
516+# self._setparameter(Param_Dic,'creditCardNumberMasked',creditCardNumberMasked)
517+ Transaction = self.createCustomerProfileTransactionRequest(Param_Dic)
518+
519+ if Transaction and type(Transaction) == type([]) :
520+ Transaction_ID = Transaction[6]
521+ pay_profile_ids = self.pool.get('cust.payment.profile').search(cr, uid, [('name', '=', customerPaymentProfileId)])
522+ for pay_id in pay_profile_ids:
523+ trans_history_id = self.pool.get('transaction.history').create(cr, uid, {'trans_id':Transaction_ID,
524+ 'payment_profile_id':pay_id,
525+ 'amount':amount,
526+ 'trans_type':trans_type,
527+ 'transaction_date':time.strftime('%m/%d/%Y %H:%M:%S')
528+ })
529+
530+ ret_dic = {'cc_auth_code':Transaction[4],
531+ 'cc_trans_id':Transaction[6]
532+ }
533+ if trans_type == 'AuthOnly':
534+ status = 'Authorization: ' + str(Transaction[3])
535+ ret_dic['cc_status'] = status
536+ voucher_obj.write(cr, uid, ids[0], ret_dic)
537+ if trans_type == 'AuthCapture':
538+ status = 'Prior Authorization and Capture: ' + str(Transaction[3])
539+ ret_dic['amount'] = acc_voucher_obj.cc_order_amt
540+ ret_dic['cc_status'] = status
541+ ret_dic['cc_transaction'] = True
542+ voucher_obj.write(cr, uid, ids[0], ret_dic)
543+ if Transaction[0] == '1':
544+ '''
545+ Validating sales reciept
546+ '''
547+ self.validate_sales_reciept(cr, uid, ids, context=context)
548+
549+ '''
550+ Posting payment voucher
551+ '''
552+ voucher_obj.action_move_line_create(cr, uid, ids, context)
553+ ret = True
554+ if trans_type == 'Refund':
555+ status = 'Refund: ' + str(Transaction[3])
556+ ret_dic['cc_status'] = status
557+ voucher_obj.write(cr, uid, ids[0], ret_dic)
558+ journal_obj = self.pool.get('account.journal')
559+ if Transaction[0] == '1':
560+ ret_dic['cc_transaction'] = False
561+ ret = True
562+ refund_journal_id = False
563+ if user.company_id.cc_refund_journal_id:
564+ refund_journal_id = user.company_id.cc_refund_journal_id.id
565+ else:
566+ j_ids = journal_obj.search(cr, uid, [('type', '=', 'sale_refund')], context=context)
567+ if j_ids:
568+ refund_journal_id = j_ids[0]
569+ account_id = False
570+ if refund_journal_id:
571+ default_debit_account_id = journal_obj.browse(cr, uid, refund_journal_id, context=context).default_debit_account_id.id
572+
573+ vals1 = {
574+
575+ 'name' : 'Refund : ' + (acc_voucher_obj.rel_sale_order_id and str(acc_voucher_obj.rel_sale_order_id.name) or ''),
576+ 'account_id' : default_debit_account_id,
577+ 'partner_id' : acc_voucher_obj.partner_id.id,
578+ 'amount' : acc_voucher_obj.cc_order_amt,
579+ 'currency_id' : user.company_id.currency_id.id,
580+ 'origin':acc_voucher_obj.rel_sale_order_id and acc_voucher_obj.rel_sale_order_id.name or ''
581+ }
582+
583+ vals = voucher_obj.onchange_partner_id(cr, uid, [], acc_voucher_obj.partner_id.id, refund_journal_id , acc_voucher_obj.cc_order_amt , user.company_id.currency_id.id, 'sale', time.time())
584+ vals.update(vals1)
585+
586+ vals['journal_id'] = refund_journal_id
587+ vals['type'] = 'sale'
588+
589+ voucher_id = voucher_obj.create(cr, uid, vals, context=context)
590+
591+
592+ if acc_voucher_obj.cc_order_amt == acc_voucher_obj.rel_sale_order_id.amount_total and acc_voucher_obj.rel_sale_order_id.shipcharge:
593+ self.pool.get('sale.order').write(cr, uid, [acc_voucher_obj.rel_sale_order_id.id], {'cc_ship_refund':True}, context=context)
594+ refund_voucher = False
595+
596+ if 'cc_refund' not in context:
597+ refund_voucher = True
598+ sales_receipt_ids = voucher_obj.search(cr, uid, [('rel_sale_order_id', '=', acc_voucher_obj.rel_sale_order_id.id), ('state', '=', 'posted'), ('type', '=', 'sale')], order="id desc", context=context)
599+
600+ for receipt in voucher_obj.browse(cr, uid, sales_receipt_ids, context):
601+
602+ for line in receipt.line_ids:
603+
604+ if line.amount:
605+ vals = {
606+ 'voucher_id': voucher_id,
607+ 'name' : line.name,
608+ 'account_id' : line.account_id.id,
609+ 'partner_id' : line.partner_id.id,
610+ 'amount' : line.amount,
611+ 'type': line.type,
612+
613+ }
614+ line_id = vou_line_obj.create(cr, uid, vals, context)
615+ break
616+
617+ else:
618+ for line in context['cc_refund']:
619+ product = self.pool.get('product.product').browse(cr, uid, line['product_id'], context)
620+
621+ vals = {
622+ 'voucher_id': voucher_id,
623+ 'name' : product.name,
624+ 'account_id' : product.product_tmpl_id.property_account_income.id,
625+ 'partner_id' : acc_voucher_obj.partner_id.id,
626+ 'amount' : product.list_price * line['qty'],
627+ 'type' : 'cr',
628+ }
629+ line_id = vou_line_obj.create(cr, uid, vals, context)
630+ if context.get('cc_ship_refund'):
631+ vals = {
632+ 'voucher_id': voucher_id,
633+ 'name' : 'Shipping Charges of ' + acc_voucher_obj.rel_sale_order_id.name,
634+ 'account_id' : acc_voucher_obj.rel_sale_order_id.ship_method_id and acc_voucher_obj.rel_sale_order_id.ship_method_id.account_id.id or False,
635+ 'partner_id' : acc_voucher_obj.partner_id.id,
636+ 'amount' : context['cc_ship_refund'],
637+ 'type' : 'cr',
638+ }
639+ line_id = vou_line_obj.create(cr, uid, vals, context)
640+ self.pool.get('sale.order').write(cr, uid, [acc_voucher_obj.rel_sale_order_id.id], {'cc_ship_refund':True}, context=context)
641+
642+ if not refund_voucher:
643+ wf_service = netsvc.LocalService('workflow')
644+ wf_service.trg_validate(uid, 'account.voucher', voucher_id, 'proforma_voucher', cr)
645+ else:
646+ ret_dic['cc_transaction'] = True
647+ voucher_obj.write(cr, uid, ids, ret_dic)
648+
649+ else:
650+ raise osv.except_osv(_('Transaction Error'), _('Error code : ' + Transaction.get('Error_Message') or '' + '\nError Message :' + Transaction.get('Error_Message') or ''))
651+ return ret
652+auth_net_cc_api()
653+
654+class account_voucher(osv.osv):
655+ _inherit = 'account.voucher'
656+
657+ def cancel_cc(self, cr, uid, ids, context=None):
658+ return self.write(cr, uid, ids, { 'cc_status':'This Transaction has been Cancelled',
659+ 'cc_auth_code':'',
660+ 'cc_trans_id':'', })
661+
662+ def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context={}):
663+ ret = super(account_voucher, self).onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context)
664+ payment_obj = self.pool.get('cust.payment.profile')
665+ payment_profile_id = None
666+ if partner_id:
667+ partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
668+ cust_pay_profile_ids = payment_obj.search(cr, uid, [('cust_profile_id', '=', partner.payment_profile_id.id)])
669+ payment_profile_id = False
670+ if cust_pay_profile_ids:
671+ for cust_pay_profile_id in cust_pay_profile_ids:
672+ pay_profile_obj = payment_obj.browse(cr, uid, cust_pay_profile_id)
673+ payment_profile_id = pay_profile_obj.id
674+ break
675+ ret['value']['payment_profile_id'] = payment_profile_id
676+ return ret
677+
678+ _columns = {
679+ 'payment_profile_id': fields.many2one('cust.payment.profile', 'Payment Profile'),
680+ 'cc_order_date':fields.date('Order Date',),
681+ 'cc_order_amt':fields.float('Order Amt',),
682+ 'cc_comment':fields.char('Comment', size=128,),
683+ 'trans_type': fields.selection([('AuthOnly', 'Authorization Only'),
684+ ('AuthCapture', 'Authorization And Capture'),
685+ ('Refund', 'Credit/Refund'), ], 'Type', size=32),
686+# 'transaction_details':
687+
688+ }
689+account_voucher()
690
691=== added file 'account_payment_cim_authdotnet/account_voucher_view.xml'
692--- account_payment_cim_authdotnet/account_voucher_view.xml 1970-01-01 00:00:00 +0000
693+++ account_payment_cim_authdotnet/account_voucher_view.xml 2012-08-24 15:52:25 +0000
694@@ -0,0 +1,31 @@
695+<?xml version="1.0" encoding="UTF-8"?>
696+<openerp>
697+ <data>
698+
699+ <record id="view_acc_voucher_form" model="ir.ui.view">
700+ <field name="name">view_acc_voucher_form</field>
701+ <field name="model">account.voucher</field>
702+ <field name="type">form</field>
703+ <field name="inherit_id" ref="account_payment_creditcard.account_voucher_changes_for_credit_card_02"/>
704+ <field name="arch" type="xml">
705+ <xpath expr="//field[@name='cc_order_amt']" position="after">
706+ <newline/>
707+ <field name="payment_profile_id" domain="[('partner_id','=',partner_id)]" attrs="{'readonly':[('state','!=','draft')]}"/>
708+ </xpath>
709+ <xpath expr="//field[@name='cc_details']" position="replace"/>
710+ <xpath expr="//field[@name='cc_number']" position="replace"/>
711+ <xpath expr="//field[@name='cc_e_d_month']" position="replace"/>
712+ <xpath expr="//field[@name='cc_e_d_year']" position="replace"/>
713+ <xpath expr="//field[@name='cc_v']" position="replace"/>
714+ <xpath expr="//field[@name='cc_bank']" position="replace"/>
715+ <xpath expr="//field[@name='cc_save_card_details']" position="replace">
716+ <field name="trans_type" /><!--Added-->
717+ </xpath>
718+ <xpath expr="//field[@name='payment_profile_id']" position="after">
719+ <button name="%(action_create_payment_profile)d" type='action' string='Create Payment Profile'/>
720+ </xpath>
721+ </field>
722+ </record>
723+
724+ </data>
725+</openerp>
726
727=== added file 'account_payment_cim_authdotnet/cim_transaction.py'
728--- account_payment_cim_authdotnet/cim_transaction.py 1970-01-01 00:00:00 +0000
729+++ account_payment_cim_authdotnet/cim_transaction.py 2012-08-24 15:52:25 +0000
730@@ -0,0 +1,133 @@
731+# -*- coding: utf-8 -*-
732+##############################################################################
733+#
734+# OpenERP, Open Source Management Solution
735+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
736+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
737+#
738+# This program is free software: you can redistribute it and/or modify
739+# it under the terms of the GNU General Public License as published by
740+# the Free Software Foundation, either version 3 of the License, or
741+# (at your option) any later version.
742+#
743+# This program is distributed in the hope that it will be useful,
744+# but WITHOUT ANY WARRANTY; without even the implied warranty of
745+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
746+# GNU General Public License for more details.
747+#
748+# You should have received a copy of the GNU General Public License
749+# along with this program. If not, see <http://www.gnu.org/licenses/>
750+#
751+##############################################################################
752+from osv import osv, fields
753+
754+class cust_profile(osv.osv):
755+ _name = "cust.profile"
756+ _description = 'Customer Profile'
757+ _columns = {
758+ 'name': fields.char('Name', size=128, required=True, help='Store payment profile id', readonly=True),
759+ 'payment_profile_ids':fields.one2many('cust.payment.profile', 'cust_profile_id', 'Payment Profiles' , help='Store customers payment profile id', readonly=True),
760+ }
761+
762+cust_profile()
763+
764+class cust_payment_profile(osv.osv):
765+ _name = "cust.payment.profile"
766+ _description = 'Customer Payment Profile'
767+
768+ def _get_partner(self, cr, uid, context=None):
769+ if context is None:
770+ context = {}
771+ return context.get('active_id', False)
772+
773+ _columns = {
774+ 'name': fields.char('Name', size=128, required=True, help='Store payment profile id returned from authorise', readonly=True),
775+ 'cust_profile_id':fields.many2one('cust.profile', 'Customer Profiles', help='Store customers payment profile id', readonly=True),
776+ 'address_id':fields.many2one('res.partner.address', 'Address', readonly=True),
777+ 'transaction_history_ids':fields.one2many('transaction.history', 'payment_profile_id', 'Transaction History' , help='Store History of Transactions', readonly=True),
778+ 'description':fields.char('Description', size=128, readonly=True),
779+ 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, required=True),
780+ 'use_default':fields.boolean('Use Default')
781+ }
782+
783+ _defaults = {
784+ 'use_default':False,
785+ 'partner_id': _get_partner,
786+ }
787+
788+ def set_default(self, cr, uid, ids, context=None):
789+
790+ cus_pay_prof_ids = self.pool.get('cust.payment.profile').browse(cr, uid, ids[0])
791+ c_ids = cus_pay_prof_ids.cust_profile_id.payment_profile_ids
792+ for payment_profile_obj in c_ids:
793+ vals = {'use_default':True}
794+ if payment_profile_obj.id == ids[0]:
795+ vals = {'use_default':True}
796+ self.pool.get('cust.payment.profile').write(cr, uid, [payment_profile_obj.id], vals)
797+ return True
798+
799+ def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
800+ if context and (context.get('make_transaction') or context.get('edit_payment_profile')):
801+ cust_obj = context.get('active_model')
802+ pay_ids = []
803+ if cust_obj == 'res.partner':
804+ partner = self.pool.get(cust_obj).browse(cr, uid, context.get('active_id'))
805+ pay_profile_objs = partner.payment_profile_id.payment_profile_ids
806+ for pay_prof in pay_profile_objs:
807+ pay_ids.append(pay_prof.id)
808+ if len(pay_ids) > 0:
809+ args = [('id', 'in', pay_ids)]
810+
811+ return super(cust_payment_profile, self).search(cr, uid, args, offset, limit, order, context, count)
812+cust_payment_profile()
813+
814+class auth_config(osv.osv):
815+ _name = "auth.config"
816+ _rec_name = 'url'
817+ _description = 'Auth Configuration'
818+ _columns = {
819+ 'url':fields.char('URL', size=512, required=True, help='Authorize url'),
820+ 'url_test':fields.char('URL(Test Server) ', size=512, required=True, help='Authorize url'),
821+ 'test_mode':fields.boolean('Test Mode'),
822+ 'url_extension':fields.char('URL Extension', size=512, required=True, help='Authorize url extension'),
823+ 'xsd_link':fields.char('XSD Link', size=512, required=True, help='Path of the file containing the schema definitions for the request'),
824+ 'transaction_key':fields.char('Transaction Key', size=64, required=True,),
825+ 'login_id':fields.char('CreditCard Login ID', size=64, required=True,),
826+ }
827+auth_config()
828+
829+class transaction_history(osv.osv):
830+ _name = "transaction.history"
831+ _rec_name = 'trans_id'
832+ _description = 'Transaction History'
833+ _columns = {
834+ 'trans_id':fields.char('Transaction ID', size=128, required=True,),
835+ 'amount':fields.float('Amount'),
836+ 'trans_type':fields.char('Transaction Type', size=64, required=True,),
837+ 'transaction_date':fields.datetime('Transaction Date'),
838+ 'payment_profile_id':fields.many2one('cust.payment.profile', 'Payment Profile ID', help='Store customers payment profile id')
839+ }
840+transaction_history()
841+
842+class transaction_details(osv.osv):
843+ _name = "transaction.details"
844+ _rec_name = 'trans_id'
845+ _description = 'Transaction Details'
846+ _columns = {
847+ 'trans_id':fields.char('Transaction ID', size=128, required=True),
848+ 'amount':fields.integer('Amount'),
849+ 'trans_type':fields.char('Transaction Type', size=64, required=True),
850+ 'transaction_date':fields.datetime('Transaction Date'),
851+ 'payment_profile_id':fields.many2one('cust.payment.profile', 'Payment Profile ID', help='Store customers payment profile id'),
852+ 'voucher_id':fields.many2one('account.voucher', 'Account Voucher'),
853+ }
854+transaction_details()
855+
856+#class cust_profile(osv.osv):
857+# _inherit = "cust.profile"
858+# _description = 'Customer Profile'
859+# _columns = {
860+# 'payment_profile_ids':fields.one2many('cust.payment.profile', 'cust_profile_id','Payment Profiles' ,help='Store customers payment profile id'),
861+# }
862+#cust_profile()
863+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
864
865=== added file 'account_payment_cim_authdotnet/cim_transaction_view.xml'
866--- account_payment_cim_authdotnet/cim_transaction_view.xml 1970-01-01 00:00:00 +0000
867+++ account_payment_cim_authdotnet/cim_transaction_view.xml 2012-08-24 15:52:25 +0000
868@@ -0,0 +1,89 @@
869+<?xml version="1.0" encoding="UTF-8"?>
870+<openerp>
871+ <data>
872+
873+ <record id="view_cim_transaction_cust_profile_form" model="ir.ui.view">
874+ <field name="name">view_cim_transaction_cust_profile_form</field>
875+ <field name="model">cust.profile</field>
876+ <field name="type">form</field>
877+ <field name="arch" type="xml">
878+ <form string="Profile">
879+ <field name="name"/>
880+ <field name="payment_profile_ids"/>
881+ </form>
882+ </field>
883+ </record>
884+
885+ <record id="view_cim_transaction_cust_profile_tree" model="ir.ui.view">
886+ <field name="name">view_cim_transaction_cust_profile_tree</field>
887+ <field name="model">cust.profile</field>
888+ <field name="type">tree</field>
889+ <field name="arch" type="xml">
890+ <tree string="Profile">
891+ <field name="name"/>
892+ <field name="payment_profile_ids"/>
893+ </tree>
894+ </field>
895+ </record>
896+
897+
898+ <record id="view_cim_transaction_cust_payment_profile_form" model="ir.ui.view">
899+ <field name="name">view_cim_transaction_cust_payment_profile_form</field>
900+ <field name="model">cust.payment.profile</field>
901+ <field name="type">form</field>
902+ <field name="arch" type="xml">
903+ <form string="Payment Profile">
904+ <field name="name"/>
905+ <field name="address_id"/>
906+ <field name="description"/>
907+ <newline/>
908+ <field name="transaction_history_ids" colspan='4' nolabel='1'/>
909+ </form>
910+ </field>
911+ </record>
912+
913+
914+ <record id="view_cim_transaction_cust_payment_profile_tree" model="ir.ui.view">
915+ <field name="name">view_cim_transaction_cust_payment_profile_tree</field>
916+ <field name="model">cust.payment.profile</field>
917+ <field name="type">tree</field>
918+ <field name="arch" type="xml">
919+ <tree string="Payment Profile">
920+ <field name="description"/>
921+ <field name="name"/>
922+ <field name="address_id"/>
923+ <field name="transaction_history_ids" />
924+ </tree>
925+ </field>
926+ </record>
927+
928+ <record id="view_transaction_history_form" model="ir.ui.view">
929+ <field name="name">view_transaction_history_form</field>
930+ <field name="model">transaction.history</field>
931+ <field name="type">form</field>
932+ <field name="arch" type="xml">
933+ <form string="Transaction History">
934+ <field name="trans_id"/>
935+ <field name="amount"/>
936+ <field name="trans_type"/>
937+ <field name="transaction_date"/>
938+ </form>
939+ </field>
940+ </record>
941+
942+ <record id="view_transaction_history_tree" model="ir.ui.view">
943+ <field name="name">view_transaction_history_tree</field>
944+ <field name="model">transaction.history</field>
945+ <field name="type">tree</field>
946+ <field name="arch" type="xml">
947+ <tree string="Transaction History">
948+ <field name="trans_id"/>
949+ <field name="amount"/>
950+ <field name="trans_type"/>
951+ <field name="transaction_date"/>
952+ </tree>
953+ </field>
954+ </record>
955+
956+ </data>
957+</openerp>
958
959=== added file 'account_payment_cim_authdotnet/company_view.xml'
960--- account_payment_cim_authdotnet/company_view.xml 1970-01-01 00:00:00 +0000
961+++ account_payment_cim_authdotnet/company_view.xml 2012-08-24 15:52:25 +0000
962@@ -0,0 +1,32 @@
963+<?xml version="1.0" encoding="UTF-8"?>
964+<openerp>
965+ <data>
966+ <record id="base_caompany_view_inherit" model="ir.ui.view">
967+ <field name="name">base_caompany_view_inherit</field>
968+ <field name="model">res.company</field>
969+ <field name="type">form</field>
970+ <field name="inherit_id" ref="base.view_company_form"/>
971+ <field name="arch" type="xml">
972+ <xpath expr="/form/notebook/page[@string='Configuration']" position="inside">
973+ <separator colspan="4" string="Authorization Configuration"/>
974+ <group colspan='4'>
975+ <field name="auth_config_id" >
976+ <tree string="Configuration">
977+ <field name="url" />
978+ <field name="url_extension" />
979+ <field name="xsd_link" />
980+ </tree>
981+ <form string="Configuration">
982+ <field name="url" />
983+ <field name="url_extension" />
984+ <field name="xsd_link" />
985+ <field name="transaction_key" />
986+ <field name="login_id" />
987+ </form>
988+ </field>
989+ </group>
990+ </xpath>
991+ </field>
992+ </record>
993+ </data>
994+</openerp>
995
996=== added file 'account_payment_cim_authdotnet/partner.py'
997--- account_payment_cim_authdotnet/partner.py 1970-01-01 00:00:00 +0000
998+++ account_payment_cim_authdotnet/partner.py 2012-08-24 15:52:25 +0000
999@@ -0,0 +1,218 @@
1000+# -*- coding: utf-8 -*-
1001+##############################################################################
1002+#
1003+# OpenERP, Open Source Management Solution
1004+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
1005+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
1006+#
1007+# This program is free software: you can redistribute it and/or modify
1008+# it under the terms of the GNU General Public License as published by
1009+# the Free Software Foundation, either version 3 of the License, or
1010+# (at your option) any later version.
1011+#
1012+# This program is distributed in the hope that it will be useful,
1013+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1014+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1015+# GNU General Public License for more details.
1016+#
1017+# You should have received a copy of the GNU General Public License
1018+# along with this program. If not, see <http://www.gnu.org/licenses/>
1019+#
1020+##############################################################################
1021+from osv import osv, fields
1022+import httplib
1023+from xml.dom.minidom import Document
1024+import xml2dic
1025+from tools.translate import _
1026+
1027+class res_partner(osv.osv):
1028+ _inherit = 'res.partner'
1029+ _rec_name = 'payment_profile_id'
1030+ _columns = {
1031+ 'payment_profile_id': fields.many2one('cust.profile', 'Payment Profiles', help='Store customers payment profile id', readonly='True'),
1032+# 'payment_profile_ids':fields.one2many('cust.payment.profile', 'partner_id','Payment Profiles' ,help='Store customers payment profile id',readonly=True),
1033+ 'payment_profile_ids': fields.related('payment_profile_id', 'payment_profile_ids', type='one2many', relation='cust.payment.profile', string='Payment Profiles', readonly=True),
1034+ }
1035+
1036+ def request_to_server(self, Request_string, url, url_path):
1037+ ''' Sends a POST request to url and returns the response from the server'''
1038+ conn = httplib.HTTPSConnection(url)
1039+ conn.putrequest('POST', url_path)
1040+ conn.putheader('content-type', 'text/xml')
1041+ print "Request_string",Request_string
1042+ print "IRRR",url, url_path
1043+ conn.putheader('content-length', len(Request_string))
1044+ conn.endheaders()
1045+ conn.send(Request_string)
1046+ response = conn.getresponse()
1047+ create_CustomerProfile_response_xml = response.read()
1048+ return create_CustomerProfile_response_xml
1049+
1050+ def search_dic(self, dic, key):
1051+ ''' Returns the parent dictionary containing key None on Faliure'''
1052+ if key in dic.keys():
1053+ return dic
1054+ for k in dic.keys():
1055+ if type(dic[k]) == type([]):
1056+ for i in dic[k]:
1057+ if type(i) == type({}):
1058+ ret = self.search_dic(i, key)
1059+ if ret and key in ret.keys():
1060+ return ret
1061+ return None
1062+
1063+ def _clean_string(self, text):
1064+ lis = ['\t', '\n']
1065+ if type(text) != type(''):
1066+ text = str(text)
1067+ for t in lis:
1068+ text = text.replace(t, '')
1069+ return text
1070+
1071+ def _setparameter(self, dic, key, value):
1072+ ''' Used to input parameters to corresponding dictionary'''
1073+ if key == None or value == None :
1074+ return
1075+ if type(value) == type(''):
1076+ dic[key] = value.strip()
1077+ else:
1078+ dic[key] = value
1079+
1080+ def createCustomerProfile(self, dic):
1081+ '''Creates CustomerProfile and returns the CustomerProfile id on success returns None or faliure '''
1082+
1083+ KEYS = dic.keys()
1084+ doc1 = Document()
1085+ url_path = dic.get('url_extension', False)
1086+ url = dic.get('url', False)
1087+ xsd = dic.get('xsd', False)
1088+
1089+ createCustomerProfileRequest = doc1.createElement("createCustomerProfileRequest")
1090+ createCustomerProfileRequest.setAttribute("xmlns", xsd)
1091+ doc1.appendChild(createCustomerProfileRequest)
1092+
1093+ merchantAuthentication = doc1.createElement("merchantAuthentication")
1094+ createCustomerProfileRequest.appendChild(merchantAuthentication)
1095+
1096+ name = doc1.createElement("name")
1097+ merchantAuthentication.appendChild(name)
1098+
1099+ transactionKey = doc1.createElement("transactionKey")
1100+ merchantAuthentication.appendChild(transactionKey)
1101+
1102+ ##Create the Request for creating the customer profile
1103+ if 'api_login_id' in KEYS and 'transaction_key' in KEYS:
1104+
1105+ ptext1 = doc1.createTextNode(self._clean_string(dic['api_login_id']))
1106+ name.appendChild(ptext1)
1107+
1108+ ptext = doc1.createTextNode(self._clean_string(dic['transaction_key']))
1109+ transactionKey.appendChild(ptext)
1110+
1111+ if 'refId' in KEYS:
1112+ refId = doc1.createElement("refId")
1113+ ptext1 = doc1.createTextNode(self._clean_string(dic['refId']))
1114+ refId.appendChild(ptext1)
1115+ createCustomerProfileRequest.appendChild(refId)
1116+
1117+ ##Now Add Profile INformation for the user
1118+ profile = doc1.createElement("profile")
1119+ createCustomerProfileRequest.appendChild(profile)
1120+
1121+ if 'merchantCustomerId' in KEYS:
1122+ merchantCustomerId = doc1.createElement("merchantCustomerId")
1123+ profile.appendChild(merchantCustomerId)
1124+ ptext = doc1.createTextNode(dic['merchantCustomerId'])
1125+ merchantCustomerId.appendChild(ptext)
1126+
1127+ if 'description' in KEYS:
1128+ description = doc1.createElement("description")
1129+ profile.appendChild(description)
1130+ ptext = doc1.createTextNode(dic['description'])
1131+ description.appendChild(ptext)
1132+
1133+ if 'email' in KEYS:
1134+ email = doc1.createElement("email")
1135+ profile.appendChild(email)
1136+ ptext = doc1.createTextNode(dic['email'])
1137+ email.appendChild(ptext)
1138+
1139+
1140+ if 'paymentProfiles' in KEYS:
1141+ paymentProfiles = doc1.createElement("paymentProfiles")
1142+ profile.appendChild(paymentProfiles)
1143+ ptext1 = doc1.createTextNode(self._clean_string(dic['paymentProfiles']))
1144+ paymentProfiles.appendChild(ptext1)
1145+
1146+ #############TO DO ADD THE NECCESSARY OPTIONS INTO IT
1147+
1148+ # Request_string1=xml=doc1.toprettyxml( encoding="utf-8" )
1149+ Request_string = xml = doc1.toxml(encoding="utf-8")
1150+
1151+ #Select from production and test server
1152+ create_CustomerProfile_response_xml = self.request_to_server(Request_string, url, url_path)
1153+ create_CustomerProfile_response_dictionary = xml2dic.main(create_CustomerProfile_response_xml)
1154+ parent_msg = self.search_dic(create_CustomerProfile_response_dictionary, "messages")
1155+ if parent_msg['messages'][0]['resultCode'] == 'Ok':
1156+ parent = self.search_dic(create_CustomerProfile_response_dictionary, "customerProfileId")
1157+ return parent['customerProfileId']
1158+
1159+ return {'Error_Code':parent_msg['messages'][1]['message'][0]['code'],
1160+ 'Error_Message' :parent_msg['messages'][1]['message'][1]['text']}
1161+
1162+ def create_cust_profile(self, cr, uid, ids, address_id=False, context=None):
1163+ ret = {}
1164+ Param_Dic = {}
1165+ email = ''
1166+ merchantCustomerId = ''
1167+ description = ''
1168+ cust_obj = self.pool.get('res.partner')
1169+ customers = cust_obj.browse(cr, uid, ids)
1170+ for customer in customers:
1171+ Trans_key = customer.company_id.auth_config_id.transaction_key or ''
1172+ Login_id = customer.company_id.auth_config_id.login_id or ''
1173+ url_extension = customer.company_id.auth_config_id.url_extension or ''
1174+ xsd = customer.company_id.auth_config_id.xsd_link or ''
1175+ description += (customer.ref or '') + (customer.name or '')
1176+ if customer.company_id.auth_config_id.test_mode:
1177+ url = customer.company_id.auth_config_id.url_test or ''
1178+ else:
1179+ url = customer.company_id.auth_config_id.url or ''
1180+
1181+ if not address_id:
1182+ address = cust_obj.address_get(cr, uid, [customer.id], ['invoice'])
1183+ address = self.pool.get('res.partner.address').browse(cr, uid, address['invoice'])
1184+ else:
1185+ address = self.pool.get('res.partner.address').browse(cr, uid, address_id)
1186+
1187+ email = address.email or ''
1188+
1189+ if Trans_key and Login_id:
1190+ self._setparameter(Param_Dic, 'api_login_id', Login_id)
1191+ self._setparameter(Param_Dic, 'transaction_key', Trans_key)
1192+
1193+ self._setparameter(Param_Dic, 'email', email)
1194+ self._setparameter(Param_Dic, 'description', description)
1195+ self._setparameter(Param_Dic, 'merchantCustomerId', merchantCustomerId)
1196+
1197+ if url:
1198+ self._setparameter(Param_Dic, 'url', url)
1199+ self._setparameter(Param_Dic, 'url_extension', url_extension)
1200+ if xsd:
1201+ self._setparameter(Param_Dic, 'xsd', xsd)
1202+
1203+ Customer_Profile_ID = self.createCustomerProfile(Param_Dic)
1204+ if Customer_Profile_ID and type(Customer_Profile_ID) == type(''):
1205+ cust_prof_id = self.pool.get('cust.profile').create(cr, uid, {'name':Customer_Profile_ID})
1206+ cust_obj.write(cr, uid, ids, {'payment_profile_id':cust_prof_id})
1207+ self._setparameter(Param_Dic, 'customerProfileId', Customer_Profile_ID)
1208+ return Customer_Profile_ID
1209+ else:
1210+ raise osv.except_osv(_('Transaction Error in Creating Customer Profile ID'), _('Error code : ' + Customer_Profile_ID['Error_Code'] + '\nError Message :' + Customer_Profile_ID['Error_Message']))
1211+ else:
1212+ raise osv.except_osv(_('Transaction Error'), _('Cannot process without valid Transaction Key and/or Login ID.Please check the configuration'))
1213+
1214+ return ret
1215+
1216+res_partner()
1217+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1218
1219=== added file 'account_payment_cim_authdotnet/partner_view.xml'
1220--- account_payment_cim_authdotnet/partner_view.xml 1970-01-01 00:00:00 +0000
1221+++ account_payment_cim_authdotnet/partner_view.xml 2012-08-24 15:52:25 +0000
1222@@ -0,0 +1,36 @@
1223+<?xml version="1.0" encoding="UTF-8"?>
1224+<openerp>
1225+ <data>
1226+ <record id="base_partner_view_inherit" model="ir.ui.view">
1227+ <field name="name">base_partner_view_inherit</field>
1228+ <field name="model">res.partner</field>
1229+ <field name="type">form</field>
1230+ <field name="inherit_id" ref="base.view_partner_form"/>
1231+ <field name="arch" type="xml">
1232+ <xpath expr="//field[@name='bank_ids']" position="before">
1233+ <separator string="Credit Card"/>
1234+ <newline/>
1235+ <!--field name="payment_profile_id" nolabel='1' colsapn='4' cols='8'/-->
1236+ <group colsapn='4'>
1237+ <field name="payment_profile_ids" nolabel='1' colsapn='4' >
1238+ <tree string='Payment Profiles'>
1239+ <field name="name"/>
1240+ <field name="cust_profile_id"/>
1241+ <field name="transaction_history_ids"/>
1242+ <field name="description"/>
1243+ <field name="use_default" invisible='1'/>
1244+ <button name="%(action_edit_payment_profile)d" type='action' string='Edit Payment Profile' icon="gtk-edit"/>
1245+ <button name="%(action_delete_payment_profile)d" type='action' string='Delete Payment Profile' icon="gtk-cancel"/>
1246+ <button name='set_default' string='Set as Default' icon="gtk-execute" type='object' attrs="{'invisible':[('use_default','=',True)]}"/>
1247+ </tree>
1248+ </field>
1249+ <newline/>
1250+ <button name="%(action_create_payment_profile)d" type='action' string='Create Payment Profile'/>
1251+ </group>
1252+ <!--button name="%(action_make_transaction)d" type='action' string='Make Transaction'/-->
1253+ <!--button name="%(action_edit_payment_profile)d" type='action' string='Edit Payment Profile'/-->
1254+ <!--button name="%(action_delete_payment_profile)d" type='action' string='Delete Payment Profile'/--> </xpath>
1255+ </field>
1256+ </record>
1257+ </data>
1258+</openerp>
1259
1260=== added file 'account_payment_cim_authdotnet/res_company.py'
1261--- account_payment_cim_authdotnet/res_company.py 1970-01-01 00:00:00 +0000
1262+++ account_payment_cim_authdotnet/res_company.py 2012-08-24 15:52:25 +0000
1263@@ -0,0 +1,30 @@
1264+# -*- coding: utf-8 -*-
1265+##############################################################################
1266+#
1267+# OpenERP, Open Source Management Solution
1268+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
1269+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
1270+#
1271+# This program is free software: you can redistribute it and/or modify
1272+# it under the terms of the GNU General Public License as published by
1273+# the Free Software Foundation, either version 3 of the License, or
1274+# (at your option) any later version.
1275+#
1276+# This program is distributed in the hope that it will be useful,
1277+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1278+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1279+# GNU General Public License for more details.
1280+#
1281+# You should have received a copy of the GNU General Public License
1282+# along with this program. If not, see <http://www.gnu.org/licenses/>
1283+#
1284+##############################################################################
1285+from osv import osv, fields
1286+
1287+class res_company(osv.osv):
1288+ _inherit = "res.company"
1289+ _columns = {
1290+ 'auth_config_id':fields.many2one('auth.config', 'Auth Configuration')}
1291+res_company()
1292+
1293+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1294
1295=== added file 'account_payment_cim_authdotnet/test.py'
1296--- account_payment_cim_authdotnet/test.py 1970-01-01 00:00:00 +0000
1297+++ account_payment_cim_authdotnet/test.py 2012-08-24 15:52:25 +0000
1298@@ -0,0 +1,202 @@
1299+ def do_this_transaction(self, cr, uid, ids, refund=False, context=None):
1300+ '''
1301+ Do credit card transaction
1302+ '''
1303+ voucher_obj = self.pool.get('account.voucher')
1304+ vou_line_obj = self.pool.get('account.voucher.line')
1305+ if type([]) == type(ids):
1306+ acc_voucher_obj=voucher_obj.browse(cr,uid,ids[0],context={'cc_no':'no_mask'})
1307+ else:
1308+ acc_voucher_obj=voucher_obj.browse(cr,uid,ids,context={'cc_no':'no_mask'})
1309+ if not acc_voucher_obj.payment_profile_id:
1310+ raise osv.except_osv(_('No Payment Profile!'),_(" Select Payment Profile.") )
1311+ ret = False
1312+ company =acc_voucher_obj.partner_id and acc_voucher_obj.partner_id.company_id
1313+ customer =acc_voucher_obj.partner_id
1314+ user = self.pool.get('res.users').browse(cr,uid,uid)
1315+ amount = acc_voucher_obj.amount
1316+ if amount <=0.00:
1317+ raise osv.except_osv(_('No Amount!'),_(" Enter a Positive Amount") )
1318+ if refund:
1319+ trans_type ='Refund'
1320+ if acc_voucher_obj.cc_trans_id:
1321+ trans_id =acc_voucher_obj.cc_trans_id
1322+ if not acc_voucher_obj.cc_trans_id:
1323+ raise osv.except_osv(_('No Transaction ID!'),_(" Unable to find transaction id for refund.") )
1324+ if not acc_voucher_obj.journal_id.cc_allow_refunds:
1325+ raise osv.except_osv(_('Unable to do Refund!'),_("Please check \"Allow Credit Card Refunds\" on journal to do refund.") )
1326+ elif acc_voucher_obj.cc_p_authorize:
1327+ trans_type ='AuthOnly'
1328+ elif acc_voucher_obj.cc_charge:
1329+ trans_type='AuthCapture'
1330+ if company and company.auth_config_id:
1331+ Login_id=company.auth_config_id.login_id
1332+ Trans_key=company.auth_config_id.transaction_key
1333+ url_extension =company.auth_config_id.url_extension
1334+ xsd=company.auth_config_id.xsd_link
1335+ if company.auth_config_id.test_mode == True:
1336+ url =company.auth_config_id.url_test
1337+ else:
1338+ url =company.auth_config_id.url
1339+ if acc_voucher_obj.payment_profile_id:
1340+ customerPaymentProfileId = acc_voucher_obj.payment_profile_id.name
1341+ Customer_Profile_ID = acc_voucher_obj.payment_profile_id.cust_profile_id.name
1342+
1343+ Param_Dic={}
1344+ if Trans_key and Login_id:
1345+ self._setparameter(Param_Dic,'api_login_id',Login_id)
1346+ self._setparameter(Param_Dic,'transaction_key',Trans_key)
1347+
1348+ if url:
1349+ self._setparameter(Param_Dic,'url',url)
1350+ self._setparameter(Param_Dic,'url_extension',url_extension)
1351+ if xsd:
1352+ self._setparameter(Param_Dic,'xsd',xsd)
1353+
1354+ self._setparameter(Param_Dic,'customerProfileId',Customer_Profile_ID)
1355+ self._setparameter(Param_Dic,'customerPaymentProfileId',customerPaymentProfileId)
1356+ self._setparameter(Param_Dic,'amount',amount)
1357+ self._setparameter(Param_Dic,'trans_type',trans_type)
1358+
1359+ if trans_type in ['Refund',]:
1360+ self._setparameter(Param_Dic,'transId',trans_id)
1361+# creditCardNumberMasked = self.getCustomerPaymentProfileRequest(Param_Dic)
1362+# self._setparameter(Param_Dic,'creditCardNumberMasked',creditCardNumberMasked)
1363+ Transaction = self.createCustomerProfileTransactionRequest(Param_Dic)
1364+
1365+ if Transaction and type(Transaction) == type([]) :
1366+ Transaction_ID=Transaction[6]
1367+ pay_profile_ids=self.pool.get('cust.payment.profile').search(cr,uid,[('name','=',customerPaymentProfileId)])
1368+ for pay_id in pay_profile_ids:
1369+ trans_history_id=self.pool.get('transaction.history').create(cr,uid,{'trans_id':Transaction_ID,
1370+ 'payment_profile_id':pay_id,
1371+ 'amount':amount,
1372+ 'trans_type':trans_type,
1373+ 'transaction_date':time.strftime('%m/%d/%Y %H:%M:%S')
1374+ })
1375+
1376+ ret_dic={'cc_auth_code':Transaction[4],
1377+ 'cc_trans_id':Transaction[6]
1378+ }
1379+ if trans_type == 'AuthOnly':
1380+ status = 'Authorization: '+str(Transaction[3])
1381+ ret_dic['cc_status'] = status
1382+ voucher_obj.write(cr, uid, ids[0], ret_dic)
1383+ if trans_type == 'AuthCapture':
1384+ status = 'Prior Authorization and Capture: '+str(Transaction[3])
1385+ ret_dic['amount'] = acc_voucher_obj.cc_order_amt
1386+ ret_dic['cc_status'] = status
1387+ ret_dic['cc_transaction'] = True
1388+ voucher_obj.write(cr, uid, ids[0], ret_dic)
1389+ if Transaction[0]=='1':
1390+ '''
1391+ Validating sales reciept
1392+ '''
1393+ self.validate_sales_reciept(cr, uid, ids, context=context)
1394+
1395+ '''
1396+ Posting payment voucher
1397+ '''
1398+ voucher_obj.action_move_line_create(cr, uid, ids, context)
1399+ ret = True
1400+ if trans_type == 'Refund':
1401+ status = 'Refund: '+str(Transaction[3])
1402+ ret_dic['cc_status'] = status
1403+ voucher_obj.write(cr, uid, ids[0], ret_dic)
1404+ journal_obj = self.pool.get('account.journal')
1405+ if Transaction[0]=='1':
1406+ ret_dic['cc_transaction'] = False
1407+ ret = True
1408+ refund_journal_id = False
1409+ if user.company_id.cc_refund_journal_id:
1410+ refund_journal_id = user.company_id.cc_refund_journal_id.id
1411+ else:
1412+ j_ids = journal_obj.search(cr, uid, [('type','=','sale_refund')], context=context)
1413+ if j_ids:
1414+ refund_journal_id = j_ids[0]
1415+ account_id=False
1416+ if refund_journal_id:
1417+ default_debit_account_id = journal_obj.browse(cr, uid, refund_journal_id,context=context).default_debit_account_id.id
1418+
1419+ vals1 = {
1420+
1421+ 'name' : 'Refund : ' + (acc_voucher_obj.rel_sale_order_id and str(acc_voucher_obj.rel_sale_order_id.name) or ''),
1422+ 'account_id' : default_debit_account_id,
1423+ 'partner_id' : acc_voucher_obj.partner_id.id,
1424+ 'amount' : acc_voucher_obj.cc_order_amt,
1425+ 'currency_id' : user.company_id.currency_id.id,
1426+ 'origin':acc_voucher_obj.rel_sale_order_id and acc_voucher_obj.rel_sale_order_id.name or ''
1427+ }
1428+
1429+ vals = voucher_obj.onchange_partner_id(cr, uid, [], acc_voucher_obj.partner_id.id, refund_journal_id , acc_voucher_obj.cc_order_amt , user.company_id.currency_id.id, 'sale', time.time())
1430+ vals.update(vals1)
1431+
1432+ vals['journal_id'] = refund_journal_id
1433+ vals['type'] = 'sale'
1434+
1435+ voucher_id = voucher_obj.create(cr, uid, vals, context=context)
1436+
1437+
1438+ if acc_voucher_obj.cc_order_amt == acc_voucher_obj.rel_sale_order_id.amount_total and acc_voucher_obj.rel_sale_order_id.shipcharge:
1439+ self.pool.get('sale.order').write(cr, uid, [acc_voucher_obj.rel_sale_order_id.id],{'cc_ship_refund':True},context=context)
1440+ refund_voucher=False
1441+
1442+ if 'cc_refund' not in context:
1443+ refund_voucher=True
1444+ sales_receipt_ids = voucher_obj.search(cr,uid,[('rel_sale_order_id','=',acc_voucher_obj.rel_sale_order_id.id),('state','=','posted'),('type','=','sale')], order="id desc",context=context)
1445+
1446+ for receipt in voucher_obj.browse(cr, uid, sales_receipt_ids, context):
1447+
1448+ for line in receipt.line_ids:
1449+
1450+ if line.amount:
1451+ vals = {
1452+ 'voucher_id': voucher_id,
1453+ 'name' : line.name,
1454+ 'account_id' : line.account_id.id,
1455+ 'partner_id' : line.partner_id.id,
1456+ 'amount' : line.amount,
1457+ 'type': line.type,
1458+
1459+ }
1460+ line_id = vou_line_obj.create(cr, uid, vals, context)
1461+ break
1462+
1463+ else:
1464+ for line in context['cc_refund']:
1465+ product=self.pool.get('product.product').browse(cr, uid, line['product_id'],context)
1466+
1467+ vals = {
1468+ 'voucher_id': voucher_id,
1469+ 'name' : product.name,
1470+ 'account_id' : product.product_tmpl_id.property_account_income.id,
1471+ 'partner_id' : acc_voucher_obj.partner_id.id,
1472+ 'amount' : product.list_price * line['qty'],
1473+ 'type' : 'cr',
1474+ }
1475+ line_id = vou_line_obj.create(cr, uid, vals, context)
1476+ if context.get('cc_ship_refund'):
1477+ vals = {
1478+ 'voucher_id': voucher_id,
1479+ 'name' : 'Shipping Charges of ' + acc_voucher_obj.rel_sale_order_id.name,
1480+ 'account_id' : acc_voucher_obj.rel_sale_order_id.ship_method_id and acc_voucher_obj.rel_sale_order_id.ship_method_id.account_id.id or False,
1481+ 'partner_id' : acc_voucher_obj.partner_id.id,
1482+ 'amount' : context['cc_ship_refund'],
1483+ 'type' : 'cr',
1484+ }
1485+ line_id = vou_line_obj.create(cr, uid, vals, context)
1486+ self.pool.get('sale.order').write(cr, uid, [acc_voucher_obj.rel_sale_order_id.id],{'cc_ship_refund':True},context=context)
1487+
1488+ if not refund_voucher:
1489+ wf_service = netsvc.LocalService('workflow')
1490+ wf_service.trg_validate(uid, 'account.voucher', voucher_id, 'proforma_voucher', cr)
1491+ else:
1492+ ret_dic['cc_transaction'] = True
1493+ voucher_obj.write(cr, uid, ids, ret_dic)
1494+
1495+ else:
1496+ raise osv.except_osv(_('Transaction Error'), _('Error code : '+ Transaction.get('Error_Message') or '' +'\nError Message :'+Transaction.get('Error_Message') or '' ))
1497+
1498+ return ret
1499+
1500+auth_net_cc_api()
1501\ No newline at end of file
1502
1503=== added directory 'account_payment_cim_authdotnet/wizard'
1504=== added file 'account_payment_cim_authdotnet/wizard/__init__.py'
1505--- account_payment_cim_authdotnet/wizard/__init__.py 1970-01-01 00:00:00 +0000
1506+++ account_payment_cim_authdotnet/wizard/__init__.py 2012-08-24 15:52:25 +0000
1507@@ -0,0 +1,28 @@
1508+# -*- coding: utf-8 -*-
1509+##############################################################################
1510+#
1511+# OpenERP, Open Source Management Solution
1512+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
1513+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
1514+#
1515+# This program is free software: you can redistribute it and/or modify
1516+# it under the terms of the GNU General Public License as published by
1517+# the Free Software Foundation, either version 3 of the License, or
1518+# (at your option) any later version.
1519+#
1520+# This program is distributed in the hope that it will be useful,
1521+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1522+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1523+# GNU General Public License for more details.
1524+#
1525+# You should have received a copy of the GNU General Public License
1526+# along with this program. If not, see <http://www.gnu.org/licenses/>
1527+#
1528+##############################################################################
1529+
1530+import create_payment_profile
1531+import make_transaction
1532+import edit_payment_profile
1533+import delete_payment_profile
1534+
1535+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1536
1537=== added file 'account_payment_cim_authdotnet/wizard/create_payment_profile.py'
1538--- account_payment_cim_authdotnet/wizard/create_payment_profile.py 1970-01-01 00:00:00 +0000
1539+++ account_payment_cim_authdotnet/wizard/create_payment_profile.py 2012-08-24 15:52:25 +0000
1540@@ -0,0 +1,328 @@
1541+# -*- coding: utf-8 -*-
1542+##############################################################################
1543+#
1544+# OpenERP, Open Source Management Solution
1545+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
1546+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
1547+#
1548+# This program is free software: you can redistribute it and/or modify
1549+# it under the terms of the GNU General Public License as published by
1550+# the Free Software Foundation, either version 3 of the License, or
1551+# (at your option) any later version.
1552+#
1553+# This program is distributed in the hope that it will be useful,
1554+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1555+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1556+# GNU General Public License for more details.
1557+#
1558+# You should have received a copy of the GNU General Public License
1559+# along with this program. If not, see <http://www.gnu.org/licenses/>
1560+#
1561+##############################################################################
1562+
1563+from osv import fields, osv
1564+import httplib
1565+from xml.dom.minidom import Document
1566+import xml2dic
1567+
1568+class create_payment_profile(osv.osv_memory):
1569+ _name = 'create.payment.profile'
1570+ _description = 'Create Payment Profile'
1571+
1572+ def _get_partner(self, cr, uid, context=None):
1573+ if context is None:
1574+ context = {}
1575+ return context.get('active_id', False)
1576+
1577+ _columns = {
1578+ 'cc_number':fields.char('Credit Card Number', size=32, required=True),
1579+ 'cc_ed_month':fields.char('Expiration Date MM', size=32, required=True),
1580+ 'cc_ed_year':fields.char('Expiration Date YYYY', size=32 , required=True),
1581+ 'cc_verify_code':fields.char('Card Code Verification', size=32),
1582+ 'address_id':fields.many2one('res.partner.address', 'Address'),
1583+ 'partner_id':fields.many2one('res.partner', 'Customer'),
1584+ 'description':fields.char('Description', size=128)
1585+ }
1586+
1587+ _defaults = {
1588+ 'partner_id' : _get_partner,
1589+ }
1590+
1591+ def request_to_server(self, Request_string, url, url_path):
1592+ ''' Sends a POST request to url and returns the response from the server'''
1593+
1594+ conn = httplib.HTTPSConnection(url)
1595+ conn.putrequest('POST', url_path)
1596+ conn.putheader('content-type', 'text/xml')
1597+ conn.putheader('content-length', len(Request_string))
1598+ conn.endheaders()
1599+ conn.send(Request_string)
1600+ response = conn.getresponse()
1601+ create_CustomerProfile_response_xml = response.read()
1602+ return create_CustomerProfile_response_xml
1603+
1604+ def search_dic(self, dic, key):
1605+ ''' Returns the parent dictionary containing key None on Faliure'''
1606+ if key in dic.keys():
1607+ return dic
1608+ for k in dic.keys():
1609+ if type(dic[k]) == type([]):
1610+ for i in dic[k]:
1611+ if type(i) == type({}):
1612+ ret = self.search_dic(i, key)
1613+ if ret and key in ret.keys():
1614+ return ret
1615+ return None
1616+
1617+ def _clean_string(self, text):
1618+ lis = ['\t', '\n']
1619+ if type(text) != type(''):
1620+ text = str(text)
1621+ for t in lis:
1622+ text = text.replace(t, '')
1623+ return text
1624+
1625+ def _setparameter(self, dic, key, value):
1626+ ''' Used to input parameters to corresponding dictionary'''
1627+ if key == None or value == None :
1628+ return
1629+ if type(value) == type(''):
1630+ dic[key] = value.strip()
1631+ else:
1632+ dic[key] = value
1633+
1634+ def createCustomerPaymentProfile(self, dic):
1635+ '''Creates PaymentProfile for Customer and returns the PaymentProfile id on success returns None or faliure '''
1636+ KEYS = dic.keys()
1637+ doc1 = Document()
1638+ url_path = dic.get('url_extension', False)
1639+ url = dic.get('url', False)
1640+ xsd = dic.get('xsd', False)
1641+
1642+ createCustomerPaymentProfileRequest = doc1.createElement("createCustomerPaymentProfileRequest")
1643+ createCustomerPaymentProfileRequest.setAttribute("xmlns", "AnetApi/xml/v1/schema/AnetApiSchema.xsd")
1644+ doc1.appendChild(createCustomerPaymentProfileRequest)
1645+
1646+ merchantAuthentication = doc1.createElement("merchantAuthentication")
1647+ createCustomerPaymentProfileRequest.appendChild(merchantAuthentication)
1648+
1649+ name = doc1.createElement("name")
1650+ merchantAuthentication.appendChild(name)
1651+
1652+ transactionKey = doc1.createElement("transactionKey")
1653+ merchantAuthentication.appendChild(transactionKey)
1654+
1655+ ##Create the Request for creating the customer profile
1656+ if 'api_login_id' in KEYS and 'transaction_key' in KEYS:
1657+
1658+ ptext1 = doc1.createTextNode(self._clean_string(dic['api_login_id']))
1659+ name.appendChild(ptext1)
1660+
1661+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['transaction_key'])))
1662+ transactionKey.appendChild(ptext)
1663+
1664+ if 'customerProfileId' in KEYS:
1665+ customerProfileId = doc1.createElement("customerProfileId")
1666+ createCustomerPaymentProfileRequest.appendChild(customerProfileId)
1667+ ptext = doc1.createTextNode(self._clean_string(dic['customerProfileId']))
1668+ customerProfileId.appendChild(ptext)
1669+
1670+ paymentProfile = doc1.createElement("paymentProfile")
1671+ createCustomerPaymentProfileRequest.appendChild(paymentProfile)
1672+ if 'customerType' in KEYS:
1673+ customerType = doc1.createElement("customerType")
1674+ paymentProfile.appendChild(customerType)
1675+
1676+ billTo = doc1.createElement("billTo")
1677+ paymentProfile.appendChild(billTo)
1678+ if 'firstName' in KEYS:
1679+ firstName = doc1.createElement("firstName")
1680+ billTo.appendChild(firstName)
1681+ ptext = doc1.createTextNode(self._clean_string(dic['firstName']))
1682+ firstName.appendChild(ptext)
1683+
1684+ if 'lastName' in KEYS:
1685+ lastName = doc1.createElement("lastName")
1686+ billTo.appendChild(lastName)
1687+ ptext = doc1.createTextNode(self._clean_string(dic['lastName']))
1688+ lastName.appendChild(ptext)
1689+
1690+ if 'company' in KEYS:
1691+ company = doc1.createElement("company")
1692+ billTo.appendChild(companycompany)
1693+ ptext = doc1.createTextNode(self._clean_string(dic['company']))
1694+ company.appendChild(ptext)
1695+
1696+ if 'address' in KEYS:
1697+ address = doc1.createElement("address")
1698+ billTo.appendChild(address)
1699+ ptext = doc1.createTextNode(self._clean_string(dic['address']))
1700+ address.appendChild(ptext)
1701+
1702+ ##State code must be given here
1703+ if 'state' in KEYS:
1704+ state = doc1.createElement("state")
1705+ billTo.appendChild(state)
1706+ ptext = doc1.createTextNode(self._clean_string(dic['state']))
1707+ state.appendChild(ptext)
1708+
1709+ if 'city' in KEYS:
1710+ city = doc1.createElement("city")
1711+ billTo.appendChild(city)
1712+ ptext = doc1.createTextNode(self._clean_string(dic['city']))
1713+ city.appendChild(ptext)
1714+
1715+ if 'zip' in KEYS:
1716+ zip = doc1.createElement("zip")
1717+ billTo.appendChild(zip)
1718+ ptext = doc1.createTextNode(self._clean_string(dic['zip']))
1719+ zip.appendChild(ptext)
1720+
1721+ if 'country' in KEYS:
1722+ country = doc1.createElement("country")
1723+ billTo.appendChild(country)
1724+ ptext = doc1.createTextNode(self._clean_string(dic['country']))
1725+ country.appendChild(ptext)
1726+
1727+ if 'phoneNumber' in KEYS:
1728+ phoneNumber = doc1.createElement("phoneNumber")
1729+ billTo.appendChild(phoneNumber)
1730+ ptext = doc1.createTextNode(self._clean_string(dic['phoneNumber']))
1731+ phoneNumber.appendChild(ptext)
1732+
1733+ if 'faxNumber' in KEYS:
1734+ faxNumber = doc1.createElement("faxNumber")
1735+ billTo.appendChild(faxNumber)
1736+ ptext = doc1.createTextNode(self._clean_string(dic['faxNumber']))
1737+ faxNumber.appendChild(ptext)
1738+
1739+ payment = doc1.createElement("payment")
1740+ paymentProfile.appendChild(payment)
1741+
1742+ if 'cardNumber' in KEYS and 'expirationDate' in KEYS:
1743+ creditCard = doc1.createElement("creditCard")
1744+ payment.appendChild(creditCard)
1745+
1746+ cardNumber = doc1.createElement("cardNumber")
1747+ creditCard.appendChild(cardNumber)
1748+ ptext = doc1.createTextNode(dic['cardNumber'])
1749+ cardNumber.appendChild(ptext)
1750+
1751+ expirationDate = doc1.createElement("expirationDate")
1752+ creditCard.appendChild(expirationDate)
1753+ ptext = doc1.createTextNode(dic['expirationDate'])
1754+ expirationDate.appendChild(ptext)
1755+
1756+ if 'cardCode' in KEYS:
1757+ cardCode = doc1.createElement("cardCode")
1758+ creditCard.appendChild(cardCode)
1759+ ptext = doc1.createTextNode(self._clean_string(dic['cardCode']))
1760+ cardCode .appendChild(ptext)
1761+ if 'bankAccount' in KEYS:
1762+ bankAccount = doc1.createElement("bankAccount")
1763+ creditCard.appendChild(bankAccount)
1764+ ptext = doc1.createTextNode(self._clean_string(dic['bankAccount']))
1765+ bankAccount .appendChild(ptext)
1766+
1767+ if 'validationMode' in KEYS:
1768+ validationMode = doc1.createElement("validationMode")
1769+ createCustomerPaymentProfileRequest.appendChild(validationMode)
1770+
1771+ Request_string = xml = doc1.toxml(encoding="utf-8")
1772+ #Select from production and test server
1773+
1774+ create_CustomerPaymentProfile_response_xml = self.request_to_server(Request_string, url, url_path)
1775+ create_CustomerPaymentProfile_response_dictionary = xml2dic.main(create_CustomerPaymentProfile_response_xml)
1776+ parent_resultCode = self.search_dic(create_CustomerPaymentProfile_response_dictionary, 'resultCode')
1777+ if parent_resultCode:
1778+ if parent_resultCode['resultCode'] == 'Ok':
1779+ parent_customerPaymentProfileId = self.search_dic(create_CustomerPaymentProfile_response_dictionary, 'customerPaymentProfileId')
1780+ return parent_customerPaymentProfileId['customerPaymentProfileId']
1781+ else:
1782+ ret = {}
1783+ Error_Code_dic = self.search_dic(create_CustomerPaymentProfile_response_dictionary, 'code')
1784+ if Error_Code_dic.get('code'):
1785+ ret['Error_Code'] = Error_Code_dic['code']
1786+ Error_message_dic = self.search_dic(create_CustomerPaymentProfile_response_dictionary, 'text')
1787+ if Error_message_dic.get('text'):
1788+ ret['Error_Message'] = Error_message_dic['text']
1789+ return ret
1790+
1791+ def create_payment_profile(self, cr, uid, ids, context=None):
1792+ """
1793+ Create new payment profile for the customer.
1794+ """
1795+ parent_model = context.get('active_model')
1796+ parent_id = context.get('active_id')
1797+ partner_obj = self.pool.get('res.partner')
1798+ if parent_model == 'res.partner':
1799+ partner = self.pool.get(parent_model).browse(cr, uid, parent_id)
1800+ partner_id = parent_id
1801+ else:
1802+ partner = self.pool.get(parent_model).browse(cr, uid, parent_id).partner_id
1803+ partner_id = partner.id
1804+ data = self.pool.get('create.payment.profile').browse(cr, uid, ids[0])
1805+ if data and data.address_id:
1806+ addr_id = data.address_id.id
1807+ else:
1808+ address = partner_obj.address_get(cr, uid, [partner.id], ['invoice'])
1809+ address = self.pool.get('res.partner.address').browse(cr, uid, address['invoice'])
1810+ addr_id = address.id
1811+
1812+ if not partner.payment_profile_id:
1813+ prof_id = partner_obj.create_cust_profile(cr, uid, [partner.id], address_id=addr_id)
1814+ else:
1815+ prof_id = partner.payment_profile_id.name
1816+
1817+ cardNumber = data.cc_number or ''
1818+ cardCode = data.cc_verify_code or ''
1819+ description = data.description or ''
1820+
1821+ expirationDate = data.cc_ed_year + '-' + data.cc_ed_month
1822+
1823+ Param_Dic = {}
1824+ email = ''
1825+ merchantCustomerId = ''
1826+ description = ''
1827+
1828+ Trans_key = partner.company_id.auth_config_id.transaction_key
1829+ Login_id = partner.company_id.auth_config_id.login_id
1830+ url_extension = partner.company_id.auth_config_id.url_extension
1831+ xsd = partner.company_id.auth_config_id.xsd_link
1832+ description += (partner.ref or '') + (partner.name or '')
1833+
1834+ if partner.company_id.auth_config_id.test_mode:
1835+ url = partner.company_id.auth_config_id.url_test
1836+ else:
1837+ url = partner.company_id.auth_config_id.url
1838+
1839+
1840+ if Trans_key and Login_id:
1841+ self._setparameter(Param_Dic, 'api_login_id', Login_id)
1842+ self._setparameter(Param_Dic, 'transaction_key', Trans_key)
1843+
1844+ if url:
1845+ self._setparameter(Param_Dic, 'url', url)
1846+ self._setparameter(Param_Dic, 'url_extension', url_extension)
1847+ if xsd:
1848+ self._setparameter(Param_Dic, 'xsd', xsd)
1849+ self._setparameter(Param_Dic, 'cardNumber', cardNumber)
1850+ self._setparameter(Param_Dic, 'expirationDate', expirationDate)
1851+ if cardCode:
1852+ self._setparameter(Param_Dic, 'cardCode', cardCode)
1853+ self._setparameter(Param_Dic, 'customerProfileId', prof_id)
1854+ self._setparameter(Param_Dic, 'description', description)
1855+
1856+ Customer_Payment_Profile_ID = self.createCustomerPaymentProfile(Param_Dic)
1857+ cust_prof_id = self.pool.get('cust.profile').search(cr, uid, [('name', '=', prof_id)])
1858+ if len(cust_prof_id) > 0 and Customer_Payment_Profile_ID and type(Customer_Payment_Profile_ID) != type({}):
1859+ cust_prof_id = self.pool.get('cust.payment.profile').create(cr, uid, {'name':Customer_Payment_Profile_ID,
1860+ 'cust_profile_id':cust_prof_id[0],
1861+ 'address_id':addr_id,
1862+ 'partner_id':partner_id,
1863+ })
1864+ return {}
1865+
1866+create_payment_profile()
1867+
1868+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1869
1870=== added file 'account_payment_cim_authdotnet/wizard/create_payment_profile_view.xml'
1871--- account_payment_cim_authdotnet/wizard/create_payment_profile_view.xml 1970-01-01 00:00:00 +0000
1872+++ account_payment_cim_authdotnet/wizard/create_payment_profile_view.xml 2012-08-24 15:52:25 +0000
1873@@ -0,0 +1,42 @@
1874+<?xml version="1.0" encoding="utf-8"?>
1875+<openerp>
1876+ <data>
1877+
1878+ <record id="create_payment_profile_view" model="ir.ui.view">
1879+ <field name="name">create.payment.profile.form</field>
1880+ <field name="model">create.payment.profile</field>
1881+ <field name="type">form</field>
1882+ <field name="arch" type="xml">
1883+ <form string="Payment Profile">
1884+ <group colspan="2" col="4">
1885+ <field name="cc_number" />
1886+ <field name="cc_ed_month" />
1887+ <field name="cc_ed_year" />
1888+ <field name="cc_verify_code" />
1889+ <field name="partner_id" invisible="1" />
1890+ <field name="description" />
1891+ <field name="address_id" domain="[('partner_id','=',partner_id)]"/>
1892+ <!--button name="button_install" states="uninstalled" string="Schedule for Installation" icon="terp-gtk-jump-to-ltr" type="object"/-->
1893+
1894+ </group>
1895+ <newline/>
1896+ <group colspan="2" col="4">
1897+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
1898+ <button name="create_payment_profile" string="Create Payment Profile" type="object" icon="gtk-ok" default_focus="1"/>
1899+ </group>
1900+ </form>
1901+ </field>
1902+ </record>
1903+
1904+ <record id="action_create_payment_profile" model="ir.actions.act_window">
1905+ <field name="name">Payment Profile</field>
1906+ <field name="type">ir.actions.act_window</field>
1907+ <field name="res_model">create.payment.profile</field>
1908+ <field name="view_type">form</field>
1909+ <field name="view_mode">form</field>
1910+ <field name="view_id" ref="create_payment_profile_view"/>
1911+ <field name="target">new</field>
1912+ </record>
1913+
1914+ </data>
1915+</openerp>
1916
1917=== added file 'account_payment_cim_authdotnet/wizard/delete_payment_profile.py'
1918--- account_payment_cim_authdotnet/wizard/delete_payment_profile.py 1970-01-01 00:00:00 +0000
1919+++ account_payment_cim_authdotnet/wizard/delete_payment_profile.py 2012-08-24 15:52:25 +0000
1920@@ -0,0 +1,190 @@
1921+# -*- coding: utf-8 -*-
1922+##############################################################################
1923+#
1924+# OpenERP, Open Source Management Solution
1925+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
1926+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
1927+#
1928+# This program is free software: you can redistribute it and/or modify
1929+# it under the terms of the GNU General Public License as published by
1930+# the Free Software Foundation, either version 3 of the License, or
1931+# (at your option) any later version.
1932+#
1933+# This program is distributed in the hope that it will be useful,
1934+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1935+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1936+# GNU General Public License for more details.
1937+#
1938+# You should have received a copy of the GNU General Public License
1939+# along with this program. If not, see <http://www.gnu.org/licenses/>
1940+#
1941+##############################################################################
1942+
1943+from osv import fields, osv
1944+from xml.dom.minidom import Document
1945+import xml2dic
1946+from tools.translate import _
1947+
1948+class delete_payment_profile(osv.osv_memory):
1949+ _name = 'delete.payment.profile'
1950+ _description = 'Delete Payment Profile'
1951+
1952+ def request_to_server(self, Request_string, url, url_path):
1953+ ''' Sends a POST request to url and returns the response from the server'''
1954+
1955+ conn = httplib.HTTPSConnection(url)
1956+ conn.putrequest('POST', url_path)
1957+ conn.putheader('content-type', 'text/xml')
1958+ conn.putheader('content-length', len(Request_string))
1959+ conn.endheaders()
1960+ conn.send(Request_string)
1961+ response = conn.getresponse()
1962+ create_CustomerProfile_response_xml = response.read()
1963+ return create_CustomerProfile_response_xml
1964+
1965+ def search_dic(self, dic, key):
1966+ ''' Returns the parent dictionary containing key None on Faliure'''
1967+ if key in dic.keys():
1968+ return dic
1969+ for k in dic.keys():
1970+ if type(dic[k]) == type([]):
1971+ for i in dic[k]:
1972+ if type(i) == type({}):
1973+ ret = self.search_dic(i, key)
1974+ if ret and key in ret.keys():
1975+ return ret
1976+ return None
1977+
1978+ def _clean_string(self, text):
1979+ lis = ['\t', '\n']
1980+ if type(text) != type(''):
1981+ text = str(text)
1982+ for t in lis:
1983+ text = text.replace(t, '')
1984+ return text
1985+
1986+ def _setparameter(self, dic, key, value):
1987+ ''' Used to input parameters to corresponding dictionary'''
1988+ if key == None or value == None :
1989+ return
1990+ if type(value) == type(''):
1991+ dic[key] = value.strip()
1992+ else:
1993+ dic[key] = value
1994+
1995+ def deleteCustomerPaymentProfile(self, dic):
1996+ KEYS = dic.keys()
1997+ doc1 = Document()
1998+ url_path = dic.get('url_extension', False)
1999+ url = dic.get('url', False)
2000+ xsd = dic.get('xsd', False)
2001+
2002+ deleteCustomerPaymentProfileRequest = doc1.createElement("deleteCustomerPaymentProfileRequest")
2003+ deleteCustomerPaymentProfileRequest.setAttribute("xmlns", xsd)
2004+ doc1.appendChild(deleteCustomerPaymentProfileRequest)
2005+
2006+ merchantAuthentication = doc1.createElement("merchantAuthentication")
2007+ deleteCustomerPaymentProfileRequest.appendChild(merchantAuthentication)
2008+
2009+ name = doc1.createElement("name")
2010+ merchantAuthentication.appendChild(name)
2011+
2012+ transactionKey = doc1.createElement("transactionKey")
2013+ merchantAuthentication.appendChild(transactionKey)
2014+
2015+ ##Create the Request for creating the customer profile
2016+ if 'api_login_id' in KEYS and 'transaction_key' in KEYS:
2017+
2018+ ptext1 = doc1.createTextNode(self._clean_string(dic['api_login_id']))
2019+ name.appendChild(ptext1)
2020+
2021+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['transaction_key'])))
2022+ transactionKey.appendChild(ptext)
2023+
2024+ if 'customerProfileId' in KEYS:
2025+ customerProfileId = doc1.createElement("customerProfileId")
2026+ deleteCustomerPaymentProfileRequest.appendChild(customerProfileId)
2027+ ptext = doc1.createTextNode(self._clean_string(dic['customerProfileId']))
2028+ customerProfileId.appendChild(ptext)
2029+
2030+ if 'customerPaymentProfileId' in KEYS:
2031+ customerPaymentProfileId = doc1.createElement("customerPaymentProfileId")
2032+ deleteCustomerPaymentProfileRequest.appendChild(customerPaymentProfileId)
2033+ ptext = doc1.createTextNode(self._clean_string(dic['customerPaymentProfileId']))
2034+ customerPaymentProfileId.appendChild(ptext)
2035+
2036+ Request_string = doc1.toxml(encoding="utf-8")
2037+ delete_CustomerPaymentProfile_response_xml = self.request_to_server(Request_string, url, url_path)
2038+ delete_CustomerPaymentProfile_response_dictionary = xml2dic.main(delete_CustomerPaymentProfile_response_xml)
2039+ parent_resultCode = self.search_dic(delete_CustomerPaymentProfile_response_dictionary, 'resultCode')
2040+ if parent_resultCode:
2041+ if parent_resultCode['resultCode'] == 'Ok':
2042+ return True
2043+ ret = {}
2044+ Error_Code_dic = self.search_dic(delete_CustomerPaymentProfile_response_dictionary, 'code')
2045+ if Error_Code_dic.get('code'):
2046+ ret['Error_Code'] = Error_Code_dic['code']
2047+ Error_message_dic = self.search_dic(delete_CustomerPaymentProfile_response_dictionary, 'text')
2048+ if Error_message_dic.get('text'):
2049+ ret['Error_Message'] = Error_message_dic['text']
2050+ return ret
2051+ return
2052+
2053+ def del_pay_profile(self, cr, uid, ids, context=None):
2054+ Param_Dic = {}
2055+ parent_model = context.get('active_model')
2056+ parent_id = context.get('active_id')
2057+ if parent_model == 'res.partner':
2058+ partner = self.pool.get(parent_model).browse(cr, uid, parent_id)
2059+ else:
2060+ parent_model_obj = self.pool.get(parent_model).browse(cr, uid, parent_id)
2061+ partner = parent_model_obj.address_id.partner_id
2062+
2063+ data = self.pool.get('delete.payment.profile').browse(cr, uid, ids[0])
2064+
2065+ Trans_key = partner.company_id.auth_config_id.transaction_key
2066+ Login_id = partner.company_id.auth_config_id.login_id
2067+ url_extension = partner.company_id.auth_config_id.url_extension
2068+ xsd = partner.company_id.auth_config_id.xsd_link
2069+ prof_id = partner.payment_profile_id.name
2070+ customerPaymentProfileId = data.payment_profile_id.name
2071+ if partner.company_id.auth_config_id.test_mode:
2072+ url = partner.company_id.auth_config_id.url_test
2073+ else:
2074+ url = partner.company_id.auth_config_id.url
2075+
2076+ if Trans_key and Login_id:
2077+ self._setparameter(Param_Dic, 'api_login_id', Login_id)
2078+ self._setparameter(Param_Dic, 'transaction_key', Trans_key)
2079+
2080+ if url:
2081+ self._setparameter(Param_Dic, 'url', url)
2082+ self._setparameter(Param_Dic, 'url_extension', url_extension)
2083+ if xsd:
2084+ self._setparameter(Param_Dic, 'xsd', xsd)
2085+
2086+ self._setparameter(Param_Dic, 'customerProfileId', prof_id)
2087+ self._setparameter(Param_Dic, 'customerPaymentProfileId', customerPaymentProfileId)
2088+
2089+ Customer_Payment_Profile_ID = self.deleteCustomerPaymentProfile(Param_Dic)
2090+ self.pool.get('cust.payment.profile').unlink(cr, uid, data.payment_profile_id.id)
2091+ if not Customer_Payment_Profile_ID or type(Customer_Payment_Profile_ID) == type({}):
2092+ raise osv.except_osv(_('Transaction Error'), _('Error code : ' + Customer_Payment_Profile_ID.get('Error_Message') or '' + '\nError Message :' + Customer_Payment_Profile_ID.get('Error_Message') or ''))
2093+
2094+ return{}
2095+
2096+ def _get_profile_id(self, cr, uid, context=None):
2097+ if context is None:
2098+ context = {}
2099+ if context.get('active_model') == 'cust.payment.profile':
2100+ return context.get('active_id')
2101+ return None
2102+
2103+ _columns = {
2104+ 'payment_profile_id':fields.many2one('cust.payment.profile', 'Payment Profile', required=True),
2105+ }
2106+ _defaults = {
2107+ 'payment_profile_id':_get_profile_id
2108+ }
2109+
2110+delete_payment_profile()
2111
2112=== added file 'account_payment_cim_authdotnet/wizard/delete_payment_profile_view.xml'
2113--- account_payment_cim_authdotnet/wizard/delete_payment_profile_view.xml 1970-01-01 00:00:00 +0000
2114+++ account_payment_cim_authdotnet/wizard/delete_payment_profile_view.xml 2012-08-24 15:52:25 +0000
2115@@ -0,0 +1,33 @@
2116+<?xml version="1.0" encoding="utf-8"?>
2117+<openerp>
2118+ <data>
2119+ <record id="delete_payment_profile_form_view" model="ir.ui.view">
2120+ <field name="name">delete_payment_profile_form_view</field>
2121+ <field name="model">delete.payment.profile</field>
2122+ <field name="type">form</field>
2123+ <field name="arch" type="xml" >
2124+ <form string="Delete Payment Profile">
2125+ <field name="payment_profile_id" attrs="{'readonly':[('payment_profile_id','!=',None)]}"/>
2126+
2127+ <group colspan="2" col="4">
2128+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
2129+ <button name="del_pay_profile" string="Delete" type="object" icon="gtk-ok" default_focus="1" />
2130+ </group>
2131+ </form>
2132+ </field>
2133+ </record>
2134+
2135+
2136+ <record id="action_delete_payment_profile" model="ir.actions.act_window">
2137+ <field name="name">Delete Payment Profile</field>
2138+ <field name="type">ir.actions.act_window</field>
2139+ <field name="res_model">delete.payment.profile</field>
2140+ <field name="view_type">form</field>
2141+ <field name="view_mode">form</field>
2142+ <field name="view_id" ref="delete_payment_profile_form_view"/>
2143+ <field name="target">new</field>
2144+ </record>
2145+
2146+
2147+ </data>
2148+</openerp>
2149\ No newline at end of file
2150
2151=== added file 'account_payment_cim_authdotnet/wizard/edit_payment_profile.py'
2152--- account_payment_cim_authdotnet/wizard/edit_payment_profile.py 1970-01-01 00:00:00 +0000
2153+++ account_payment_cim_authdotnet/wizard/edit_payment_profile.py 2012-08-24 15:52:25 +0000
2154@@ -0,0 +1,422 @@
2155+# -*- coding: utf-8 -*-
2156+##############################################################################
2157+#
2158+# OpenERP, Open Source Management Solution
2159+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
2160+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
2161+#
2162+# This program is free software: you can redistribute it and/or modify
2163+# it under the terms of the GNU General Public License as published by
2164+# the Free Software Foundation, either version 3 of the License, or
2165+# (at your option) any later version.
2166+#
2167+# This program is distributed in the hope that it will be useful,
2168+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2169+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2170+# GNU General Public License for more details.
2171+#
2172+# You should have received a copy of the GNU General Public License
2173+# along with this program. If not, see <http://www.gnu.org/licenses/>
2174+#
2175+##############################################################################
2176+
2177+from osv import fields, osv
2178+import httplib
2179+from xml.dom.minidom import Document
2180+import xml2dic
2181+from tools.translate import _
2182+
2183+class edit_payment_profile(osv.osv_memory):
2184+ _name = 'edit.payment.profile'
2185+ _description = 'Edit Payment Profile'
2186+
2187+ def _get_partner(self, cr, uid, context=None):
2188+ if context is None:
2189+ context = {}
2190+ return context.get('active_id', False)
2191+
2192+ def _get_state(self, cr, uid, context=None):
2193+ if context.get('active_model', False) == 'cust.payment.profile':
2194+ return 'preprocessing'
2195+ return 'draft'
2196+
2197+ def _get_profile_id(self, cr, uid, context=None):
2198+ if context is None:
2199+ context = {}
2200+ if context['active_model'] == 'cust.payment.profile':
2201+ return context.get('active_id')
2202+ return None
2203+
2204+ _columns = {
2205+ 'payment_profile_id':fields.many2one('cust.payment.profile', 'Payment Profile', required=True),
2206+ 'partner_id':fields.many2one('res.partner', 'Customer', required=True),
2207+ 'cc_number':fields.char('Credit Card Number', size=32),
2208+ 'cc_ed_month':fields.char('Expiration Date MM', size=32),
2209+ 'cc_ed_year':fields.char('Expiration Date YYYY', size=32),
2210+ 'cc_code':fields.char('Card Code', size=32),
2211+ 'state':fields.selection(
2212+ [('draft', 'Draft'),
2213+ ('done', 'Done'),
2214+ ('processing', 'Processing'),
2215+ ('preprocessing', 'PreProcessing'),
2216+ ], 'State', readonly=True, size=32)
2217+ }
2218+
2219+ _defaults = {
2220+ 'partner_id': _get_partner,
2221+ 'state':_get_state,
2222+ 'payment_profile_id':_get_profile_id
2223+ }
2224+
2225+ def getCustomerPaymentProfileRequest(self, dic):
2226+ profile_dictionary = dic
2227+ KEYS = dic.keys()
2228+ Payment_Profile_Details = {}
2229+
2230+ doc1 = Document()
2231+ url_path = dic.get('url_extension')
2232+ url = dic.get('url')
2233+ xsd = dic.get('xsd')
2234+
2235+ getCustomerPaymentProfileRequest = doc1.createElement("getCustomerPaymentProfileRequest")
2236+ getCustomerPaymentProfileRequest.setAttribute("xmlns", xsd)
2237+ doc1.appendChild(getCustomerPaymentProfileRequest)
2238+
2239+ merchantAuthentication = doc1.createElement("merchantAuthentication")
2240+ getCustomerPaymentProfileRequest.appendChild(merchantAuthentication)
2241+
2242+ name = doc1.createElement("name")
2243+ merchantAuthentication.appendChild(name)
2244+
2245+ transactionKey = doc1.createElement("transactionKey")
2246+ merchantAuthentication.appendChild(transactionKey)
2247+
2248+ ##Create the Request for creating the customer profile
2249+ if 'api_login_id' in KEYS and 'transaction_key' in KEYS:
2250+
2251+ ptext1 = doc1.createTextNode(self._clean_string(dic['api_login_id']))
2252+ name.appendChild(ptext1)
2253+
2254+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['transaction_key'])))
2255+ transactionKey.appendChild(ptext)
2256+
2257+ customerProfileId = doc1.createElement("customerProfileId")
2258+ getCustomerPaymentProfileRequest.appendChild(customerProfileId)
2259+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['customerProfileId'])))
2260+ customerProfileId.appendChild(ptext)
2261+
2262+ customerPaymentProfileId = doc1.createElement("customerPaymentProfileId")
2263+ getCustomerPaymentProfileRequest.appendChild(customerPaymentProfileId)
2264+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['customerPaymentProfileId'])))
2265+ customerPaymentProfileId.appendChild(ptext)
2266+
2267+ Request_string = xml = doc1.toxml(encoding="utf-8")
2268+ get_transaction_response_xml = self.request_to_server(Request_string, url, url_path)
2269+ get_PaymentProfile_response_dictionary = xml2dic.main(get_transaction_response_xml)
2270+
2271+ parent_card_number = self.search_dic(get_PaymentProfile_response_dictionary, 'cardNumber')
2272+ parent_exp_date = self.search_dic(get_PaymentProfile_response_dictionary, 'expirationDate')
2273+
2274+ if parent_card_number.get('cardNumber'):
2275+ Payment_Profile_Details['cc_number'] = parent_card_number['cardNumber']
2276+
2277+ if parent_exp_date.get('expirationDate'):
2278+ Payment_Profile_Details['cc_ed_year'] = parent_exp_date['expirationDate']
2279+
2280+ if parent_exp_date.get('cardCode'):
2281+ Payment_Profile_Details['cardCode'] = parent_exp_date['cardCode']
2282+
2283+ return Payment_Profile_Details
2284+
2285+ def request_to_server(self, Request_string, url, url_path):
2286+ ''' Sends a POST request to url and returns the response from the server'''
2287+
2288+ conn = httplib.HTTPSConnection(url)
2289+ conn.putrequest('POST', url_path)
2290+ conn.putheader('content-type', 'text/xml')
2291+ conn.putheader('content-length', len(Request_string))
2292+ conn.endheaders()
2293+ conn.send(Request_string)
2294+ response = conn.getresponse()
2295+ create_CustomerProfile_response_xml = response.read()
2296+ return create_CustomerProfile_response_xml
2297+
2298+ def search_dic(self, dic, key):
2299+ ''' Returns the parent dictionary containing key None on Faliure'''
2300+ if key in dic.keys():
2301+ return dic
2302+ for k in dic.keys():
2303+ if type(dic[k]) == type([]):
2304+ for i in dic[k]:
2305+ if type(i) == type({}):
2306+ ret = self.search_dic(i, key)
2307+ if ret and key in ret.keys():
2308+ return ret
2309+ return None
2310+
2311+ def _clean_string(self, text):
2312+ lis = ['\t', '\n']
2313+ if type(text) != type(''):
2314+ text = str(text)
2315+ for t in lis:
2316+ text = text.replace(t, '')
2317+ return text
2318+
2319+ def _setparameter(self, dic, key, value):
2320+ ''' Used to input parameters to corresponding dictionary'''
2321+ if key == None or value == None :
2322+ return
2323+ if type(value) == type(''):
2324+ dic[key] = value.strip()
2325+ else:
2326+ dic[key] = value
2327+
2328+ def get_payment_profile_info(self, cr, uid, ids, context=None):
2329+ Param_Dic = {}
2330+ parent_model = context.get('active_model')
2331+ parent_id = context.get('active_id')
2332+ data = self.browse(cr, uid, ids[0])
2333+ if parent_model == 'res.partner':
2334+ partner = self.pool.get(parent_model).browse(cr, uid, parent_id)
2335+ else:
2336+ parent_model_obj = self.pool.get(parent_model).browse(cr, uid, parent_id)
2337+ partner = parent_model_obj.address_id.partner_id
2338+
2339+ customerPaymentProfileId = data.payment_profile_id.name
2340+
2341+ Customer_Profile_ID = partner.payment_profile_id.name
2342+
2343+ Trans_key = partner.company_id.auth_config_id.transaction_key
2344+ Login_id = partner.company_id.auth_config_id.login_id
2345+ url_extension = partner.company_id.auth_config_id.url_extension
2346+ xsd = partner.company_id.auth_config_id.xsd_link
2347+ if partner.company_id.auth_config_id.test_mode:
2348+ url = partner.company_id.auth_config_id.url_test
2349+ else:
2350+ url = partner.company_id.auth_config_id.url
2351+
2352+ if Trans_key and Login_id:
2353+ self._setparameter(Param_Dic, 'api_login_id', Login_id)
2354+ self._setparameter(Param_Dic, 'transaction_key', Trans_key)
2355+
2356+ if url:
2357+ self._setparameter(Param_Dic, 'url', url)
2358+ self._setparameter(Param_Dic, 'url_extension', url_extension)
2359+ if xsd:
2360+ self._setparameter(Param_Dic, 'xsd', xsd)
2361+
2362+ self._setparameter(Param_Dic, 'customerProfileId', Customer_Profile_ID)
2363+ self._setparameter(Param_Dic, 'customerPaymentProfileId', customerPaymentProfileId)
2364+
2365+
2366+ existing_profile = self.getCustomerPaymentProfileRequest(Param_Dic)
2367+ existing_profile['state'] = 'processing'
2368+ self.write(cr, uid, ids, existing_profile)
2369+ return True
2370+
2371+ def updateCustomerPaymentProfile(self, dic):
2372+ KEYS = dic.keys()
2373+ doc1 = Document()
2374+ url_path = dic['url_extension']
2375+ url = dic['url']
2376+ xsd = dic['xsd']
2377+
2378+ updateCustomerPaymentProfileResponse = doc1.createElement("updateCustomerPaymentProfileRequest")
2379+ updateCustomerPaymentProfileResponse.setAttribute("xmlns", xsd)
2380+ doc1.appendChild(updateCustomerPaymentProfileResponse)
2381+
2382+ merchantAuthentication = doc1.createElement("merchantAuthentication")
2383+ updateCustomerPaymentProfileResponse.appendChild(merchantAuthentication)
2384+
2385+ name = doc1.createElement("name")
2386+ merchantAuthentication.appendChild(name)
2387+
2388+ transactionKey = doc1.createElement("transactionKey")
2389+ merchantAuthentication.appendChild(transactionKey)
2390+
2391+ ##Create the Request for creating the customer profile
2392+ if 'api_login_id' in KEYS and 'transaction_key' in KEYS:
2393+
2394+ ptext1 = doc1.createTextNode(self._clean_string(dic['api_login_id']))
2395+ name.appendChild(ptext1)
2396+
2397+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['transaction_key'])))
2398+ transactionKey.appendChild(ptext)
2399+
2400+ if 'customerProfileId' in KEYS:
2401+ customerProfileId = doc1.createElement("customerProfileId")
2402+ updateCustomerPaymentProfileResponse.appendChild(customerProfileId)
2403+ ptext = doc1.createTextNode(self._clean_string(dic['customerProfileId']))
2404+ customerProfileId.appendChild(ptext)
2405+
2406+ paymentProfile = doc1.createElement("paymentProfile")
2407+ updateCustomerPaymentProfileResponse.appendChild(paymentProfile)
2408+ if 'customerType' in KEYS:
2409+ customerType = doc1.createElement("customerType")
2410+ paymentProfile.appendChild(customerType)
2411+
2412+ billTo = doc1.createElement("billTo")
2413+ paymentProfile.appendChild(billTo)
2414+ if 'firstName' in KEYS:
2415+ firstName = doc1.createElement("firstName")
2416+ billTo.appendChild(firstName)
2417+ ptext = doc1.createTextNode(self._clean_string(dic['firstName']))
2418+ firstName.appendChild(ptext)
2419+
2420+ if 'lastName' in KEYS:
2421+ lastName = doc1.createElement("lastName")
2422+ billTo.appendChild(lastName)
2423+ ptext = doc1.createTextNode(self._clean_string(dic['lastName']))
2424+ lastName.appendChild(ptext)
2425+
2426+ if 'company' in KEYS:
2427+ company = doc1.createElement("company")
2428+ billTo.appendChild(companycompany)
2429+ ptext = doc1.createTextNode(self._clean_string(dic['company']))
2430+ company.appendChild(ptext)
2431+
2432+ if 'address' in KEYS:
2433+ address = doc1.createElement("address")
2434+ billTo.appendChild(address)
2435+ ptext = doc1.createTextNode(self._clean_string(dic['address']))
2436+ address.appendChild(ptext)
2437+
2438+ ##State code must be given here
2439+ if 'state' in KEYS:
2440+ state = doc1.createElement("state")
2441+ billTo.appendChild(state)
2442+ ptext = doc1.createTextNode(self._clean_string(dic['state']))
2443+ state.appendChild(ptext)
2444+
2445+ if 'city' in KEYS:
2446+ city = doc1.createElement("city")
2447+ billTo.appendChild(city)
2448+ ptext = doc1.createTextNode(self._clean_string(dic['city']))
2449+ city.appendChild(ptext)
2450+
2451+ if 'zip' in KEYS:
2452+ zip = doc1.createElement("zip")
2453+ billTo.appendChild(zip)
2454+ ptext = doc1.createTextNode(self._clean_string(dic['zip']))
2455+ zip.appendChild(ptext)
2456+
2457+ if 'country' in KEYS:
2458+ country = doc1.createElement("country")
2459+ billTo.appendChild(country)
2460+ ptext = doc1.createTextNode(self._clean_string(dic['country']))
2461+ country.appendChild(ptext)
2462+
2463+ if 'phoneNumber' in KEYS:
2464+ phoneNumber = doc1.createElement("phoneNumber")
2465+ billTo.appendChild(phoneNumber)
2466+ ptext = doc1.createTextNode(self._clean_string(dic['phoneNumber']))
2467+ phoneNumber.appendChild(ptext)
2468+
2469+ if 'faxNumber' in KEYS:
2470+ faxNumber = doc1.createElement("faxNumber")
2471+ billTo.appendChild(faxNumber)
2472+ ptext = doc1.createTextNode(self._clean_string(dic['faxNumber']))
2473+ faxNumber.appendChild(ptext)
2474+
2475+ payment = doc1.createElement("payment")
2476+ paymentProfile.appendChild(payment)
2477+
2478+ if 'cardNumber' in KEYS and 'expirationDate' in KEYS:
2479+ creditCard = doc1.createElement("creditCard")
2480+ payment.appendChild(creditCard)
2481+
2482+ cardNumber = doc1.createElement("cardNumber")
2483+ creditCard.appendChild(cardNumber)
2484+ ptext = doc1.createTextNode(self._clean_string(dic['cardNumber']))
2485+ cardNumber.appendChild(ptext)
2486+
2487+ expirationDate = doc1.createElement("expirationDate")
2488+ creditCard.appendChild(expirationDate)
2489+ ptext = doc1.createTextNode(dic['expirationDate'])
2490+ expirationDate.appendChild(ptext)
2491+
2492+ if 'cardCode' in KEYS:
2493+ cardCode = doc1.createElement("cardCode")
2494+ creditCard.appendChild(cardCode)
2495+ ptext = doc1.createTextNode(self._clean_string(dic['cardCode']))
2496+ cardCode .appendChild(ptext)
2497+
2498+ customerPaymentProfileId = doc1.createElement("customerPaymentProfileId")
2499+ paymentProfile.appendChild(customerPaymentProfileId)
2500+ ptext = doc1.createTextNode(self._clean_string(dic['customerPaymentProfileId']))
2501+ customerPaymentProfileId .appendChild(ptext)
2502+
2503+ if 'validationMode' in KEYS:
2504+ validationMode = doc1.createElement("validationMode")
2505+ updateCustomerPaymentProfileResponse.appendChild(validationMode)
2506+ Request_string = doc1.toxml(encoding="utf-8")
2507+ update_CustomerPaymentProfile_response_xml = self.request_to_server(Request_string, url, url_path)
2508+ update_CustomerPaymentProfile_response_dictionary = xml2dic.main(update_CustomerPaymentProfile_response_xml)
2509+ parent_resultCode = self.search_dic(update_CustomerPaymentProfile_response_dictionary, 'resultCode')
2510+ if parent_resultCode:
2511+ if parent_resultCode['resultCode'] == 'Ok':
2512+ return True
2513+ else:
2514+ ret = {}
2515+ Error_Code_dic = self.search_dic(update_CustomerPaymentProfile_response_dictionary, 'code')
2516+ if Error_Code_dic.get('code'):
2517+ ret['Error_Code'] = Error_Code_dic['code']
2518+ Error_message_dic = self.search_dic(update_CustomerPaymentProfile_response_dictionary, 'text')
2519+ if Error_message_dic.get('text'):
2520+ ret['Error_Message'] = Error_message_dic['text']
2521+ return ret
2522+ return
2523+
2524+ def update_payment_profile_info(self, cr, uid, ids, context=None):
2525+ Param_Dic = {}
2526+ parent_model = context.get('active_model')
2527+ parent_id = context.get('active_id')
2528+ data = self.browse(cr, uid, ids[0])
2529+ if parent_model == 'res.partner':
2530+ partner = self.pool.get(parent_model).browse(cr, uid, parent_id)
2531+ else:
2532+ parent_model_obj = self.pool.get(parent_model).browse(cr, uid, parent_id)
2533+ partner = parent_model_obj.address_id.partner_id
2534+
2535+ cardNumber = data.cc_number or ''
2536+ expirationDate = ''
2537+ if data.cc_ed_year and data.cc_ed_month:
2538+ expirationDate = data.cc_ed_year + '-' + data.cc_ed_month
2539+ cardCode = data.cc_code or ''
2540+
2541+ Trans_key = partner.company_id.auth_config_id.transaction_key
2542+ Login_id = partner.company_id.auth_config_id.login_id
2543+ url_extension = partner.company_id.auth_config_id.url_extension
2544+ xsd = partner.company_id.auth_config_id.xsd_link
2545+ prof_id = partner.payment_profile_id.name
2546+ customerPaymentProfileId = data.payment_profile_id.name
2547+
2548+ if partner.company_id.auth_config_id.test_mode:
2549+ url = partner.company_id.auth_config_id.url_test
2550+ else:
2551+ url = partner.company_id.auth_config_id.url
2552+
2553+ if Trans_key and Login_id:
2554+ self._setparameter(Param_Dic, 'api_login_id', Login_id)
2555+ self._setparameter(Param_Dic, 'transaction_key', Trans_key)
2556+
2557+ if url:
2558+ self._setparameter(Param_Dic, 'url', url)
2559+ self._setparameter(Param_Dic, 'url_extension', url_extension)
2560+ if xsd:
2561+ self._setparameter(Param_Dic, 'xsd', xsd)
2562+
2563+ self._setparameter(Param_Dic, 'cardNumber', cardNumber)
2564+ self._setparameter(Param_Dic, 'expirationDate', expirationDate)
2565+ if cardCode:
2566+ self._setparameter(Param_Dic, 'cardCode', cardCode)
2567+ self._setparameter(Param_Dic, 'customerProfileId', prof_id)
2568+ self._setparameter(Param_Dic, 'customerPaymentProfileId', customerPaymentProfileId)
2569+
2570+ Customer_Payment_Profile_ID = self.updateCustomerPaymentProfile(Param_Dic)
2571+ if not Customer_Payment_Profile_ID or type(Customer_Payment_Profile_ID) == type({}):
2572+ raise osv.except_osv(_('Transaction Error'), _('Error code : ' + Customer_Payment_Profile_ID.get('Error_Message') or '' + '\nError Message :' + Customer_Payment_Profile_ID.get('Error_Message') or ''))
2573+
2574+ return{}
2575+
2576+edit_payment_profile()
2577
2578=== added file 'account_payment_cim_authdotnet/wizard/edit_payment_profile_view.xml'
2579--- account_payment_cim_authdotnet/wizard/edit_payment_profile_view.xml 1970-01-01 00:00:00 +0000
2580+++ account_payment_cim_authdotnet/wizard/edit_payment_profile_view.xml 2012-08-24 15:52:25 +0000
2581@@ -0,0 +1,39 @@
2582+<?xml version="1.0" encoding="utf-8"?>
2583+<openerp>
2584+ <data>
2585+ <record id="edit_payment_profile_form_view" model="ir.ui.view">
2586+ <field name="name">edit_payment_profile_form_view</field>
2587+ <field name="model">edit.payment.profile</field>
2588+ <field name="type">form</field>
2589+ <field name="arch" type="xml" >
2590+ <form string="Edit Payment Profile">
2591+ <field name="payment_profile_id" context="{'edit_payment_profile':'edit_payment_profile'}" attrs="{'readonly':[('state','=','preprocessing')]}"/>
2592+ <field name="cc_number" attrs="{'invisible':[('state','in',['draft','preprocessing'])]}"/>
2593+ <field name="cc_ed_year" attrs="{'invisible':[('state','in',['draft','preprocessing'])]}"/>
2594+ <field name="cc_ed_month" attrs="{'invisible':[('state','in',['draft','preprocessing'])]}"/>
2595+ <field name="cc_code" attrs="{'invisible':[('state','in',['draft','preprocessing'])]}"/>
2596+ <field name="state" invisible='1' />
2597+ <newline/>
2598+ <group colspan="2" col="4">
2599+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
2600+ <button name="get_payment_profile_info" string="Next" type="object" icon="gtk-ok" default_focus="1" attrs="{'invisible':[('state','in',['done','processing'])]}"/>
2601+ <button name="update_payment_profile_info" string="Update" type="object" icon="gtk-ok" default_focus="1" attrs="{'invisible':[('state','in',['draft','preprocessing'])]}"/>
2602+ </group>
2603+ </form>
2604+ </field>
2605+ </record>
2606+
2607+
2608+ <record id="action_edit_payment_profile" model="ir.actions.act_window">
2609+ <field name="name">Edit Payment Profile</field>
2610+ <field name="type">ir.actions.act_window</field>
2611+ <field name="res_model">edit.payment.profile</field>
2612+ <field name="view_type">form</field>
2613+ <field name="view_mode">form</field>
2614+ <field name="view_id" ref="edit_payment_profile_form_view"/>
2615+ <field name="target">new</field>
2616+ </record>
2617+
2618+
2619+ </data>
2620+</openerp>
2621
2622=== added file 'account_payment_cim_authdotnet/wizard/make_transaction.py'
2623--- account_payment_cim_authdotnet/wizard/make_transaction.py 1970-01-01 00:00:00 +0000
2624+++ account_payment_cim_authdotnet/wizard/make_transaction.py 2012-08-24 15:52:25 +0000
2625@@ -0,0 +1,399 @@
2626+# -*- coding: utf-8 -*-
2627+##############################################################################
2628+#
2629+# OpenERP, Open Source Management Solution
2630+# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
2631+# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
2632+#
2633+# This program is free software: you can redistribute it and/or modify
2634+# it under the terms of the GNU General Public License as published by
2635+# the Free Software Foundation, either version 3 of the License, or
2636+# (at your option) any later version.
2637+#
2638+# This program is distributed in the hope that it will be useful,
2639+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2640+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2641+# GNU General Public License for more details.
2642+#
2643+# You should have received a copy of the GNU General Public License
2644+# along with this program. If not, see <http://www.gnu.org/licenses/>
2645+#
2646+##############################################################################
2647+
2648+from osv import fields, osv
2649+import httplib
2650+from xml.dom.minidom import Document
2651+import xml2dic
2652+import time
2653+from tools.translate import _
2654+
2655+class make_transaction(osv.osv_memory):
2656+ _name = 'make.transaction'
2657+ _description = 'Make Transaction'
2658+
2659+ def onchange_trans_type(self, cr, uid, ids, trans_type, context=None):
2660+ res = {}
2661+ if trans_type in ['AuthOnly', 'AuthCapture', 'CaptureOnly']:
2662+ res['value'] = {'invisible': True}
2663+ else:
2664+ res['value'] = {'invisible': False}
2665+ return res
2666+
2667+ def _get_partner(self, cr, uid, context=None):
2668+ return context and context.get('partner_id') or False
2669+
2670+ def _get_profile(self, cr, uid, context=None):
2671+ return context and context.get('payment_profile_id') or False
2672+
2673+ _columns = {
2674+ 'amount':fields.integer('Amount', size=32, required=True),
2675+ 'trans_type': fields.selection([('AuthOnly', 'Authorization Only'),
2676+ ('AuthCapture', 'Authorization And Capture'),
2677+ ('CaptureOnly', 'Capture Only'),
2678+ ('PriorAuthCapture', 'Prior Authorization Capture'),
2679+ ('Refund', 'Credit/Refund'),
2680+ ('Void', 'Void'), ], 'Type', size=32, required=True),
2681+ 'partner_id':fields.many2one('res.partner', 'Customer', required=True),
2682+ 'payment_profile_id':fields.many2one('cust.payment.profile', 'Payment Profile', required=True),
2683+ 'trans_id':fields.many2one('transaction.history', 'Transaction ID'),
2684+ 'invisible':fields.boolean('invisible'),
2685+ }
2686+
2687+ _defaults = {
2688+ 'partner_id': _get_partner,
2689+ 'payment_profile_id':_get_profile
2690+ }
2691+
2692+ def createCustomerProfileTransactionRequest(self, dic):
2693+
2694+ ''' Creates the xml for TransactionRequest and returns the transaction id '''
2695+
2696+ profile_dictionary = dic
2697+ KEYS = dic.keys()
2698+
2699+ doc1 = Document()
2700+ url_path = dic.get('url_extension', False)
2701+ url = dic.get('url', False)
2702+ xsd = dic.get('xsd', False)
2703+ trans_type_list = ['AuthOnly', 'AuthCapture', 'CaptureOnly', 'PriorAuthCapture', 'Refund', ]
2704+
2705+ createCustomerProfileTransactionRequest = doc1.createElement("createCustomerProfileTransactionRequest")
2706+ createCustomerProfileTransactionRequest.setAttribute("xmlns", xsd)
2707+ doc1.appendChild(createCustomerProfileTransactionRequest)
2708+
2709+ merchantAuthentication = doc1.createElement("merchantAuthentication")
2710+ createCustomerProfileTransactionRequest.appendChild(merchantAuthentication)
2711+
2712+ name = doc1.createElement("name")
2713+ merchantAuthentication.appendChild(name)
2714+
2715+ transactionKey = doc1.createElement("transactionKey")
2716+ merchantAuthentication.appendChild(transactionKey)
2717+
2718+ ##Create the Request for creating the customer profile
2719+ if 'api_login_id' in KEYS and 'transaction_key' in KEYS:
2720+
2721+ ptext1 = doc1.createTextNode(self._clean_string(dic['api_login_id']))
2722+ name.appendChild(ptext1)
2723+
2724+ ptext = doc1.createTextNode(self._clean_string(self._clean_string(dic['transaction_key'])))
2725+ transactionKey.appendChild(ptext)
2726+
2727+ transaction = doc1.createElement("transaction")
2728+ createCustomerProfileTransactionRequest.appendChild(transaction)
2729+ if 'trans_type' in KEYS :
2730+ if profile_dictionary.get('trans_type') in trans_type_list:
2731+ transaction_type_tagname = 'profileTrans' + profile_dictionary.get('trans_type')
2732+ transaction_type = doc1.createElement(transaction_type_tagname)
2733+ transaction.appendChild(transaction_type)
2734+
2735+ if 'amount' in KEYS :
2736+ amount = doc1.createElement('amount')
2737+ transaction_type.appendChild(amount)
2738+ ptext = doc1.createTextNode(self._clean_string(dic.get('amount')))
2739+ amount.appendChild(ptext)
2740+
2741+ if 'tax_amount' in KEYS :
2742+ tax = doc1.createElement('tax')
2743+ transaction_type.appendChild(tax)
2744+
2745+ tax_amount = doc1.createElement('amount')
2746+ tax.appendChild(tax_amount)
2747+ ptext = doc1.createTextNode(self._clean_string(dic.get('tax_amount')))
2748+ tax_amount.appendChild(ptext)
2749+
2750+ tax_name = doc1.createElement('name')
2751+ tax.appendChild(tax_name)
2752+ ptext = doc1.createTextNode(self._clean_string(dic.get('tax_name')))
2753+ tax_name.appendChild(ptext)
2754+
2755+ tax_description = doc1.createElement('description')
2756+ tax.appendChild(tax_description)
2757+ ptext = doc1.createTextNode(self._clean_string(dic.get('tax_description')))
2758+ tax_description.appendChild(ptext)
2759+
2760+ if 'shipping_amount' in KEYS :
2761+ shipping = doc1.createElement('shipping')
2762+ transaction_type.appendChild(shipping)
2763+
2764+ shipping_amount = doc1.createElement('amount')
2765+ tax.appendChild(shipping_amount)
2766+ ptext = doc1.createTextNode(self._clean_string(dic.get('shipping_amount')))
2767+ shipping_amount.appendChild(ptext)
2768+
2769+ shipping_name = doc1.createElement('name')
2770+ tax.appendChild(shipping_name)
2771+ ptext = doc1.createTextNode(self._clean_string(dic.get('shipping_name')))
2772+ shipping_name.appendChild(ptext)
2773+
2774+ shipping_description = doc1.createElement('description')
2775+ tax.appendChild(shipping_description)
2776+ ptext = doc1.createTextNode(self._clean_string(dic.get('shipping_description')))
2777+ shipping_description.appendChild(ptext)
2778+
2779+ if 'duty_amount' in KEYS :
2780+ duty = doc1.createElement('duty')
2781+ transaction_type.appendChild(duty)
2782+
2783+ duty_amount = doc1.createElement('amount')
2784+ tax.appendChild(duty_amount)
2785+ ptext = doc1.createTextNode(self._clean_string(dic.get('duty_amount')))
2786+ duty_amount.appendChild(ptext)
2787+
2788+ duty_name = doc1.createElement('name')
2789+ tax.appendChild(duty_name)
2790+ ptext = doc1.createTextNode(self._clean_string(dic.get('duty_name')))
2791+ duty_name.appendChild(ptext)
2792+
2793+ duty_description = doc1.createElement('description')
2794+ tax.appendChild(duty_description)
2795+ ptext = doc1.createTextNode(self._clean_string(dic.get('duty_description')))
2796+ duty_description.appendChild(ptext)
2797+
2798+ if 'items'in KEYS and len(profile_dictionary['items']) > 0:
2799+ for i in range(0, len(profile_dictionary['items'])):
2800+ lineItems = doc1.createElement('lineItems')
2801+ transaction_type.appendChild(lineItems)
2802+
2803+ if 'itemId' in profile_dictionary['items'][i].keys():
2804+ itemId = doc1.createElement('itemId')
2805+ lineItems.appendChild(itemId)
2806+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['itemId']))
2807+ itemId.appendChild(ptext)
2808+
2809+ if 'name' in profile_dictionary['items'][i].keys():
2810+ name = doc1.createElement('name')
2811+ lineItems.appendChild(name)
2812+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['name']))
2813+ name.appendChild(ptext)
2814+
2815+ if 'description' in profile_dictionary['items'][i].keys():
2816+ description = doc1.createElement('description')
2817+ lineItems.appendChild(description)
2818+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['description']))
2819+ description.appendChild(ptext)
2820+
2821+ if 'quantity' in profile_dictionary['items'][i].keys():
2822+ quantity = doc1.createElement('quantity')
2823+ lineItems.appendChild(quantity)
2824+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['quantity']))
2825+ quantity.appendChild(ptext)
2826+
2827+ if 'unitPrice' in profile_dictionary['items'][i].keys():
2828+ unitPrice = doc1.createElement('unitPrice')
2829+ lineItems.appendChild(unitPrice)
2830+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['unitPrice']))
2831+ unitPrice.appendChild(ptext)
2832+
2833+ if 'taxable' in profile_dictionary['items'][i].keys():
2834+ taxable = doc1.createElement('taxable')
2835+ lineItems.appendChild(taxable)
2836+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['items'][0]['taxable']))
2837+ taxable.appendChild(ptext)
2838+
2839+ if 'customerProfileId' in KEYS:
2840+ customerProfileId = doc1.createElement('customerProfileId')
2841+ transaction_type.appendChild(customerProfileId)
2842+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerProfileId']))
2843+ customerProfileId.appendChild(ptext)
2844+
2845+ if 'customerPaymentProfileId' in KEYS:
2846+ customerProfileId = doc1.createElement('customerPaymentProfileId')
2847+ transaction_type.appendChild(customerProfileId)
2848+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerPaymentProfileId']))
2849+ customerProfileId.appendChild(ptext)
2850+
2851+ if 'customerShippingAddressId' in KEYS:
2852+ customerShippingAddressId = doc1.createElement('customerShippingAddressId')
2853+ transaction_type.appendChild(customerShippingAddressId)
2854+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerShippingAddressId']))
2855+ customerShippingAddressId.appendChild(ptext)
2856+
2857+ if transaction_type_tagname == 'profileTransCaptureOnly':
2858+ approvalCode = doc1.createElement('approvalCode')
2859+ transaction_type.appendChild(approvalCode)
2860+ ptext = doc1.createTextNode('000000')
2861+ approvalCode.appendChild(ptext)
2862+
2863+ if transaction_type_tagname == 'profileTransPriorAuthCapture' or transaction_type_tagname == 'profileTransRefund' :
2864+ transId = doc1.createElement('transId')
2865+ transaction_type.appendChild(transId)
2866+ if 'transId' in KEYS:
2867+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['transId']))
2868+ transId.appendChild(ptext)
2869+
2870+ if transaction_type_tagname == 'profileTransRefund':
2871+ if 'creditCardNumberMasked' in KEYS:
2872+ creditCardNumberMasked = doc1.createElement('creditCardNumberMasked')
2873+ transaction_type.appendChild(creditCardNumberMasked)
2874+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['creditCardNumberMasked']))
2875+ creditCardNumberMasked.appendChild(ptext)
2876+
2877+ elif profile_dictionary.get('trans_type') == 'Void':
2878+ transaction_type_tagname = 'profileTrans' + profile_dictionary.get('trans_type')
2879+ transaction_type = doc1.createElement(transaction_type_tagname)
2880+ transaction.appendChild(transaction_type)
2881+
2882+ if 'customerProfileId' in KEYS:
2883+ customerProfileId = doc1.createElement('customerProfileId')
2884+ transaction_type.appendChild(customerProfileId)
2885+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerProfileId']))
2886+ customerProfileId.appendChild(ptext)
2887+
2888+ if 'customerPaymentProfileId' in KEYS:
2889+ customerProfileId = doc1.createElement('customerPaymentProfileId')
2890+ transaction_type.appendChild(customerProfileId)
2891+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerPaymentProfileId']))
2892+ customerProfileId.appendChild(ptext)
2893+
2894+ if 'customerShippingAddressId' in KEYS:
2895+ customerShippingAddressId = doc1.createElement('customerShippingAddressId')
2896+ transaction_type.appendChild(customerShippingAddressId)
2897+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['customerShippingAddressId']))
2898+ customerShippingAddressId.appendChild(ptext)
2899+
2900+ if 'transId' in KEYS:
2901+ transId = doc1.createElement('transId')
2902+ transaction_type.appendChild(transId)
2903+ ptext = doc1.createTextNode(self._clean_string(profile_dictionary['transId']))
2904+ transId.appendChild(ptext)
2905+
2906+ if 'extraOptions' in KEYS:
2907+ extraOptions = doc1.createElement("extraOptions")
2908+ createCustomerProfileTransactionRequest.appendChild(extraOptions)
2909+
2910+ Request_string = xml = doc1.toxml(encoding="utf-8")
2911+ create_transaction_response_xml = self.request_to_server(Request_string, url, url_path)
2912+ create_transaction_response_dictionary = xml2dic.main(create_transaction_response_xml)
2913+ parent_resultCode = self.search_dic(create_transaction_response_dictionary, 'resultCode')
2914+ if parent_resultCode:
2915+ if parent_resultCode['resultCode'] == 'Ok':
2916+ parent_directResponse = self.search_dic(create_transaction_response_dictionary, 'directResponse')
2917+ li = parent_directResponse['directResponse'].split(',')
2918+ li[6]##Transaction ID
2919+ li[4]##Authorization code
2920+ return li[6]
2921+ ret = {}
2922+ Error_Code_dic = self.search_dic(create_transaction_response_dictionary, 'code')
2923+ if Error_Code_dic.get('code'):
2924+ ret['Error_Code'] = Error_Code_dic['code']
2925+ Error_message_dic = self.search_dic(create_transaction_response_dictionary, 'text')
2926+ if Error_message_dic.get('text'):
2927+ ret['Error_Message'] = Error_message_dic['text']
2928+ return ret
2929+
2930+ def request_to_server(self, Request_string, url, url_path):
2931+ ''' Sends a POST request to url and returns the response from the server'''
2932+
2933+ conn = httplib.HTTPSConnection(url)
2934+ conn.putrequest('POST', url_path)
2935+ conn.putheader('content-type', 'text/xml')
2936+ conn.putheader('content-length', len(Request_string))
2937+ conn.endheaders()
2938+ conn.send(Request_string)
2939+ response = conn.getresponse()
2940+ create_CustomerProfile_response_xml = response.read()
2941+ return create_CustomerProfile_response_xml
2942+
2943+ def search_dic(self, dic, key):
2944+ ''' Returns the parent dictionary containing key None on Faliure'''
2945+ if key in dic.keys():
2946+ return dic
2947+ for k in dic.keys():
2948+ if type(dic[k]) == type([]):
2949+ for i in dic[k]:
2950+ if type(i) == type({}):
2951+ ret = self.search_dic(i, key)
2952+ if ret and key in ret.keys():
2953+ return ret
2954+ return None
2955+
2956+ def _clean_string(self, text):
2957+ lis = ['\t', '\n']
2958+ if type(text) != type(''):
2959+ text = str(text)
2960+ for t in lis:
2961+ text = text.replace(t, '')
2962+ return text
2963+
2964+ def _setparameter(self, dic, key, value):
2965+ ''' Used to input parameters to corresponding dictionary'''
2966+ if key == None or value == None :
2967+ return
2968+ if type(value) == type(''):
2969+ dic[key] = value.strip()
2970+ else:
2971+ dic[key] = value
2972+
2973+ def do_cc_transaction(self, cr, uid, ids, context=None):
2974+ Param_Dic = {}
2975+ data = self.browse(cr, uid, ids[0])
2976+
2977+ customer = data.partner_id
2978+ amount = data.amount
2979+ trans_type = data.trans_type
2980+ trans_id = data.trans_id.trans_id
2981+ Customer_Profile_ID = customer.payment_profile_id.name
2982+ customerPaymentProfileId = data.payment_profile_id.name
2983+ Trans_key = customer.company_id.auth_config_id.transaction_key
2984+ Login_id = customer.company_id.auth_config_id.login_id
2985+ url_extension = customer.company_id.auth_config_id.url_extension
2986+ xsd = customer.company_id.auth_config_id.xsd_link
2987+ if customer.company_id.auth_config_id.test_mode:
2988+ url = customer.company_id.auth_config_id.url_test
2989+ else:
2990+ url = customer.company_id.auth_config_id.url
2991+
2992+ if Trans_key and Login_id:
2993+ self._setparameter(Param_Dic, 'api_login_id', Login_id)
2994+ self._setparameter(Param_Dic, 'transaction_key', Trans_key)
2995+
2996+ if url:
2997+ self._setparameter(Param_Dic, 'url', url)
2998+ self._setparameter(Param_Dic, 'url_extension', url_extension)
2999+ if xsd:
3000+ self._setparameter(Param_Dic, 'xsd', xsd)
3001+
3002+ self._setparameter(Param_Dic, 'customerProfileId', Customer_Profile_ID)
3003+ self._setparameter(Param_Dic, 'customerPaymentProfileId', customerPaymentProfileId)
3004+ self._setparameter(Param_Dic, 'amount', amount)
3005+ self._setparameter(Param_Dic, 'trans_type', trans_type)
3006+# self._setparameter(Param_Dic,'description',description)
3007+
3008+ if trans_type in ['Void', 'PriorAuthCapture', 'Refund', ]:
3009+ self._setparameter(Param_Dic, 'transId', trans_id)
3010+ Transaction_ID = self.createCustomerProfileTransactionRequest(Param_Dic)
3011+ if Transaction_ID and type(Transaction_ID) == type('') :
3012+ pay_profile_ids = self.pool.get('cust.payment.profile').search(cr, uid, [('name', '=', customerPaymentProfileId)])
3013+ for pay_id in pay_profile_ids:
3014+ trans_history_id = self.pool.get('transaction.history').create(cr, uid, {'trans_id':Transaction_ID,
3015+ 'payment_profile_id':pay_id,
3016+ 'amount':amount,
3017+ 'trans_type':trans_type,
3018+ 'transaction_date':time.strftime('%m/%d/%Y %H:%M:%S')
3019+ })
3020+ raise osv.except_osv(_('Transaction Error'), _('Error code : ' + Transaction_ID.get('Error_Message') or '' + '\nError Message :' + Transaction_ID.get('Error_Message') or ''))
3021+
3022+ return {}
3023+
3024+make_transaction()
3025
3026=== added file 'account_payment_cim_authdotnet/wizard/make_transaction_view.xml'
3027--- account_payment_cim_authdotnet/wizard/make_transaction_view.xml 1970-01-01 00:00:00 +0000
3028+++ account_payment_cim_authdotnet/wizard/make_transaction_view.xml 2012-08-24 15:52:25 +0000
3029@@ -0,0 +1,43 @@
3030+<?xml version="1.0" encoding="utf-8"?>
3031+<openerp>
3032+ <data>
3033+ <record id="make_transaction_form_view" model="ir.ui.view">
3034+ <field name="name">make_transaction_form_view</field>
3035+ <field name="model">make.transaction</field>
3036+ <field name="type">form</field>
3037+ <field name="arch" type="xml">
3038+ <form string="Make Transaction">
3039+
3040+ <field name="amount"/>
3041+ <newline/>
3042+ <field name="trans_type" on_change="onchange_trans_type(trans_type)"/>
3043+ <field name="partner_id"/>
3044+ <field name="payment_profile_id" context="{'make_transaction':'make_transaction'}"/>
3045+ <field name="invisible" invisible='1' />
3046+ <field name="trans_id" attrs="{'invisible':[('invisible','=',True)]}"/>
3047+ <newline/>
3048+ <group colspan="2" col="4">
3049+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
3050+ <button name="do_cc_transaction" string="Process Transaction" type="object" icon="gtk-ok" default_focus="1"/>
3051+ </group>
3052+ </form>
3053+ </field>
3054+ </record>
3055+
3056+
3057+ <record id="action_make_transaction" model="ir.actions.act_window">
3058+ <field name="name">Make Transaction</field>
3059+ <field name="type">ir.actions.act_window</field>
3060+ <field name="res_model">make.transaction</field>
3061+ <field name="view_type">form</field>
3062+ <field name="view_mode">form</field>
3063+ <field name="view_id" ref="make_transaction_form_view"/>
3064+ <field name="target">new</field>
3065+ </record>
3066+
3067+
3068+
3069+
3070+
3071+ </data>
3072+</openerp>
3073
3074=== added file 'account_payment_cim_authdotnet/wizard/xml2dic.py'
3075--- account_payment_cim_authdotnet/wizard/xml2dic.py 1970-01-01 00:00:00 +0000
3076+++ account_payment_cim_authdotnet/wizard/xml2dic.py 2012-08-24 15:52:25 +0000
3077@@ -0,0 +1,48 @@
3078+##Module that converts the Xml response to dictionary
3079+from lxml import etree
3080+import re
3081+
3082+def dictlist(node):
3083+ res = {}
3084+ node_tag=re.findall(r'}(\w*)',node.tag)
3085+ node_tag=node_tag[0]
3086+ res[node_tag] = []
3087+ xmltodict(node,res[node_tag])
3088+ reply = {}
3089+ reply[node_tag] =res[node_tag]
3090+
3091+ return reply
3092+
3093+def xmltodict(node,res):
3094+ rep = {}
3095+ node_tag=re.findall(r'}(\w*)',node.tag)
3096+ node_tag=node_tag[0]
3097+ if len(node):
3098+ #n = 0
3099+ for n in list(node):
3100+
3101+ rep[node_tag] = []
3102+ value = xmltodict(n,rep[node_tag])
3103+ if len(n):
3104+ n_tag=re.findall(r'}(\w*)',n.tag)
3105+ n_tag=n_tag[0]
3106+ value = rep[node_tag]
3107+ res.append({n_tag:value})
3108+ else :
3109+
3110+ res.append(rep[node_tag][0])
3111+
3112+ else:
3113+ value = {}
3114+ value = node.text
3115+ res.append({node_tag:value})
3116+
3117+ return
3118+
3119+def main(xml_string):
3120+ tree = etree.fromstring(xml_string)
3121+ res = dictlist(tree)
3122+ return res
3123+
3124+if __name__ == '__main__' :
3125+ main()
3126
3127=== added file 'account_payment_cim_authdotnet/xml2dic.py'
3128--- account_payment_cim_authdotnet/xml2dic.py 1970-01-01 00:00:00 +0000
3129+++ account_payment_cim_authdotnet/xml2dic.py 2012-08-24 15:52:25 +0000
3130@@ -0,0 +1,48 @@
3131+##Module that converts the Xml response to dictionary
3132+from lxml import etree
3133+import re
3134+
3135+
3136+def dictlist(node):
3137+ res = {}
3138+ node_tag = re.findall(r'}(\w*)', node.tag)
3139+ node_tag = node_tag[0]
3140+ res[node_tag] = []
3141+ xmltodict(node, res[node_tag])
3142+ reply = {}
3143+ reply[node_tag] = res[node_tag]
3144+ return reply
3145+
3146+def xmltodict(node, res):
3147+ rep = {}
3148+ node_tag = re.findall(r'}(\w*)', node.tag)
3149+ node_tag = node_tag[0]
3150+ if len(node):
3151+ #n = 0
3152+ for n in list(node):
3153+
3154+ rep[node_tag] = []
3155+ value = xmltodict(n, rep[node_tag])
3156+ if len(n):
3157+ n_tag = re.findall(r'}(\w*)', n.tag)
3158+ n_tag = n_tag[0]
3159+ value = rep[node_tag]
3160+ res.append({n_tag:value})
3161+ else :
3162+
3163+ res.append(rep[node_tag][0])
3164+
3165+ else:
3166+ value = {}
3167+ value = node.text
3168+ res.append({node_tag:value})
3169+
3170+ return
3171+
3172+def main(xml_string):
3173+ tree = etree.fromstring(xml_string)
3174+ res = dictlist(tree)
3175+ return res
3176+
3177+if __name__ == '__main__' :
3178+ main()