diff options
Diffstat (limited to 'sandbox/travelsample/contributions/payment-spring/src/main/java/com')
3 files changed, 19 insertions, 20 deletions
diff --git a/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java b/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java index fdced0d659..b08f76e0fa 100644 --- a/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java +++ b/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/customer/CustomerNotFoundException.java @@ -19,7 +19,6 @@ package com.tuscanyscatours.customer; - public class CustomerNotFoundException extends Exception { private static final long serialVersionUID = -129752837478357452L; diff --git a/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java b/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java index 6364701b9c..26926c7764 100644 --- a/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java +++ b/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/customer/impl/CustomerRegistryImpl.java @@ -64,12 +64,12 @@ public class CustomerRegistryImpl implements CustomerRegistry { cc.setExpYear(2012); createCustomer("John Smith", "john@xyz.com", cc); } - + @Destroy public void destroy() { // Save the customers } - + public Customer createCustomer(String name, String email, CreditCardDetailsType creditCard) { Customer customer = new Customer(); customer.setId("c-" + idGenerator++); @@ -90,11 +90,11 @@ public class CustomerRegistryImpl implements CustomerRegistry { public Customer getCustomer(String id) throws CustomerNotFoundException { Customer customer = customers.get(id); - - if (customer == null){ + + if (customer == null) { throw new CustomerNotFoundException("Customer " + id + " not found"); } - + return customer; } diff --git a/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java b/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java index 8dfe4b2b40..a35f761dc7 100644 --- a/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java +++ b/sandbox/travelsample/contributions/payment-spring/src/main/java/com/tuscanyscatours/payment/impl/PaymentImpl.java @@ -33,45 +33,45 @@ public class PaymentImpl implements Payment { private CustomerRegistry customerRegistry; private EmailGateway emailGateway; private float transactionFee; - + public void setCreditCardPayment(CreditCardPayment creditCardPayment) { this.creditCardPayment = creditCardPayment; } - + public void setCustomerRegistry(CustomerRegistry customerRegistry) { this.customerRegistry = customerRegistry; - } - + } + public void setEmailGateway(EmailGateway emailGateway) { this.emailGateway = emailGateway; } - + public void setTransactionFee(Float transactionFee) { this.transactionFee = transactionFee; } - + public String makePaymentMember(String customerId, float amount) { try { Customer customer = customerRegistry.getCustomer(customerId); - + amount += transactionFee; - + String status = creditCardPayment.authorize(customer.getCreditCard(), amount); - - com.tuscanyscatours.emailgateway.ObjectFactory emailFactory - = new com.tuscanyscatours.emailgateway.ObjectFactory(); + + com.tuscanyscatours.emailgateway.ObjectFactory emailFactory = + new com.tuscanyscatours.emailgateway.ObjectFactory(); EmailType email = emailFactory.createEmailType(); email.setTitle("Payment Received"); email.setTo(customerId); - + emailGateway.sendEmail(email); - + return status; } catch (CustomerNotFoundException ex) { return "Payment failed due to " + ex.getMessage(); } catch (Throwable t) { return "Payment failed due to system error " + t.getMessage(); - } + } } } |