cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

createTransactionRequest API - Charge a Customer Profile is not working

I used "createCustomerProfileTransactionRequest" to authorize a transaction from an existing customer profile and made it work in java. I understand that this has been depreciated as per information - http://developer.authorize.net/api/reference/#charge-customer-profiles

 

So, I tried to use "createTransactionRequest" to authorize a payment using a stored customer payment profile but in vain. In the following web site (http://developer.authorize.net/api/reference/#payment-transactions-charge-a-customer-profile) I just gave required information to see the output. Interestingly I see blank in response instead of seeing either success/failure.

 

------------------------------------------------

 

<createTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <merchantAuthentication>
    <name>XXXXXXXXXXXX</name>
    <transactionKey>XXXXXXXXXXXXXX</transactionKey>
  </merchantAuthentication>
  <refId>123456</refId>
  <transactionRequest>
    <transactionType>authCaptureTransaction</transactionType>
    <amount>5</amount>
    <profile>
      <customerProfileId>XXXXXXXXXX</customerProfileId>
      <paymentProfile>
        <paymentProfileId>XXXXXXXXX</paymentProfileId>
      </paymentProfile>
    </profile>
    <lineItems>
      <lineItem>
        <itemId>1</itemId>
        <name>vase</name>
        <description>Cannes logo </description>
        <quantity>18</quantity>
        <unitPrice>45.00</unitPrice>
      </lineItem>
    </lineItems>
    <poNumber>456654</poNumber>
    <shipTo>
      <firstName>China</firstName>
      <lastName>Bayles</lastName>
      <company>Thyme for Tea</company>
      <address>12 Main Street</address>
      <city>Pecan Springs</city>
      <state>TX</state>
      <zip>44628</zip>
      <country>USA</country>
    </shipTo>
    <customerIP>192.168.1.1</customerIP>
  </transactionRequest>
</createTransactionRequest>

 

---------------------------------------

 

I guess this must be a new api and I am not sure whether I have to add any other information. I am just testing from site itself. Please help me to solve this one.

smartk1977
Contributor
8 REPLIES 8

It work fine for me.

RaynorC1emen7
Expert

Did you test from website directly? Even the following java code does not yeild result to me, I get null for response code

        
            Merchant merchant = Merchant.createMerchant(Environment.SANDBOX,
                        apiLoginID, transactionKey);

            MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType();
            merchantAuthenticationType.setName("xxx");
            merchantAuthenticationType.setTransactionKey("xxx");

            CreateTransactionRequest createTransactionRequest = new CreateTransactionRequest();
            createTransactionRequest.setMerchantAuthentication(merchantAuthenticationType);
          
            TransactionRequestType transactionRequestType = new TransactionRequestType();
            transactionRequestType.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value());
            transactionRequestType.setAmount(new BigDecimal(150));
            
            CustomerProfilePaymentType customerProfilePaymentType = new CustomerProfilePaymentType();
            customerProfilePaymentType.setCustomerProfileId("xxxx");
            net.authorize.api.contract.v1.PaymentProfile paymentProfile = new net.authorize.api.contract.v1.PaymentProfile();
            paymentProfile.setPaymentProfileId("xxxxx");
            customerProfilePaymentType.setPaymentProfile(paymentProfile);
            
            transactionRequestType.setProfile(customerProfilePaymentType);
            createTransactionRequest.setTransactionRequest(transactionRequestType);            
            
            CreateTransactionResponse createTransactionResponse = null;
            createTransactionResponse = (CreateTransactionResponse) HttpUtility.postData(Environment.SANDBOX, createTransactionRequest, CreateTransactionResponse.class );

Thanks for the information. I followed your instructions and added controller at the end of the code but in vain. I am still getting transactionid as null. Can u please find what is wrong in the below code?

 

            MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType();
            merchantAuthenticationType.setName("xxx");
            merchantAuthenticationType.setTransactionKey("xxx");

            CreateTransactionRequest createTransactionRequest = new CreateTransactionRequest();
            createTransactionRequest.setMerchantAuthentication(merchantAuthenticationType);
          
            TransactionRequestType transactionRequestType = new TransactionRequestType();
            transactionRequestType.setTransactionType(TransactionTypeEnum.AUTH_ONLY_TRANSACTION.value());
            transactionRequestType.setAmount(new BigDecimal(150));
            
            CustomerProfilePaymentType customerProfilePaymentType = new CustomerProfilePaymentType();
            customerProfilePaymentType.setCustomerProfileId("xxxx");
            net.authorize.api.contract.v1.PaymentProfile paymentProfile = new net.authorize.api.contract.v1.PaymentProfile();
            paymentProfile.setPaymentProfileId("xxxxx");
            customerProfilePaymentType.setPaymentProfile(paymentProfile);
            
            transactionRequestType.setProfile(customerProfilePaymentType);
            createTransactionRequest.setTransactionRequest(transactionRequestType);       

 

            //used controller

            CreateTransactionController controller = new CreateTransactionController(createTransactionRequest);
            controller.execute(Environment.SANDBOX);
            CreateTransactionResponse createTransactionResponse = controller.getApiResponse();
                                
            System.out.println("transactionid:" + createTransactionResponse.getTransactionResponse().getTransId());
            System.out.println("response code:" + createTransactionResponse.getTransactionResponse().getResponseCode());

Maybe some java developer can help you on this.

 

System.out.println("transactionid:" + createTransactionResponse.getTransactionResponse().getTransId());
            System.out.println("response code:" + createTransactionResponse.getTransactionResponse().getResponseCode());

You are assuming the request when thru without error.

Can you debug in what on the createTransactionResponse after the controller.getApiResponse();

Or better yet, if the execute() ran without failed.

Actually the last two statements are to print what happened with CreateTransactionResponse. I could print this messages(null) as  controller.execute(Environment.SANDBOX) ran successfully. At this point, I don't have any clue as what to do.

 

Since the source it also on the github.com, you could look to see what it doing.

Any luck with this API?

 

looks lke we are missing something so obvious?. I am also facing this problem.