| 420 |
ashish |
1 |
'''
|
|
|
2 |
Created on 26-Aug-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
| 701 |
chandransh |
6 |
from shop2020.payments.impl.DataService import Payment, PaymentGateway
|
|
|
7 |
from shop2020.thriftpy.payments.ttypes import Payment as TPayment, PaymentGateway as TPGateway, Attribute, PaymentGatewayStatus
|
| 420 |
ashish |
8 |
from shop2020.utils.Utils import to_java_date
|
|
|
9 |
|
| 701 |
chandransh |
10 |
def to_t_payment(payment):
|
|
|
11 |
t_payment = TPayment()
|
|
|
12 |
t_payment.paymentId = payment.id
|
|
|
13 |
t_payment.gatewayId = payment.gatewayId
|
|
|
14 |
if payment.gatewayPaymentId:
|
|
|
15 |
t_payment.gatewayPaymentId = payment.gatewayPaymentId
|
|
|
16 |
t_payment.merchantTxnId = payment.merchantTxnId
|
|
|
17 |
if payment.gatewayTxnId:
|
|
|
18 |
t_payment.gatewayTxnId = payment.gatewayTxnId
|
|
|
19 |
t_payment.amount = payment.amount
|
|
|
20 |
if payment.gatewayTxnStatus:
|
|
|
21 |
t_payment.gatewayTxnStatus = payment.gatewayTxnStatus
|
|
|
22 |
t_payment.status = payment.status
|
|
|
23 |
t_payment.userId = payment.userId
|
|
|
24 |
if payment.errorCode:
|
|
|
25 |
t_payment.errorCode = payment.errorCode
|
|
|
26 |
t_payment.description = payment.description
|
|
|
27 |
if payment.authCode:
|
|
|
28 |
t_payment.authCode = payment.authCode
|
|
|
29 |
if payment.referenceCode:
|
|
|
30 |
t_payment.referenceCode = payment.referenceCode
|
|
|
31 |
if payment.sessionId:
|
|
|
32 |
t_payment.sessionId = payment.sessionId
|
|
|
33 |
if payment.gatewayTxnDate:
|
|
|
34 |
t_payment.gatewayTxnDate = payment.gatewayTxnDate
|
|
|
35 |
t_payment.initTimestamp = to_java_date(payment.initTimestamp)
|
|
|
36 |
if payment.successTimestamp:
|
|
|
37 |
t_payment.successTimestamp = to_java_date(payment.successTimestamp)
|
|
|
38 |
if payment.errorTimestamp:
|
|
|
39 |
t_payment.errorTimestamp = to_java_date(payment.errorTimestamp)
|
|
|
40 |
t_payment.attributes = [Attribute(name=attr.name, value=attr.value) for attr in payment.attributes]
|
|
|
41 |
return t_payment
|
|
|
42 |
|
|
|
43 |
def to_t_payment_gateway(pg):
|
|
|
44 |
t_pgateway = TPGateway()
|
|
|
45 |
t_pgateway.id = pg.id
|
|
|
46 |
t_pgateway.name = pg.name
|
|
|
47 |
t_pgateway.url = pg.url
|
|
|
48 |
t_pgateway.responseUrl = pg.responseUrl
|
|
|
49 |
t_pgateway.errorUrl = pg.errorUrl
|
| 2309 |
ankur.sing |
50 |
t_pgateway.status = pg.status
|
| 701 |
chandransh |
51 |
t_pgateway.aliasName = pg.aliasName
|
|
|
52 |
t_pgateway.addedOn = to_java_date(pg.addedOn)
|
|
|
53 |
t_pgateway.attributes = [Attribute(name=attr.name, value=attr.value) for attr in pg.attributes]
|
|
|
54 |
return t_pgateway
|