Subversion Repositories SmartDukaan

Rev

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

Rev 701 Rev 717
Line 87... Line 87...
87
 
87
 
88
def update_payment_details(id, gatewayPaymentId, sessionId, gatewayTxnStatus, description, gatewayTxnId, authCode, referenceCode, errorCode, status, attributes):
88
def update_payment_details(id, gatewayPaymentId, sessionId, gatewayTxnStatus, description, gatewayTxnId, authCode, referenceCode, errorCode, status, attributes):
89
    if not id:
89
    if not id:
90
        raise PaymentException(101, "Can't update a payment without an id")
90
        raise PaymentException(101, "Can't update a payment without an id")
91
    try:
91
    try:
92
        payment = Payment.get_by(id)
92
        payment = Payment.get_by(id=id)
93
        if gatewayPaymentId:
93
        if gatewayPaymentId:
94
            payment.gatewayPaymentId = gatewayPaymentId
94
            payment.gatewayPaymentId = gatewayPaymentId
-
 
95
        if sessionId:
-
 
96
            payment.sessionId = sessionId    
95
        if gatewayTxnStatus:
97
        if gatewayTxnStatus:
96
            payment.gatewayTxnStatus = gatewayTxnStatus
98
            payment.gatewayTxnStatus = gatewayTxnStatus
97
        if description:
99
        if description:
98
            payment.description = description
100
            payment.description = description
99
        if gatewayTxnId:
101
        if gatewayTxnId:
Line 104... Line 106...
104
            payment.referenceCode = referenceCode
106
            payment.referenceCode = referenceCode
105
        if errorCode:
107
        if errorCode:
106
            payment.errorCode = errorCode
108
            payment.errorCode = errorCode
107
        if status:
109
        if status:
108
            payment.status = status
110
            payment.status = status
-
 
111
        if attributes: 
109
        for attr in attributes:
112
            for attr in attributes:
110
            payment_attr =  PaymentAttribute.query.filter_by(payment=payment, name=attr.name)
113
                payment_attr =  PaymentAttribute.query.filter_by(payment=payment, name=attr.name)
111
            if payment_attr:
114
                if payment_attr:
112
                payment_attr.value = attr.value
115
                    payment_attr.value = attr.value
113
            else:
116
                else:
114
                payment_attr = PaymentAttribute(payment=payment, name = attr.name, value = attr.value)
117
                    payment_attr = PaymentAttribute(payment=payment, name = attr.name, value = attr.value)
115
        session.commit()
118
        session.commit()
116
        return True
119
        return True
117
    except:
120
    except:
118
        return False
121
        return False
119
122