Subversion Repositories SmartDukaan

Rev

Rev 859 | Rev 1493 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 859 Rev 1120
Line 84... Line 84...
84
    try:
84
    try:
85
        return Payment.query.filter_by(merchantTxnId=txnId).one()
85
        return Payment.query.filter_by(merchantTxnId=txnId).one()
86
    except:
86
    except:
87
        raise PaymentException(103, "Unable to get payment for the given transaction")
87
        raise PaymentException(103, "Unable to get payment for the given transaction")
88
        
88
        
89
def update_payment_details(id, gatewayPaymentId, sessionId, gatewayTxnStatus, description, gatewayTxnId, authCode, referenceCode, errorCode, status, attributes):
89
def update_payment_details(id, gatewayPaymentId, sessionId, gatewayTxnStatus, description, gatewayTxnId, authCode, referenceCode, errorCode, status, gatewayTxnDate, attributes):
90
    if not id:
90
    if not id:
91
        raise PaymentException(101, "Can't update a payment without an id")
91
        raise PaymentException(101, "Can't update a payment without an id")
92
    try:
92
    try:
93
        payment = Payment.get_by(id=id)
93
        payment = Payment.get_by(id=id)
94
        if gatewayPaymentId:
94
        if gatewayPaymentId:
Line 105... Line 105...
105
            payment.authCode = authCode
105
            payment.authCode = authCode
106
        if referenceCode:
106
        if referenceCode:
107
            payment.referenceCode = referenceCode
107
            payment.referenceCode = referenceCode
108
        if errorCode:
108
        if errorCode:
109
            payment.errorCode = errorCode
109
            payment.errorCode = errorCode
-
 
110
        if gatewayTxnDate:
-
 
111
            payment.gatewayTxnDate = gatewayTxnDate
110
        if status:
112
        if status:
111
            payment.status = status
113
            payment.status = status
-
 
114
            if status == PaymentStatus.SUCCESS:
-
 
115
                payment.successTimestamp = datetime.datetime.now()
-
 
116
            if status == PaymentStatus.FAILED:
-
 
117
                payment.errorTimestamp = datetime.datetime.now()
112
        if attributes: 
118
        if attributes: 
113
            for attr in attributes:
119
            for attr in attributes:
114
                payment_attr =  PaymentAttribute.query.filter_by(payment=payment, name=attr.name).first()
120
                payment_attr =  PaymentAttribute.query.filter_by(payment=payment, name=attr.name).first()
115
                if payment_attr:
121
                if payment_attr:
116
                    payment_attr.value = attr.value
122
                    payment_attr.value = attr.value