package net.authorize.sample.PayPalExpressCheckout;

import net.authorize.Environment;
import net.authorize.api.contract.v1.*;
import net.authorize.api.controller.CreateTransactionController;
import net.authorize.api.controller.base.ApiOperationBase;

public class GetDetails {
	
	public static void run(String apiLoginId, String transactionKey) {
        //Common code to set for all requests
        ApiOperationBase.setEnvironment(Environment.SANDBOX);
        MerchantAuthenticationType merchantAuthenticationType  = new MerchantAuthenticationType() ;
        merchantAuthenticationType.setName(apiLoginId);
        merchantAuthenticationType.setTransactionKey(transactionKey);
        ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
                
        PayPalType payPalType = new PayPalType();
        payPalType.setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
        payPalType.setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
        // set payment type as PayPal
        PaymentType paymentType = new PaymentType();
        paymentType.setPayPal(payPalType);
        
        //create GetDetailsTransaction for any valid PayPal transaction Id for the Merchant
        TransactionRequestType transactionRequestType = new TransactionRequestType();
        transactionRequestType.setTransactionType(TransactionTypeEnum.GET_DETAILS_TRANSACTION.value());
        transactionRequestType.setPayment(paymentType);
        transactionRequestType.setRefTransId("2241936095");
        CreateTransactionRequest apiRequest = new CreateTransactionRequest();
        apiRequest.setTransactionRequest(transactionRequestType);
        
        CreateTransactionController controller = new CreateTransactionController(apiRequest);
        controller.execute();
        
        
        CreateTransactionResponse response = controller.getApiResponse();
        
        if (response!=null) {
            if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {

                TransactionResponse result = response.getTransactionResponse();
                if (result.getResponseCode().equals("1")) {
                    System.out.println("Successful PayPal Get Details Transaction");
                    System.out.println("Account Type : "+ result.getAccountType());
                    System.out.println("PayPal PayerID : "+ result.getSecureAcceptance().getPayerID());
                    System.out.println("Shipping Address : "+ result.getShipTo().getFirstName());
                    System.out.println(result.getShipTo().getAddress() +" " + result.getShipTo().getCity());
                    System.out.println(result.getShipTo().getState() +" "+ result.getShipTo().getZip());
                    System.out.println(result.getShipTo().getCountry());
                    System.out.println("Transaction ID : " + result.getTransId());
                }
                else
                {
                    System.out.println("Failed Transaction"+result.getResponseCode());
                }
            }
            else
            {
                System.out.println("Failed Transaction:  "+response.getMessages().getResultCode());
            }
        }
        else{
        	System.out.println("Failed Transaction");
        }

	}

}

@@ -25,17 +25,17 @@
 mple.Pay
-P
+p
 alExpres
@@ -1950,28 +1950,12 @@
 null
-) %7B%0A            if (
+ && 
 resp
@@ -2023,28 +2023,24 @@
             
-    
 TransactionR
@@ -2087,28 +2087,24 @@
 Response();%0A
-    
             
@@ -2155,36 +2155,32 @@
                 
-    
 System.out.print
@@ -2236,36 +2236,32 @@
                 
-    
 System.out.print
@@ -2304,28 +2304,24 @@
 untType());%0A
-    
             
@@ -2404,28 +2404,24 @@
 PayerID());%0A
-    
             
@@ -2510,36 +2510,32 @@
                 
-    
 System.out.print
@@ -2615,36 +2615,32 @@
                 
-    
 System.out.print
@@ -2716,36 +2716,32 @@
                 
-    
 System.out.print
@@ -2773,28 +2773,24 @@
 Country());%0A
-    
             
@@ -2860,36 +2860,32 @@
 ));%0A            
-    
 %7D%0A              
@@ -2870,32 +2870,34 @@
       %7D%0A        
+%7D%0A
         else%0A   
@@ -2901,34 +2901,18 @@
         
-        %7B%0A        
+%7B%0A
         
@@ -2957,159 +2957,75 @@
 tion
+:  
 %22+res
-ult
+ponse
 .get
-ResponseCode());%0A                %7D%0A            %7D%0A            else%0A            %7B%0A                System.out.println(%22Failed Transaction:  %22+
+Messages().getMessage().get(0).getCode()+ %22   %22 + 
 resp
@@ -3050,109 +3050,34 @@
 .get
-ResultCode());%0A            %7D%0A        %7D%0A        else%7B%0A        %09System.out.println(%22Failed Transaction%22
+Message().get(0).getText()
 );%0A 

Update GetDetails.java