diff options
Diffstat (limited to 'sandbox/travelsample/contributions/payment-java-contribution/src')
2 files changed, 16 insertions, 38 deletions
diff --git a/sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java b/sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java index e3b1d88d4a..53e896a580 100644 --- a/sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java +++ b/sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java @@ -57,34 +57,21 @@ public class PaymentImpl implements Payment { protected float transactionFee = 0.01f;
public String makePaymentMember(String customerId, float amount) {
- Customer customer = null;
-
try {
- customer = customerRegistry.getCustomer(customerId);
+ Customer customer = customerRegistry.getCustomer(customerId);
+ String status = creditCardPayment.authorize(customer.getCreditCard(),
+ amount + transactionFee);
+ emailGateway.sendEmail("order@tuscanyscatours.com",
+ customer.getEmail(),
+ "Status for your payment",
+ customer + " >>> Status = " + status);
+ return status;
} catch (CustomerNotFoundException ex) {
return "Payment failed due to " + ex.getMessage();
+ } catch (AuthorizeFault_Exception e) {
+ return e.getFaultInfo().getErrorCode();
} catch (Throwable t) {
return "Payment failed due to system error " + t.getMessage();
- }
-
- CreditCardDetailsType ccDetails = customer.getCreditCard();
-
- float total = amount + transactionFee;
-
- String status;
- try {
- status = creditCardPayment.authorize(ccDetails, total);
- } catch (AuthorizeFault_Exception e) {
- status = e.getFaultInfo().getErrorCode();
- }
-
- StringBuffer body = new StringBuffer();
- body.append(customer);
- body.append("\n").append("Status: ").append(status).append("\n");
- emailGateway.sendEmail("order@tuscanyscatours.com", customer.getEmail(), "Status for your payment", body
- .toString());
-
- return status;
+ }
}
-
}
diff --git a/sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java b/sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java index 39671b33ca..b6c7561a15 100644 --- a/sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java +++ b/sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java @@ -25,17 +25,12 @@ import org.apache.tuscany.sca.node.SCANode; import org.apache.tuscany.sca.node.SCANodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
-/**
- *
- */
public class PaymentTestCase {
private static SCANode node;
- /**
- * @throws java.lang.Exception
- */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
@@ -53,26 +48,22 @@ public class PaymentTestCase { public void testPayment() {
SCAClient client = (SCAClient) node;
Payment payment = client.getService(Payment.class, "PaymentComponent");
- System.out.println(payment.makePaymentMember("c-0", 100.00f));
- System.out.println(payment.makePaymentMember("c-1", 100.00f));
+
+ System.out.println("\n\nSuccessful Payment - Status = \n\n" + payment.makePaymentMember("c-0", 100.00f));
+ System.out.println("\n\nFailed Payment - Status = \n\n" + payment.makePaymentMember("c-1", 100.00f));
}
@Test
- //@Ignore
+ @Ignore
public void testWaitForInput() {
-/*
System.out.println("Press a key to end");
try {
System.in.read();
} catch (Exception ex) {
}
System.out.println("Shutting down");
-*/
}
- /**
- * @throws java.lang.Exception
- */
@AfterClass
public static void tearDownAfterClass() throws Exception {
if (node != null) {
|