
com.commercetools.payment.domain.PaymentServiceProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
The commercetools java payment project intend is to make payment integration easy
The newest version!
package com.commercetools.payment.domain;
import com.commercetools.payment.model.CreatePaymentData;
import com.commercetools.payment.model.CreatePaymentTransactionData;
import com.commercetools.payment.model.PaymentCreationResult;
import com.commercetools.payment.model.PaymentTransactionCreationResult;
import io.sphere.sdk.payments.PaymentMethodInfo;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import static java.lang.String.format;
/**
* A payment service provider provides functions that can be used to handle payment related tasks in
* a PSP specific way.
* @author mgatz
*/
public interface PaymentServiceProvider {
/**
* @return a unique identifier of the payment service provider
*/
String getId();
/**
* @return an unfiltered list of payment methods this PSP supports
*/
List getAvailablePaymentMethods();
/**
* Create a (filtered) list of payment methods.
* @param filter a filter function that can be applied to the whole list of payment methods before returning them
* @return a list of payment methods this PSP supports
*/
List getAvailablePaymentMethods(@Nullable Function, List> filter);
/**
* Create a function that can create a payment for the passed method Id
*
* @param methodId the ID of the payment method to be used for the payment object
* @return a function method creating the payment object for the passed method Id
*
* @throws UnsupportedOperationException if such {@code methodId} is not implemented
*/
Function> provideCreatePaymentHandler(String methodId) throws UnsupportedOperationException;
/**
* Create a function that can create a payment transaction for a payment object
* and has the ability to handle overriding of configuration values via given key value pairs.
*
* @param methodId the ID of the payment method to be used for the payment transaction object
* @return a function method creating a payment transaction
*
* @throws UnsupportedOperationException if such {@code methodId} is not implemented
*/
Function> provideCreatePaymentTransactionHandler(String methodId) throws UnsupportedOperationException;
@Nonnull
default UnsupportedOperationException createUnsupportedMethodException(String methodId) throws UnsupportedOperationException {
return new UnsupportedOperationException(format("[%s] does not support [%s] method",
this.getClass().getName(), methodId));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy