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

com.commercetools.payment.nopsp.config.NoPaymentServiceConfiguration Maven / Gradle / Ivy

Go to download

The commercetools java payment project intend is to make payment integration easy

There is a newer version: 1.6.0
Show newest version
package com.commercetools.payment.nopsp.config;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.sphere.sdk.payments.PaymentMethodInfo;

import java.util.List;
import java.util.Map;

/**
 * Provides the configuration values of the default payment interface and its methods.
 *
 * Is currently read only.
 */
public class NoPaymentServiceConfiguration {
    private String interfaceId;
    private List enabledMethods;
    private Map availableMethods;

    @JsonCreator
    private NoPaymentServiceConfiguration(@JsonProperty("interfaceId") final String interfaceId,
                                          @JsonProperty("enabledMethods") final List enabledMethods,
                                          @JsonProperty("availableMethods") final Map availableMethods) {
        this.interfaceId = interfaceId;
        this.enabledMethods = enabledMethods;
        this.availableMethods = availableMethods;

    }

    public String getInterfaceId() {

        return interfaceId;
    }

    /**
     * @return the list of enabled payment methods
     */
    public List getEnabledMethods() {

        return enabledMethods;
    }

    /**
     * @return the available payment method configurations mapped by their method ID
     */
    public Map getAvailableMethods() {

        return availableMethods;
    }

    /**
     * @param methodId the method id to check
     * @return true if the method is enabled
     */
    public boolean isMethodEnabled(String methodId) {

        return this.enabledMethods.contains(methodId);
    }

    /**
     * Try finding the {@link PaymentMethodInfo} for the passed method ID.
     * @param methodId the method ID
     * @return the {@link PaymentMethodInfo} or null if none is found
     */
    public PaymentMethodInfo getMethodInfo(String methodId) {

        return this.availableMethods.get(methodId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy