Subversion Repositories SmartDukaan

Rev

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

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

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

enum PaymentStatus{
        INIT,
        PENDING,
        SUCCESS,
        FAILED
}

enum RequestStatus{
        RECEIVED,
        SENT_TO_GATEWAY,
        GATEWAY_UNREACHABLE
        RESPONSE_FROM_GATEWAY,
        RESPONSE_SENT
}

struct Paymentgateway{
        1:i64 id,
        2:string gatewayName,
        3:string gatewayProductionUrl,
        4:string gatewayStagingUrl,
        5:map<string,string> gatewayInfo,
        6:i64 addedOn
}

struct Payment{
        1:i64 merchant_tx_id,                   //merchant transaction id. This will be propagated further to order processing
        2:i64 bank_tx_id,                               //bank trnasaction id
        3:double amount,                                
        4:i64 init_timestamp,                   //statring the payment processing timestamp
        5:i64 bank_ack_timestamp,               //finishing processing timestamp
        6:string bank_status,                   //status provided by bank
        7:PaymentStatus status,                 //shop2020 status
        8:string message,                               //Will have the failure reason
        9:i64 user_id,                                  //The user for which payment has to be processed.This is here to speed up querying.
        10:i64 cart_id,
        11:map<string,string> other_info, //other misllaneous info about the payment
        12:PaymentGateway gateway               //payment gateway used
}       

struct ApplicationRegistry{
        1:i64 application_id,
        2:string callback_url
}

struct Param{
        1:string key,
        2:string value
}

struct PaymentRequest{
        1:i64 request_id,
        2:i64 application_id,
        3:RequestStatus requestStatus,
        4:i64 receiving_timestamp,
        5:i64 sending_timestamp,
        6:list<Param> params,
        7:i64 merchant_tx_id
}

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

service PaymentService{
        //create a new payment
        Payment createPayment(1:i64 user_id, 2:i64 cart_id, 3:double amount, 4:i64 gateway_id) throws (1:PaymentException pe),
        //create a new payment request
        PaymentRequest createPaymentRequest(1:i64 cart_id, 2:i64 application_id, 3:i64 merchant_tx_id, 5:list<Param> params) throws (1:PaymentException pe),
        //Add/update  a new callback url for an application
        void addCallbackUrl(1:i64 application_id, 2:string callback_url, 3:bool updateIfExisting) throws (1:PaymentException pe),
        //Retrieve callback url
        void getCallbackUrl(1:i64 application_id) throws (1:PaymentException pe),
        //get payment for user. If status and gateway are null, it is ignore. Same for times as well. 
        list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 from_time, 3:i64 to_time, 4:PaymentStatus status, 5:PaymentGateway gateway) throws (1:PaymentException pe),
        //get payments for a cart. If status and gateway are null, it is ignore. Same for times as well.
        list<Payment> getPaymentsForCart(1:i64 cartId,  2:i64 from_time, 3:i64 to_time, 4:PaymentStatus status, 5:PaymentGateway gateway) throws (1:PaymentException pe),
        //get all payments. 
        list<Payment> getPayments(1:i64 from_time, 2:i64 to_time, 3:PaymentStatus status, 4:PaymentGateway gateway) throws (1:PaymentException pe),
        //Get a particular payment
        Payment getPaymentForMerchantId(1:i64 merchant_tx_id) throws (1:PaymentException pe),
        //change payment status
        void changePaymentStatus(1:i64 merchant_tx_id, 2:PaymentStatus newStatus) throws (1:PaymentException pe),
        //change paymet request status
        void changePaymentRequestStatus(1:i64 request_id, 2:RequestStatus requestStatus) throws (1:PaymentException pe),
        
        //Get all payment gateways
        list<PaymentGateway> getPaymentGateways(1:PaymentGatewayStatus status) throws (1:PaymentException pe),
        
        //Get a particular gateway
        PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
        
        //change status of a gateway
        void changeGatewayStatus(1:i64 id, 2:PaymentGatewayStatus) throws (1:PaymentException pe),
        
        
}