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

com.hps.integrator.entities.altpayment.HpsAltPaymentResponse 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.entities.altpayment;

import com.hps.integrator.entities.credit.HpsAuthorization;
import com.hps.integrator.infrastructure.Element;
import com.hps.integrator.infrastructure.ElementTree;
import com.hps.integrator.infrastructure.HpsProcessorError;

import java.util.Dictionary;
import java.util.Hashtable;

public class HpsAltPaymentResponse extends HpsAuthorization {
    HpsProcessorError error;

    public HpsAltPaymentResponse fromElementTree(ElementTree rsp) {
        super.fromElementTree(rsp);

        Element response = rsp.get("Transaction").firstChild();
        if(response.getInt("RspCode") != 0){
            Dictionary error = nvpToArray(response.get("Processor").get("Response"));
            this.error = new HpsProcessorError();
            this.error.setCode(error.get("Code") != null ? error.get("Code") : null);
            this.error.setMessage(error.get("Message") != null ? error.get("Message") : null);
            this.error.setType(error.get("Type") != null ? error.get("Type") : null);
        }

        return this;
    }

    protected Dictionary nvpToArray(Element pairs) {
        Dictionary rvalue = new Hashtable();
        for(Element pair: pairs.getAll())
            rvalue.put(pair.getString("Name"), pair.getString("Value"));
        return rvalue;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy