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

com.hps.integrator.fluent.GiftCardVoidBuilder 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.gift.HpsGiftCardResponse;
import com.hps.integrator.infrastructure.Element;
import com.hps.integrator.infrastructure.ElementTree;
import com.hps.integrator.infrastructure.HpsException;
import com.hps.integrator.services.fluent.HpsFluentGiftService;

public class GiftCardVoidBuilder extends HpsBuilderAbstract {
    Integer transactionId;

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

    public GiftCardVoidBuilder(HpsFluentGiftService service) {
        super(service);
    }

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

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

        ElementTree response = service.submitTransaction(transaction);
        return new HpsGiftCardResponse().fromElementTree(response);
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy