Êëàññ TestPaymentAuthorizer...
Ëèñòèíã 5.10. Êëàññ TestPaymentAuthorizer (TestPaymentAuthorizer.java)
public class TestPaymentAuthorizer {
static public Authorization getAuthorization( Order order ) {
Authorization authorization = new Authorization();
try {
CustomerInfo custInfo = order.getCustomerInfo();
CreditInfo creditInfo = custInfo.getCreditInfo();
String num = creditInfo.getCreditCardNumber();
if( num != null ) {
if( num.endsWith( "1" ) ) {
authorization.setApproved( false );
authorization.setReason("Insufficent Funds");
}
else
{
authorization.setApproved( true );
authorization.setReason( "Approved" );
authorization.setAuthorizationCode( "Test" );
}
}
}
catch( Exception e ) {}
return authorization;
}
static public void capture( String authorizationCode, double amount ) {
}
}
Ñîäåðæàíèå ðàçäåëà