Subversion Repositories SmartDukaan

Rev

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

Rev 2818 Rev 3010
Line 54... Line 54...
54
			log.error("Error while initializing payment.", e);
54
			log.error("Error while initializing payment.", e);
55
			return PAYMENT_NOT_CREATED;
55
			return PAYMENT_NOT_CREATED;
56
		}
56
		}
57
	}
57
	}
58
	
58
	
59
	public static Map<String, String> capturePayment(Payment payment, String gatewayTxnId){
59
	public static Map<String, String> capturePayment(Payment payment){
60
		String amount = "" + payment.getAmount();
60
		String amount = "" + payment.getAmount();
61
		String gatewayPaymentId = payment.getGatewayPaymentId();
61
		String gatewayPaymentId = payment.getGatewayPaymentId();
62
		log.info("Capturing amount: Rs " + amount + " for payment Id: " + gatewayPaymentId);
62
		log.info("Capturing amount: Rs " + amount + " for payment Id: " + gatewayPaymentId);
63
		
63
		
64
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
64
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
Line 86... Line 86...
86
		Payment payment = new Payment();
86
		Payment payment = new Payment();
87
		payment.setPaymentId(216);
87
		payment.setPaymentId(216);
88
		payment.setAmount(40000);
88
		payment.setAmount(40000);
89
		payment.setGatewayPaymentId("TESTSTSTS");
89
		payment.setGatewayPaymentId("TESTSTSTS");
90
		
90
		
-
 
91
        // The underlying method calls are no longer valid since all the
-
 
92
        // information required to capture a payment is read from the database
-
 
93
        // itself and can't be specified through the call.
-
 
94
		
91
		//This test checks what happens when the txn id is left blank
95
		//This test checks what happens when the txn id is left blank
92
		capturePayment(payment, "");					//Result: !ERROR!-GW00205-Invalid Subsequent Transaction.
96
		//capturePayment(payment, "");					//Result: !ERROR!-GW00205-Invalid Subsequent Transaction.
93
		
97
		
94
		//This test checks what happends with an invalid txn id 
98
		//This test checks what happends with an invalid txn id 
95
		capturePayment(payment, "6022630101411740"); 	//Result: !ERROR!-GW00201-Transaction not found.
99
		//capturePayment(payment, "6022630101411740"); 	//Result: !ERROR!-GW00201-Transaction not found.
96
		
100
		
97
		//The next three tests require a valid AUTH transaction id.
101
		//The next three tests require a valid AUTH transaction id.
98
		//This test checks what happens when we attempt to capture an amount greater than what was authorized.
102
		//This test checks what happens when we attempt to capture an amount greater than what was authorized.
99
		capturePayment(payment, "9644960021411730");	//Result: !ERROR!-GW00177-Failed Capture Greater Than Auth check.
103
		//capturePayment(payment, "9644960021411730");	//Result: !ERROR!-GW00177-Failed Capture Greater Than Auth check.
100
		
104
		
101
		//This test checks what happens when we attempt to capture a valid transaction with the right amount. This transaction should be CAPTURED.
105
		//This test checks what happens when we attempt to capture a valid transaction with the right amount. This transaction should be CAPTURED.
102
		payment.setAmount(21698);
106
		//payment.setAmount(21698);
103
		capturePayment(payment, "9644960021411730");	//Result: CAPTURED
107
		//capturePayment(payment, "9644960021411730");	//Result: CAPTURED
104
		
108
		
105
		//This test tries to capture an already captured payment.
109
		//This test tries to capture an already captured payment.
106
		capturePayment(payment, "9644960021411730");	//Result: !ERROR!-GW00177-Failed Capture Greater Than Auth check.
110
		//capturePayment(payment, "9644960021411730");	//Result: !ERROR!-GW00177-Failed Capture Greater Than Auth check.
107
	}
111
	}
108
}
112
}
109
 
113