AuthorizeNet / inperson-sdk-android

Mobile SDK for Android point-of-sale applications
Other
23 stars 38 forks source link

Non-EMV Transaction not showing up in Authorize.net account #75

Closed cmcfatter closed 3 years ago

cmcfatter commented 3 years ago

I am trying to implement a way to charge a credit card by keying in the information rather than swiping the card. I am referencing the Non-EMV Code Samples in the documentation. My code is saying that the transaction gets posted when I run it but it never shows up in Authorize.net. What am I doing wrong that is not making it show on my authorize.net merchant account? Here is my code:

Thread thread = new Thread(new Runnable() {

@Override public void run() {

   try  {
       //if merchant information is null, have user login again
       if (AppManager.merchant == null) {
           Intent i = new Intent(context, LoginActivity.class);
           i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
           startActivity(i);
           finish();
           return;
        }

       net.authorize.aim.Transaction merchantTransaction = 
       net.authorize.aim.Transaction.createTransaction(AppManager.merchant, TransactionType.AUTH_CAPTURE, new 
       BigDecimal(1.0));

       //create new credit card object with required fields
       CreditCard creditCard = CreditCard.createCreditCard();
       creditCard.setCreditCardNumber("4111111111111111");
       creditCard.setExpirationMonth("11");
       creditCard.setExpirationYear("2021");
       creditCard.setCardCode("123");

       //create order item and add to transaction object
       Order order =  Order.createOrder();
       OrderItem oi =  OrderItem.createOrderItem();
       oi.setItemId("001");
       oi.setItemName("testItem");
       oi.setItemDescription("Goods");
       oi.setItemPrice(new BigDecimal(1.1));
       oi.setItemQuantity("1");
       oi.setItemTaxable(false);
       order.addOrderItem(oi);
       order.setTotalAmount(new BigDecimal(1.1));

       merchantTransaction.setCreditCard(creditCard);
       merchantTransaction.setOrder(order);

       try{
           //post the transaction to Gateway
           net.authorize.aim.Result authCaptureResult = (net.authorize.aim.Result) 
           AppManager.merchant.postTransaction(merchantTransaction);
           Log.i(TAG, "posted transaction");
           //net.authorize.aim.Result authCaptureResult = (net.authorize.aim.Result) 
           testMerchant.postTransaction(authCaptureTransaction);
       } catch (Exception ex){
            Log.i(TAG, "failed to post transaction");
            Log.i(TAG, "Error message: " + ex.toString());
       }

  } catch (Exception e) {
           e.printStackTrace();
  }

} });

thread.start();

amimishr commented 3 years ago

@cmcfatter Just to verify from my end, I took your code, cleaned up little bit and wrote it inside sample app's MainActivity.java -

void processCardTransaction(){ new Thread(new Runnable() { @Override public void run() { net.authorize.aim.Transaction merchantTransaction = net.authorize.aim.Transaction.createTransaction(AppManager.merchant, net.authorize.TransactionType.AUTH_CAPTURE, new BigDecimal(1.0));

            //create new credit card object with required fields
            CreditCard creditCard = CreditCard.createCreditCard();
            creditCard.setCreditCardNumber("4111111111111111");
            creditCard.setExpirationMonth("11");
            creditCard.setExpirationYear("2021");
            creditCard.setCardCode("123");

            //create order item and add to transaction object
            Order order =  Order.createOrder();
            OrderItem oi =  OrderItem.createOrderItem();
            oi.setItemId("001");
            oi.setItemName("testItem");
            oi.setItemDescription("Goods");
            oi.setItemPrice(new BigDecimal(1.1));
            oi.setItemQuantity("1");
            oi.setItemTaxable(false);
            order.addOrderItem(oi);
            order.setTotalAmount(new BigDecimal(1.1));

            merchantTransaction.setCreditCard(creditCard);
            merchantTransaction.setOrder(order);

            try{
                net.authorize.Result result = AppManager.merchant.postTransaction(merchantTransaction);
                if (result != null){
                    Log.d(TAG, "processCardTransaction: "+result.toString());
                }
            } catch (Exception ex){
                Log.i(TAG, "failed to post transaction");
                Log.i(TAG, "Error message: " + ex.toString());
            }
        }
    }).start();
}

The on the click of "Process Payment With EMV" button, instead of doing EMV transaction, i called up this method. The transaction was successful as shown in the following logcat log-

021-08-23 20:27:44.377 556-863/authorize.net.inperson_sdk_android D/MainActivity: processCardTransaction: Account Number: XXXX1111 Account Type: VISA Auth Code: 32MWWD Transaction ID: 40065442989 Transaction Hash: null Transaction Type:AUTH_CAPTURE Response Code: APPROVED Result Code:APPROVED XML Response: <?xml version="1.0" encoding="utf-8"?><createTransactionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><sessionToken>ulsJbRdugzeSm2bNWnBY97uvFaLdrnfgwTzHGWoRzEi01oPkYxuhKirQB6m$cm2MWmBJBF5pRmfBoAZklMMn$qOjicwGL7SmKy1WyhHw4dGqf7V0kDEinNO_z$APbgSUSqtd0emOceDt85xG_PrZtwAA</sessionToken><transactionResponse><responseCode>1</responseCode><authCode>32MWWD</authCode><avsResultCode>Y</avsResultCode><cvvResultCode>P</cvvResultCode><cavvResultCode>2</cavvResultCode><transId>40065442989</transId><refTransID /><transHash /><testRequest>0</testRequest><accountNumber>XXXX1111</accountNumber><accountType>Visa</accountType><messages><message><code>1</code><description>This transaction has been approved.</description></message></messages><transHashSha2 /><networkTransId>VV0CU7O3LBR5PDPFV85U4OA</networkTransId></transactionResponse></createTransactionResponse>

To see this transaction in your backend, once you login to merchant interface portal, you can go to "Transaction search" tab and search for "unsettled" transaction. You should be able to see this transaction there.

image

cmcfatter commented 3 years ago

Thank you for your quick answer. I copied your cleaned up code into my project and saw that it was getting error E00027 because Bill To First Name, Bill To Last Name, etc. are required. It seems like I need to change some settings in my account to fix that. Thanks for your help!