Interface PaymentProvider<P extends PaymentSummary>

  • All Known Implementing Classes:
    ExternalPaymentProvider

    public interface PaymentProvider<P extends PaymentSummary>
    Provider for interfacing with a Payment Management system for operations around payment related entities. Typically utilizes WebClient to make requests to an external REST API.
    Author:
    Dima Myroniuk (dmyroniuk), Sunny Yu
    • Method Detail

      • readByCartId

        default List<P> readByCartId​(@NonNull
                                     @NonNull String cartId,
                                     @Nullable
                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Retrieves a list of PaymentSummaries that belong to the given Cart.getId().
        Parameters:
        cartId - the Cart.getId() of the PaymentSummaries to retrieve
        contextInfo - context information around sandbox and multitenant state.
        Returns:
        a list of PaymentSummaries that belong to the given Cart.getId()
      • readAllByOwnerTypeAndOwnerId

        List<P> readAllByOwnerTypeAndOwnerId​(String ownerType,
                                             String ownerId,
                                             @Nullable
                                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Retrieves a list of PaymentSummaries that belong to the given owner type and owner id.
        Parameters:
        ownerType - the owner type of the PaymentSummaries to retrieve
        ownerId - the owner id of the PaymentSummaries to retrieve
        contextInfo - context information around sandbox and multitenant state.
        Returns:
        a list of PaymentSummaries based on the given owner type and owner id
      • patchPayment

        default PaymentSummary patchPayment​(@NonNull
                                            @NonNull UpdatePaymentRequest updatePaymentRequest,
                                            @NonNull
                                            @NonNull Integer version,
                                            @Nullable
                                            com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Updates the payment based on the provided UpdatePaymentRequest. This method can be used to partially update the payment. To do so provide only the fields you would like to update. The default implementation archives the payment if UpdatePaymentRequest.getAmount() is equal to zero.
        Parameters:
        updatePaymentRequest - the request payload used to update the payment
        version - the payment version
        context - Context information related to multitenancy
        Returns:
        the updated payment summary.
      • patchPayment

        PaymentSummary patchPayment​(UpdatePaymentRequest updatePaymentRequest,
                                    Integer version,
                                    @Nullable
                                    String lockToken,
                                    @Nullable
                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Updates the payment based on the provided UpdatePaymentRequest. This method can be used to partially update the payment. To do so provide only the fields you would like to update. The default implementation archives the payment if UpdatePaymentRequest.getAmount() is equal to zero.
        Parameters:
        updatePaymentRequest - the request payload used to update the payment
        version - the payment version
        context - Context information related to multitenancy
        Returns:
        the updated payment summary.
      • archivePayment

        void archivePayment​(String paymentId,
                            Integer version,
                            @Nullable
                            com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Archives the payment based on the provided id and version.
        Parameters:
        paymentId - the context id of the payment
        version - the payment version
        context - context information related to multitenancy
      • lockCartPayments

        Map<String,​String> lockCartPayments​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                                  @Nullable
                                                  com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Locks the cart's payments to ensure that all of the work done within the CheckoutWorkflow and checkout process in general is consistently interacting with payments that will not change. With these locks in place, only this executing process will have access to modify the payments, until the lock TTL expires. Note: make sure that the checkout process can sufficiently be contained within the payment lock TTL. This can be configured in PaymentTransactionServices.
        Parameters:
        cart - the Cart whose payments are to be locked.
        contextInfo - context information around sandbox and multitenant state.
        Returns:
        A map of payment id to lock token.
        Throws:
        PaymentLockException - if a lock could not be obtained.
      • unlockCartPayments

        void unlockCartPayments​(Collection<String> lockTokens,
                                @Nullable
                                com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Unlocks the cart's payments, based on the lock tokens that were previously obtained via lockCartPayments(Cart, ContextInfo).
        Parameters:
        lockTokens - Tokens that can be used to unlock the cart's payments