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

com.hps.integrator.fluent.CreditVoidBuilder Maven / Gradle / Ivy

Go to download

The SecureSubmit Java SDK simplifies processing of credit card transactions using Heartland Payment Systems' Portico Payment Gateway

There is a newer version: v2.5.2
Show newest version
package com.hps.integrator.fluent;

import com.hps.integrator.entities.HpsTransaction;
import com.hps.integrator.infrastructure.Element;
import com.hps.integrator.infrastructure.ElementTree;
import com.hps.integrator.infrastructure.HpsException;
import com.hps.integrator.services.fluent.HpsFluentCreditService;

public class CreditVoidBuilder extends HpsBuilderAbstract {
    Integer transactionId;
    String clientTransactionId;

    public CreditVoidBuilder withTransactionId(Integer transactionId) {
        this.transactionId = transactionId;
        return this;
    }

    public CreditVoidBuilder withClientTransactionId(String clientTransactionId) {
        this.clientTransactionId = clientTransactionId;
        return this;
    }

    public CreditVoidBuilder(HpsFluentCreditService service) {
        super(service);
    }

    @Override
    public HpsTransaction execute() throws HpsException {
        super.execute();

        Element transaction = Et.element("CreditVoid");
        Et.subElement(transaction, "GatewayTxnId").text(transactionId.toString());

        HpsTransaction response = new HpsTransaction().fromElementTree(service.submitTransaction(transaction, clientTransactionId));
        response.setResponseCode("00");
        response.setResponseText("");
        return response;
    }

    @Override
    protected void setupValidations() throws HpsException {
        this.addValidation(new HpsBuilderValidation("transactionIdIsNotNull", "TransactionID is required."));
    }

    private boolean transactionIdIsNotNull(){
        return this.transactionId != null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy