Subversion Repositories SmartDukaan

Rev

Rev 2059 | Rev 2461 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

namespace java in.shop2020.payments
namespace py shop2020.thriftpy.payments

/**
Various structures
**/
enum PaymentGatewayStatus{
        AVAILABLE,
        BLOCKED
}

enum PaymentStatus{
        INIT,
        PENDING,
        SUCCESS,        // HDFC Status: CAPTURED; EBS Status: Captured
        FAILED,         // HDFC status: NOT CAPTURED, DENIED BY RISK, HOST TIMEOUT, CANCELLED
        AUTHORIZED  // EBS Status: Pending
}

const map<string,string> PAYMENT_METHOD = {
        '1001' : 'EBS-TEST Payment'
        '1004' : 'EBS-AXIS Bank Account'
        '1007' : 'EBS-HDFC Bank Account'
        '1008' : 'EBS-VISA'
        '1009' : 'EBS-Citi Bank Debit Card'
        '1010' : 'EBS-Diners Club'
        '1012' : 'EBS-ItzCash'
        '1015' : 'EBS-JK Bank Account'
        '1016' : 'EBS-ICICI Bank Account'
        '1017' : 'EBS-MasterCard'
        '1029' : 'EBS-Federal Bank Account'
        '1032' : 'EBS-State Bank of India Netbanking'
        '1033' : 'EBS-State Bank of Bikaner and Jaipur Netbanking'
        '1034' : 'EBS-State Bank of Hyderabad Netbanking'
        '1035' : 'EBS-State Bank of Patiala Netbanking'
        '1036' : 'EBS-State Bank of Shaurashtra Netbanking'
        '1037' : 'EBS-State Bank of Indore Netbanking'
        '1038' : 'EBS-State Bank of Mysore Netbanking'
        '1039' : 'EBS-State Bank of Travancore Netbanking'
        '1040' : 'EBS-Citi Bank Reward Point'
        '1127' : 'EBS-Citi Bank Account'
        '1132' : 'EBS-Done Card'
}

struct Attribute{
        1:string name,
        2:string value
}

struct PaymentGateway{
        1:i64 id,
        2:string name,
        3:string url,
        4:i64 addedOn,
        5:string aliasName,
        6:string responseUrl,
        7:string errorUrl,
        8:PaymentGatewayStatus status
        9:list<Attribute> attributes  // list of all attributes for PG
}

struct Payment{
        1:i64 paymentId,                                // trackId for bank, paymentid for us and id for table.
        2:i64 gatewayId,                                //payment gateway used
        3:string gatewayPaymentId
        4:i64 merchantTxnId,                    //merchant transaction id. This will be propagated further to order processing
        5:string gatewayTxnId,                  //bank trnasaction id
        6:double amount,
        7:string gatewayTxnStatus,      // bank status will be stored here
        8:PaymentStatus status,
        9:i64 userId,                                   //The user for which payment has to be processed.This is here to speed up querying.
        10:string errorCode,
        11:string description,
        12:string authCode,
        13:string referenceCode,                // given by gateway
        14:string sessionId,                    // received from PG 
        15:string gatewayTxnDate,
        16:list<Attribute> attributes,          // list of all attributes received from PG
        17:i64 initTimestamp,                   //statring the payment processing timestamp
        18:i64 successTimestamp,                //timestamp when payment is captured
        19:i64 errorTimestamp,                  // in case, error is received from PG
}


exception PaymentException{
        1:i64 error_code,
        2:string message
}

service PaymentService{
        /**
        * For closing the open session in sqlalchemy
        */
        void closeSession(),

        /**
        *       create a new payment and return payment id, throws an exception if gateway is not active
        **/
        i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId) throws (1:PaymentException pe),
        
        /**
        * get payment for user. If status and gateway are null, it is ignored. Same for times as well.
        **/ 
        list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
        
        /**
        * get all payments for user. If gatewayId is 0, then it is ignored while filtering.
        **/ 
        list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
        
        
        /** 
        * Get a particular gateway
        **/
        PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),

        /** 
        * Get a particular payment info
        **/
        Payment getPayment(1:i64 id) throws (1:PaymentException pe),


        /** 
        * Get a particular payment for a transaction. Will raise exception.
        **/
        list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
        
        /**
        * mark payment successful and store parameters
        **/
        bool updatePaymentDetails(1:i64 id, 2:string gatewayPaymentId, 3:string sessionId, 4:string gatewayTxnStatus, 5:string  description, 6:string gatewayTxnId, 7:string authCode, 8:string referenceCode, 9:string errorCode, 10:PaymentStatus  status, 11:string gatewayTxnDate, 12:list<Attribute> attributes) throws (1:PaymentException pe),
        
        /**
        * mark payment failed and store parameters
        
        bool markPaymentFailed(1:i64 id, 2:string gatewayPaymentId, 3:string sessionId, 4:string gatewayTxnStatus, 5:string description, 6:string errorCode, 7:list<Attribute> attributes )  throws (1:PaymentException pe)
        */
                
        /**
        Returns the minimum and maximum amounts among successful payments.
        List contains two double values, first minimum and second maximum amount.
        */
        list<double> getSuccessfulPaymentsAmountRange()
}