cancel
Showing results for 
Search instead for 
Did you mean: 

CIM java code for charging an existing customer profile

I've got my code so that I can create customer profiles and payment profiles, but I'm running into a wall when trying to build the code to be able to charge one of those customer profiles.

I've coded to the CIMTest.java code as such:

// Create an auth capture txn request
net.authorize.cim.Transaction transaction = merchant.createCIMTransaction(TransactionType.CREATE_CUSTOMER_PROFILE_TRANSACTION);

transaction.setRefId(refId);
transaction.setCustomerProfileId(customerProfileId);
transaction.setCustomerPaymentProfileId(customerPaymentProfileId);
//transaction.setCustomerShippingAddressId(customerShippingAddressId);  // not adding a shipping address

paymentTransaction.setTransactionType(net.authorize.TransactionType.AUTH_CAPTURE);
transaction.setPaymentTransaction(paymentTransaction);

Result<Transaction> result = (Result<Transaction>) merchant.postTransaction(transaction);

 

which produces this xml:

<?xml version="1.0"?>
<createCustomerProfileTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
	<merchantAuthentication>
		<name>xxxxxxxxx</name>
		<transactionKey>xxxxxxxxxxxxxxxx</transactionKey>
	</merchantAuthentication>
	<refId>REFID:1409637084474</refId>
	<transaction>
		<profileTransAuthCapture>
			<customerProfileId>28572301</customerProfileId>
			<customerPaymentProfileId>25939915</customerPaymentProfileId>
			<recurringBilling>false</recurringBilling>
		</profileTransAuthCapture>
	</transaction>
</createCustomerProfileTransactionRequest>

 and when that is posted this error comes back:

E00003:The element 'profileTransAuthCapture' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
has invalid child element 'customerProfileId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
List of possible elements expected: 'amount' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.

I've got the same code basically that is in the auth.net unit test code, So what's wrong with this?  

Why doesn't this work?  And what do I have to change to make it work?

 

wavebiddev
Contributor
4 REPLIES 4

Missing an amount

 

doc in here

http://developer.authorize.net/api/cim/

RaynorC1emen7
Expert

Thank you for your response.  I've read through the doc and the code and obviously the error and your post.  I still don't see anything that explains why profileTransAuthCapture doesn't like the customerProfileId child element.  Also if I'm missing the amount, then how/where do I add it?  I'm using JAVA so I'm not directly manipulating the XML and there for I can't just add in a tag.  (I wish I could, this would be easier).

To me it looks like the library is not working as it should.

Maybe I need to use the Order object?  Is there example Java code somewhere for this?  Nothing in the example code I can find shows how to charge an existing Customer Profile.

The error is saiding amount is required and it should be before customerprofileid.

 

look at the public void setUp()

order = Order.createOrder();

....

 

 

paymentTransaction.setOrder(order);

We were able to successfully use the invoice number in Java.

 

Look under OrderType.  You can set both Invoice Number (as invoiceNum) and a Description (as decription).  Here is the piece of our code where we set it.

 

// Create the payment transaction request
        TransactionRequestType txnRequest = new TransactionRequestType();
        txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
        txnRequest.setAmount(new BigDecimal(amountTotal).setScale(2, RoundingMode.CEILING));
        txnRequest.setProfile(profileToCharge);
        OrderType ot=new OrderType();
        ot.setInvoiceNumber("Put Your Invoice Number Here");
        ot.setDescription("A description of the transaction");
        txnRequest.setOrder(ot);
        ArrayOfLineItem lineItemsArray = new ArrayOfLineItem();
            List<LineItemType> lineItems = lineItemsArray.getLineItem();
            LineItemType line1 = new LineItemType();
            line1.setName("Some Detail");
            line1.setDescription("Some Detail Description");
            line1.setItemId("1");
            line1.setQuantity( BigDecimal.valueOf( 1 ) );
            line1.setTaxable( false );
            line1.setUnitPrice( BigDecimal.valueOf(amount) );
            lineItems.add( line1 );
            LineItemType line2 = new LineItemType();
            line2.setName("Another Item");
            line2.setDescription("Another description for the 2nd item");
            line2.setItemId("2");
            line2.setQuantity( BigDecimal.valueOf( 1 ) );
            line2.setTaxable( false );
            line2.setUnitPrice( BigDecimal.valueOf(adminfee) );
            lineItems.add( line2 );
kennydavis416
Member