Skip to content

Commit b0e58e7

Browse files
author
brianmc
committed
Updated Sample for Refund
1 parent 7e9d0d2 commit b0e58e7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/main/java/net/authorize/sample/PaymentTransactions/RefundTransaction.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,19 @@ public static void run(String apiLoginId, String transactionKey) {
2323
merchantAuthenticationType.setTransactionKey(transactionKey);
2424
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
2525

26+
// Create a payment object, last 4 of the credit card and expiration date are required
27+
PaymentType paymentType = new PaymentType();
28+
CreditCardType creditCard = new CreditCardType();
29+
creditCard.setCardNumber("0015");
30+
creditCard.setExpirationDate("1220");
31+
paymentType.setCreditCard(creditCard);
32+
2633
// Create the payment transaction request
2734
TransactionRequestType txnRequest = new TransactionRequestType();
2835
txnRequest.setTransactionType(TransactionTypeEnum.REFUND_TRANSACTION.value());
29-
txnRequest.setRefTransId("2238786428");
36+
txnRequest.setRefTransId("2245803597");
37+
txnRequest.setAmount(new BigDecimal(1.00));
38+
txnRequest.setPayment(paymentType);
3039

3140
// Make the API Request
3241
CreateTransactionRequest apiRequest = new CreateTransactionRequest();
@@ -57,6 +66,12 @@ public static void run(String apiLoginId, String transactionKey) {
5766
else
5867
{
5968
System.out.println("Failed Transaction: "+response.getMessages().getResultCode());
69+
if(!response.getMessages().getMessage().isEmpty())
70+
System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() + " " + response.getMessages().getMessage().get(0).getText());
71+
72+
if (response.getTransactionResponse() != null)
73+
if(!response.getTransactionResponse().getErrors().getError().isEmpty())
74+
System.out.println("Transaction Error : " + response.getTransactionResponse().getErrors().getError().get(0).getErrorCode() + " " + response.getTransactionResponse().getErrors().getError().get(0).getErrorText());
6075
}
6176
}
6277

0 commit comments

Comments
 (0)