|
1 | | -package net.authorize.sample.PayPalExpressCheckout; |
| 1 | +package net.authorize.sample.PaypalExpressCheckout; |
2 | 2 |
|
3 | 3 | import net.authorize.Environment; |
4 | 4 | import net.authorize.api.contract.v1.*; |
@@ -36,32 +36,23 @@ public static void run(String apiLoginId, String transactionKey) { |
36 | 36 |
|
37 | 37 | CreateTransactionResponse response = controller.getApiResponse(); |
38 | 38 |
|
39 | | - if (response!=null) { |
40 | | - if (response.getMessages().getResultCode() == MessageTypeEnum.OK) { |
| 39 | + if (response!=null && response.getMessages().getResultCode() == MessageTypeEnum.OK) { |
41 | 40 |
|
42 | | - TransactionResponse result = response.getTransactionResponse(); |
43 | | - if (result.getResponseCode().equals("1")) { |
44 | | - System.out.println("Successful PayPal Get Details Transaction"); |
45 | | - System.out.println("Account Type : "+ result.getAccountType()); |
46 | | - System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID()); |
47 | | - System.out.println("Shipping Address : "+ result.getShipTo().getFirstName()); |
48 | | - System.out.println(result.getShipTo().getAddress() +" " + result.getShipTo().getCity()); |
49 | | - System.out.println(result.getShipTo().getState() +" "+ result.getShipTo().getZip()); |
50 | | - System.out.println(result.getShipTo().getCountry()); |
51 | | - System.out.println("Transaction ID : " + result.getTransId()); |
52 | | - } |
53 | | - else |
54 | | - { |
55 | | - System.out.println("Failed Transaction"+result.getResponseCode()); |
56 | | - } |
57 | | - } |
58 | | - else |
59 | | - { |
60 | | - System.out.println("Failed Transaction: "+response.getMessages().getResultCode()); |
| 41 | + TransactionResponse result = response.getTransactionResponse(); |
| 42 | + if (result.getResponseCode().equals("1")) { |
| 43 | + System.out.println("Successful PayPal Get Details Transaction"); |
| 44 | + System.out.println("Account Type : "+ result.getAccountType()); |
| 45 | + System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID()); |
| 46 | + System.out.println("Shipping Address : "+ result.getShipTo().getFirstName()); |
| 47 | + System.out.println(result.getShipTo().getAddress() +" " + result.getShipTo().getCity()); |
| 48 | + System.out.println(result.getShipTo().getState() +" "+ result.getShipTo().getZip()); |
| 49 | + System.out.println(result.getShipTo().getCountry()); |
| 50 | + System.out.println("Transaction ID : " + result.getTransId()); |
61 | 51 | } |
62 | 52 | } |
63 | | - else{ |
64 | | - System.out.println("Failed Transaction"); |
| 53 | + else |
| 54 | + { |
| 55 | + System.out.println("Failed Transaction: "+response.getMessages().getMessage().get(0).getCode()+ " " + response.getMessages().getMessage().get(0).getText()); |
65 | 56 | } |
66 | 57 |
|
67 | 58 | } |
|
0 commit comments