Rev 701 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 26-Aug-2010@author: ashish'''from shop2020.payments.impl.DataService import Payment, PaymentGatewayfrom shop2020.thriftpy.payments.ttypes import Payment as TPayment, PaymentGateway as TPGateway, Attribute, PaymentGatewayStatusfrom shop2020.utils.Utils import to_java_datedef to_t_payment(payment):t_payment = TPayment()t_payment.paymentId = payment.idt_payment.gatewayId = payment.gatewayIdif payment.gatewayPaymentId:t_payment.gatewayPaymentId = payment.gatewayPaymentIdt_payment.merchantTxnId = payment.merchantTxnIdif payment.gatewayTxnId:t_payment.gatewayTxnId = payment.gatewayTxnIdt_payment.amount = payment.amountif payment.gatewayTxnStatus:t_payment.gatewayTxnStatus = payment.gatewayTxnStatust_payment.status = payment.statust_payment.userId = payment.userIdif payment.errorCode:t_payment.errorCode = payment.errorCodet_payment.description = payment.descriptionif payment.authCode:t_payment.authCode = payment.authCodeif payment.referenceCode:t_payment.referenceCode = payment.referenceCodeif payment.sessionId:t_payment.sessionId = payment.sessionIdif payment.gatewayTxnDate:t_payment.gatewayTxnDate = payment.gatewayTxnDatet_payment.initTimestamp = to_java_date(payment.initTimestamp)if payment.successTimestamp:t_payment.successTimestamp = to_java_date(payment.successTimestamp)if payment.errorTimestamp:t_payment.errorTimestamp = to_java_date(payment.errorTimestamp)t_payment.attributes = [Attribute(name=attr.name, value=attr.value) for attr in payment.attributes]return t_paymentdef to_t_payment_gateway(pg):t_pgateway = TPGateway()t_pgateway.id = pg.idt_pgateway.name = pg.namet_pgateway.url = pg.urlt_pgateway.responseUrl = pg.responseUrlt_pgateway.errorUrl = pg.errorUrlt_pgateway.status = pg.statust_pgateway.aliasName = pg.aliasNamet_pgateway.addedOn = to_java_date(pg.addedOn)t_pgateway.attributes = [Attribute(name=attr.name, value=attr.value) for attr in pg.attributes]return t_pgateway