Class DefaultPaymentServiceImpl

    • Constructor Detail

      • DefaultPaymentServiceImpl

        public DefaultPaymentServiceImpl()
    • Method Detail

      • authorize

        public PaymentTransactionEntryModel authorize​(java.lang.String merchantTransactionCode,
                                                      java.math.BigDecimal amount,
                                                      java.util.Currency currency,
                                                      AddressModel deliveryAddress,
                                                      java.lang.String subscriptionID,
                                                      java.lang.String cv2,
                                                      java.lang.String paymentProvider)
        Description copied from interface: PaymentService
        authorize payment
        Specified by:
        authorize in interface PaymentService
        Parameters:
        merchantTransactionCode - the transaction code
        amount - the amount
        currency - the currency
        deliveryAddress - the delivery address (paymentAddress is used if null)
        subscriptionID - the subscriptionID
        cv2 - card verification value
        paymentProvider - code of payment provider
        Returns:
        Payment Transaction Entry
      • authorize

        public PaymentTransactionEntryModel authorize​(java.lang.String merchantTransactionCode,
                                                      java.math.BigDecimal amount,
                                                      java.util.Currency currency,
                                                      AddressModel deliveryAddress,
                                                      AddressModel paymentAddress,
                                                      CardInfo card)
        Description copied from interface: PaymentService
        authorize payment
        Specified by:
        authorize in interface PaymentService
        Parameters:
        merchantTransactionCode - the transaction code
        amount - the amount
        currency - the currency
        deliveryAddress - the delivery address (paymentAddress is used if null)
        paymentAddress - the payment address
        card - the card
        Returns:
        Payment Transaction Entry
      • authorize

        public PaymentTransactionEntryModel authorize​(PaymentTransactionModel transaction,
                                                      java.math.BigDecimal amount,
                                                      java.util.Currency currency,
                                                      AddressModel deliveryAddress,
                                                      java.lang.String subscriptionID,
                                                      java.lang.String paymentprovider)
        authorize payment
        note: the code of the assigned payment transaction will be used as code-basecode during the PaymentTransactionEntryModel.CODE code generation process, which represents the main benefit of this method.
        Specified by:
        authorize in interface PaymentService
        Parameters:
        transaction - the payment transaction
        amount - the amount
        currency - the currency
        deliveryAddress - the delivery address
        subscriptionID - will be used for identifying the user profile (see payment tokenization)
        paymentprovider - code of payment provider
        Returns:
        Payment Transaction Entry
        Throws:
        AdapterException
      • authorize

        public PaymentTransactionEntryModel authorize​(PaymentTransactionModel transaction,
                                                      java.math.BigDecimal amount,
                                                      java.util.Currency currency,
                                                      AddressModel deliveryAddress,
                                                      java.lang.String subscriptionID)
        Description copied from interface: PaymentService
        authorize payment
        Specified by:
        authorize in interface PaymentService
        Parameters:
        transaction - the payment transaction
        amount - the amount
        currency - the currency
        deliveryAddress - the delivery address (paymentAddress is used if null)
        subscriptionID - the subscriptionID
        Returns:
        Payment Transaction Entry
      • authorizeInternal

        protected PaymentTransactionEntryModel authorizeInternal​(PaymentTransactionModel transaction,
                                                                 java.math.BigDecimal amount,
                                                                 java.util.Currency currency,
                                                                 BillingInfo shippingInfo,
                                                                 CardInfo card,
                                                                 java.lang.String subscriptionID,
                                                                 java.lang.String cv2,
                                                                 java.lang.String paymentProvider)
        ... internally used authorization.
        Parameters:
        transaction - the payment transaction
        amount - the amount we ant to authorize
        currency - the related currency of the amount
        shippingInfo - the shipping info
        card - the card info
        subscriptionID - will be used for identifying the user profile (see payment tokenization)
        Throws:
        AdapterException
      • getNewPaymentTransactionEntryCode

        public java.lang.String getNewPaymentTransactionEntryCode​(PaymentTransactionModel transaction,
                                                                  PaymentTransactionType paymentTransactionType)
        Generate new merchant transaction code for payment transaction entries based on code for whole transaction
        Specified by:
        getNewPaymentTransactionEntryCode in interface PaymentService
        Parameters:
        transaction - An associated Payment transaction
        paymentTransactionType - A type of entry.
        Returns:
        A new unique code withing a transaction context.
      • createBillingInfo

        protected BillingInfo createBillingInfo​(AddressModel deliveryAddress,
                                                AddressModel paymentAddress,
                                                CardInfo card)
        creates the billing info based on the assigned delivery address instance. In case the deliveryAddress is null, we will use the billing info of the assigned CardInfo instance.
        Parameters:
        deliveryAddress - the delivery address
        paymentAddress - the payment address
        card - the card info
        Returns:
        the billing info
      • refundStandalone

        public PaymentTransactionEntryModel refundStandalone​(java.lang.String merchantTransactionCode,
                                                             java.math.BigDecimal amount,
                                                             java.util.Currency currency,
                                                             AddressModel paymentAddress,
                                                             CardInfo card)
        Description copied from interface: PaymentService
        Refund value to a card (no transaction is obligatory)
        Specified by:
        refundStandalone in interface PaymentService
        Parameters:
        merchantTransactionCode - any code to locate transaction
        amount - amount to refund
        currency - currency, used for refunding
        paymentAddress - address to refund
        card - card to refund
        Returns:
        payment transaction entry
      • refundStandalone

        public PaymentTransactionEntryModel refundStandalone​(java.lang.String merchantTransactionCode,
                                                             java.math.BigDecimal amount,
                                                             java.util.Currency currency,
                                                             AddressModel paymentAddress,
                                                             CardInfo card,
                                                             java.lang.String providerName,
                                                             java.lang.String subscriptionId)
        Description copied from interface: PaymentService
        Refund value to a card (no transaction is obligatory)
        Specified by:
        refundStandalone in interface PaymentService
        Parameters:
        merchantTransactionCode - any code to locate transaction
        amount - amount to refund
        currency - currency, used for refunding
        paymentAddress - address to refund
        card - card to refund
        providerName - name of the payment provider
        subscriptionId - subscription identifier
        Returns:
        payment transaction entry
      • attachPaymentInfo

        public void attachPaymentInfo​(PaymentTransactionModel paymentTransactionModel,
                                      UserModel userModel,
                                      CardInfo cardInfo,
                                      java.math.BigDecimal amount)
        Attaches PaymentInfo to the assigned PaymentTransactionModel instance by using the configured PaymentInfoCreatorStrategy.
        You can call this method after/before authorization by yourself if there is a need for it.
        Specified by:
        attachPaymentInfo in interface PaymentService
        Parameters:
        paymentTransactionModel - the payment transaction
        userModel - the user
        cardInfo - the card info
        amount - the amount
      • createSubscription

        public NewSubscription createSubscription​(PaymentTransactionModel transaction,
                                                  AddressModel paymentAddress,
                                                  CardInfo card)
        Description copied from interface: PaymentService
        Creates a subscription at the payment provider side and stores sensitive data there. Future payment authorization and refundStandalone calls will not have to provide the sensitive information, subscriptionID would be sufficient. Call this method after a successful authorize txn and provide THE SAME billing and card info. Please note: the card and billing info is not saved in the returning PaymentTransactionEntryModel from authorize method call ON PURPOSE.
        Specified by:
        createSubscription in interface PaymentService
        Parameters:
        transaction - a previous recent successful authorize payment transaction
        paymentAddress - the same billing address as for the authorize txn
        card - the same card as for the authorize txn
        Returns:
        instance of NewSubscription
      • createSubscription

        public NewSubscription createSubscription​(java.lang.String merchantTransactionCode,
                                                  java.lang.String paymentProvider,
                                                  java.util.Currency currency,
                                                  AddressModel paymentAddress,
                                                  CardInfo card)
        Description copied from interface: PaymentService
        Creates a subscription at the payment provider side and stores sensitive data there. Future payment authorization and refundStandalone calls will not have to provide the sensitive information, subscriptionID would be sufficient. This method does not need an authorized payment transaction, the authorization is expected to be done implicitly by the payment provider.
        Specified by:
        createSubscription in interface PaymentService
        Parameters:
        merchantTransactionCode - the transactionCode
        paymentProvider - the paymentProvider who will hold the subscription. You might also have just one payment provider in your implementation.
        currency - the default customer's currency
        paymentAddress - the same billing address as for the authorize txn
        card - the same card as for the authorize txn
        Returns:
        new subscription object (instance of NewSubscription)
      • updateSubscription

        public PaymentTransactionEntryModel updateSubscription​(java.lang.String merchantTransactionCode,
                                                               java.lang.String subscriptionID,
                                                               java.lang.String paymentProvider,
                                                               AddressModel paymentAddress,
                                                               CardInfo card)
        Description copied from interface: PaymentService
        Updates the data of the subscription at the payment provider.
        Specified by:
        updateSubscription in interface PaymentService
        Parameters:
        merchantTransactionCode - the transactionCode
        subscriptionID - the subscription ID
        paymentProvider - the paymentProvider who holds the subscription. You get this value from the PaymentTransactionModel of the createSubscription command. You might also have just one payment provider in your implementation.
        paymentAddress - the new billing address, could be null
        card - the updated card, could be null
        Returns:
        instance of PaymentTransactionEntryModel
      • getSubscriptionData

        public PaymentTransactionEntryModel getSubscriptionData​(java.lang.String merchantTransactionCode,
                                                                java.lang.String subscriptionID,
                                                                java.lang.String paymentProvider,
                                                                BillingInfo billingInfo,
                                                                CardInfo card)
        Description copied from interface: PaymentService
        Gets the stored card info or payment address
        Specified by:
        getSubscriptionData in interface PaymentService
        Parameters:
        merchantTransactionCode - the transactionCode
        subscriptionID - the subscription ID
        paymentProvider - the paymentProvider who holds the subscription. You get this value from the PaymentTransactionModel of the createSubscription command. You might also have just one payment provider in your implementation.
        billingInfo - the billing address is returned in this DTO
        card - the card information is returned in this DTO
        Returns:
        instance of PaymentTransactionEntryModel
      • deleteSubscription

        public PaymentTransactionEntryModel deleteSubscription​(java.lang.String merchantTransactionCode,
                                                               java.lang.String subscriptionID,
                                                               java.lang.String paymentProvider)
        Description copied from interface: PaymentService
        Deletes the subscription at the payment provider. Warning: Deleting a customer profile is permanent. You cannot recover a deleted customer profile.
        Specified by:
        deleteSubscription in interface PaymentService
        Parameters:
        merchantTransactionCode - the transactionCode
        subscriptionID - the subscription ID
        paymentProvider - the paymentProvider who holds the subscription. You get this value from the PaymentTransactionModel of the createSubscription command. You might also have just one payment provider in your implementation.
        Returns:
        instance of PaymentTransactionEntryModel
      • setCommonI18NService

        public void setCommonI18NService​(CommonI18NService commonI18NService)
      • getModelService

        protected ModelService getModelService()
      • setModelService

        public void setModelService​(ModelService modelService)
      • setFlexibleSearchService

        public void setFlexibleSearchService​(FlexibleSearchService flexibleSearchService)
      • setTransactionCodeGenerator

        public void setTransactionCodeGenerator​(TransactionCodeGenerator transactionCodeGenerator)
      • setCardPaymentService

        public void setCardPaymentService​(CardPaymentService cardPaymentService)