All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.braintreegateway.TransactionRefundRequest Maven / Gradle / Ivy

The newest version!
package com.braintreegateway;

import java.math.BigDecimal;

/**
 * Provides a fluent interface to build up refund requests around {@link Transaction Transactions}.
 */
public class TransactionRefundRequest extends Request {
    private BigDecimal amount;
    private String merchantAccountId;
    private String orderId;

    public TransactionRefundRequest() {
    }

    public TransactionRefundRequest amount(BigDecimal amount) {
        this.amount = amount;
        return this;
    }

    public TransactionRefundRequest orderId(String orderId) {
        this.orderId = orderId;
        return this;
    }

    public TransactionRefundRequest merchantAccountId(String merchantAccountId) {
        this.merchantAccountId = merchantAccountId;
        return this;
    }

    @Override
    public String toQueryString() {
        return toQueryString("transaction");
    }

    @Override
    public String toQueryString(String root) {
        return buildRequest(root).toQueryString();
    }

    @Override
    public String toXML() {
        return buildRequest("transaction").toXML();
    }

    protected RequestBuilder buildRequest(String root) {
        RequestBuilder builder = new RequestBuilder(root)
            .addElement("amount", amount)
            .addElement("merchantAccountId", merchantAccountId)
            .addElement("orderId", orderId);

        return builder;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy