I can use visa to do purchase with production api login id and transaction key by using real credit card data in java. Yet when I do sandbox test in java, it fails. Response is null. The detail error message is "sun.reflect.annotation.TypeNotPresentExceptionProxy". For sandbox test, I use Sandbox api login id and transaction key. Is Sandbox connected? The codes are as below:
ApiOperationBase.setEnvironment(Environment.SANDBOX);
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName("sandbox_api_login_id");
merchantAuthenticationType.setTransactionKey("sandbox_transaction_key");
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
// Populate the payment data
net.authorize.api.contract.v1.PaymentType paymentType =
new net.authorize.api.contract.v1.PaymentType();
CreditCardType creditCard = new CreditCardType();
creditCard.setCardNumber("4111111111111111>");
creditCard.setExpirationDate("0822");
paymentType.setCreditCard(creditCard);
// Create the payment transaction request
TransactionRequestType txnRequest = new TransactionRequestType();
txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
txnRequest.setPayment(paymentType);
txnRequest.setAmount(new BigDecimal(500.00));
// Make the API Request
CreateTransactionRequest apiRequest = new CreateTransactionRequest();
apiRequest.setTransactionRequest(txnRequest);
CreateTransactionController controller = new CreateTransactionController(apiRequest);
controller.execute();
CreateTransactionResponse response = controller.getApiResponse();
08-17-2017 09:26 AM