Rev 701 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 26-Aug-2010@author: ashish'''from shop2020.payments.impl import DataServicefrom shop2020.utils.Utils import log_entryfrom shop2020.payments.impl.DataAccessor import create_payment,\get_payments_for_user, get_payments, change_payment_status, get_payment,\add_bank_detailsfrom shop2020.payments.impl.converters import to_t_paymentclass PaymentsHandler:def __init__(self):DataService.initialize()log_entry(self, "Initialized the data model")def createPayment(self, user_id, cart_id, amount, gateway_id):"""Parameters:- user_id- cart_id- amount- gateway_id"""id = create_payment(user_id, cart_id, amount, gateway_id)log_entry(self, "created payment for cart_id %d" %(cart_id))return iddef createPaymentRequest(self, cart_id, application_id, merchant_tx_id, params):"""Parameters:- cart_id- application_id- merchant_tx_id- params"""passdef addCallbackUrl(self, application_id, callback_url, updateIfExisting):"""Parameters:- application_id- callback_url- updateIfExisting"""passdef getCallbackUrl(self, application_id):"""Parameters:- application_id"""passdef getPaymentsForUser(self, userId, from_time, to_time, status, gateway):"""Parameters:- userId- from_time- to_time- status- gateway"""payments = []pmnts = get_payments_for_user(userId, from_time, to_time, status, gateway)if pmnts:for pmnt in pmnts:payments.append(to_t_payment(pmnt))return paymentsdef getPaymentsForCart(self, cartId, from_time, to_time, status, gateway):"""Parameters:- cartId- from_time- to_time- status- gateway"""payments = []pmnts = get_payments_for_user(cartId, from_time, to_time, status, gateway)if pmnts:for pmnt in pmnts:payments.append(to_t_payment(pmnt))return paymentsdef getPayments(self, from_time, to_time, status, gateway):"""Parameters:- from_time- to_time- status- gateway"""payments = []pmnts = get_payments(from_time, to_time, status, gateway)if pmnts:for pmnt in pmnts:payments.append(to_t_payment(pmnt))return paymentsdef getPaymentForMerchantId(self, merchant_tx_id):"""Parameters:- merchant_tx_id"""payments = []pmnts = get_payments_for_user(int(merchant_tx_id), 0, 0, -1, 0)if pmnts:for pmnt in pmnts:payments.append(to_t_payment(pmnt))return paymentsdef changePaymentStatus(self, merchant_tx_id, newStatus):"""Parameters:- merchant_tx_id- newStatus"""change_payment_status(merchant_tx_id, newStatus)def changePaymentRequestStatus(self, request_id, requestStatus):"""Parameters:- request_id- requestStatus"""passdef getPaymentGateways(self, status):"""Parameters:- status"""passdef getPaymentGateway(self, id):"""Parameters:- id"""passdef changeGatewayStatus(self, id, status):"""Parameters:- id- status"""passdef getPayment(self, id):payment = get_payment(id)if payment:return to_t_payment(payment)return Nonepassdef addBankDetails(self, id, bid, btxid, error_code, session_id, postdate, auth_code, ref_code):"""Parameters:- id- bid- btxid- error_code- session_id- postdate- auth_code- ref_code"""add_bank_details(id, bid, btxid, error_code, session_id, postdate, auth_code, ref_code)