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
05-17-2017 10:51 PM
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;
}
05-18-2017 01:51 AM - edited 05-18-2017 02:00 AM
Thank you,
there is only change in providing the OpaqueDataType instead of CreditCard Details.
05-18-2017 03:34 AM
Yes, your application uses the nonce to replace the payment details in standard Authorize.Net API calls.
05-18-2017 08:01 AM