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

com.unzer.payment.Charge Maven / Gradle / Ivy

package com.unzer.payment;

import com.unzer.payment.communication.HttpCommunicationException;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * Business object for Charge. Amount, currency and typeId are mandatory parameter to
 * execute a Charge.
 * The returnUrl is mandatory in case of redirectPayments like Sofort, Paypal, Giropay, Card 3DS.
 *
 * @author Unzer E-Com GmbH
 */
public class Charge extends BaseTransaction {
    private List cancelList;

    public Charge() {
        super();
        setCancelList(new ArrayList());
    }

    @Deprecated
    public Charge(Unzer unzer) {
        super(unzer);
        setCancelList(new ArrayList());
    }

    @Override
    protected String getTransactionUrl() {
        return "/v1/payments//charges/";
    }

    /**
     * @deprecated use {@link Unzer#cancelCharge(String, String)} instead
     */
    @Deprecated
    public Cancel cancel() throws HttpCommunicationException {
        return getUnzer().cancelCharge(getPayment().getId(), getId());
    }

    /**
     * @deprecated use {@link Unzer#cancelCharge(String, String, Cancel)} instead
     */
    @Deprecated
    public Cancel cancel(BigDecimal amount) throws HttpCommunicationException {
        return getUnzer().cancelCharge(getPayment().getId(), getId(), amount);
    }

    /**
     * @deprecated use {@link Unzer#cancelCharge(String, String, Cancel)} instead
     */
    @Deprecated
    public Cancel cancel(Cancel cancel) throws HttpCommunicationException {
        return getUnzer().cancelCharge(getPayment().getId(), getId(), cancel);
    }

    public List getCancelList() {
        return cancelList;
    }

    public void setCancelList(List cancelList) {
        this.cancelList = cancelList;
    }

    public Cancel getCancel(String cancelId) {
        if (cancelList == null) {
            return null;
        }
        for (Cancel cancel : cancelList) {
            if (cancelId.equalsIgnoreCase(cancel.getId())) {
                return cancel;
            }
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy