src/test/java/com/squareup/connect/api/TransactionsApiTest.java
@Test
    public void createRefundTest() throws ApiException {
        Transaction transaction = api.charge(locationId, new ChargeRequest()
            .idempotencyKey(UUID.randomUUID().toString())
            .amountMoney(new Money()
                .amount(200L)
                .currency("USD"))
            .cardNonce(cardNonce)).getTransaction();


        String idempotencyKey = UUID.randomUUID().toString();
        CreateRefundRequest body = new CreateRefundRequest()
            .idempotencyKey(idempotencyKey)
            .tenderId(transaction.getTenders().get(0).getId())
            .amountMoney(new Money()
                .amount(100L)
                .currency("USD"))
            .reason("Cancelled order");
        CreateRefundResponse response = api.createRefund(locationId, transaction.getId(), body);

        assertTrue(response.getErrors().isEmpty());
        assertNotNull(response.getRefund().getId());
    }
/**
     * CreateRefund
     *
     * Initiates a refund for a previously charged tender.
     *
     * @throws ApiException
     *          if the Api call fails
     */
CreateRefund
Initiates a refund for a previously charged tender.

@throws ApiException
if the Api call fails
CreateRefund Initiates a refund for a previously charged tender . @throws ApiException if the Api call fails
@Test
    public void createRefundTest() throws ApiException {
        Transaction transaction = api.charge(locationId, new ChargeRequest()
            .idempotencyKey(UUID.randomUUID().toString())
            .amountMoney(new Money()
                .amount(200L)
                .currency("USD"))
            .cardNonce(cardNonce)).getTransaction();
        String idempotencyKey = UUID.randomUUID().toString();
        CreateRefundRequest body = new CreateRefundRequest()
            .idempotencyKey(idempotencyKey)
            .tenderId(transaction.getTenders().get(0).getId())
            .amountMoney(new Money()
                .amount(100L)
                .currency("USD"))
            .reason("Cancelled order");
        CreateRefundResponse response = api.createRefund(locationId, transaction.getId(), body);
        assertTrue(response.getErrors().isEmpty());
        assertNotNull(response.getRefund().getId());
    }
@ Test public void createRefundTest ( ) throws ApiException { Transaction transaction = api . charge ( locationId , new ChargeRequest ( ) . idempotencyKey ( UUID . randomUUID ( ) . toString ( ) ) . amountMoney ( new Money ( ) . amount ( 200L ) . currency ( "USD" ) ) . cardNonce ( cardNonce ) ) . getTransaction ( ) ; String idempotencyKey = UUID . randomUUID ( ) . toString ( ) ; CreateRefundRequest body = new CreateRefundRequest ( ) . idempotencyKey ( idempotencyKey ) . tenderId ( transaction . getTenders ( ) . get ( 0 ) . getId ( ) ) . amountMoney ( new Money ( ) . amount ( 100L ) . currency ( "USD" ) ) . reason ( "Cancelled order" ) ; CreateRefundResponse response = api . createRefund ( locationId , transaction . getId ( ) , body ) ; assertTrue ( response . getErrors ( ) . isEmpty ( ) ) ; assertNotNull ( response . getRefund ( ) . getId ( ) ) ; }
CreateRefund
 Initiates a refund for a previously charged tender.
CreateRefund Initiates a refund for a previously charged tender .