Reply
Member
Posts: 2
Registered: ‎05-17-2017

integration of Accept.js in Java

Hi 

we are trying to integrate Accept.js into our website and i was able to get the response.opaqueData.dataValue from the server.

 

Document says to use 

Create an Accept Payment Transaction but i dont see an example in java for this API.

 

could you please provide me example in java

Posts: 146
Topics: 0
Kudos: 28
Blog Posts: 0
Ideas: 0
Solutions: 10
Registered: ‎04-28-2017

Re: integration of Accept.js in Java

[ Edited ]

If you are using the SDK:

 public static ANetApiResponse run(String apiLoginId, String transactionKey, String opaqueDataValue, BigDecimal amount)
{
ApiOperationBase.setEnvironment(Environment.SANDBOX);

MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
merchantAuthenticationType.setName(apiLoginId);
merchantAuthenticationType.setTransactionKey(transactionKey);
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);

OpaqueDataType op = new OpaqueDataType();
op.setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT");
op.setDataValue(opaqueDataValue);
PaymentType paymentOne = new PaymentType();
paymentOne.setOpaqueData(op);

TransactionRequestType transactionRequest = new TransactionRequestType();
transactionRequest.setAmount(new BigDecimal(amount));
transactionRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
transactionRequest.setPayment(paymentOne);
CreateTransactionRequest apiRequest = new CreateTransactionRequest();
apiRequest.setTransactionRequest(transactionRequest);
CreateTransactionController controller = new CreateTransactionController(apiRequest);
controller.execute();
CreateTransactionResponse response = controller.getApiResponse();

if (response!=null) {
// If API Response is ok, check the transaction response
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
TransactionResponse result = response.getTransactionResponse();
if(result.getMessages() != null){
System.out.println("Successfully created transaction with Transaction ID: " + result.getTransId());
System.out.println("Response Code: " + result.getResponseCode());
System.out.println("Message Code: " + result.getMessages().getMessage().get(0).getCode());
System.out.println("Description: " + result.getMessages().getMessage().get(0).getDescription());
System.out.println("Auth code : " + result.getAuthCode());
}
else {
System.out.println("Failed Transaction.");
if(response.getTransactionResponse().getErrors() != null){
System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode());
System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText());
}
}
}
else {
System.out.println("Failed Transaction.");
if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){
System.out.println("Error Code: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode());
System.out.println("Error message: " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText());
}
else {
System.out.println("Error Code: " + response.getMessages().getMessage().get(0).getCode());
System.out.println("Error message: " + response.getMessages().getMessage().get(0).getText());
}
}
}
else {
System.out.println("Null Response.");
}

return response;
}
Powered by NexWebSites.com -
Certified Authorize.net developers
Member
Posts: 2
Registered: ‎05-17-2017

Re: integration of Accept.js in Java

Thank you, 

 

there is only change in providing the OpaqueDataType instead of CreditCard Details.

Posts: 146
Topics: 0
Kudos: 28
Blog Posts: 0
Ideas: 0
Solutions: 10
Registered: ‎04-28-2017

Re: integration of Accept.js in Java

Yes, your application uses the nonce to replace the payment details in standard Authorize.Net API calls.

Powered by NexWebSites.com -
Certified Authorize.net developers