Interface PaymentService

All Known Subinterfaces:
ChinesePaymentService
All Known Implementing Classes:
DefaultAlipayPaymentService, DefaultPaymentServiceImpl, DefaultWeChatPayPaymentService

public interface PaymentService
service can serve payments based on orders
  • Method Details

    • authorize

      PaymentTransactionEntryModel authorize(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID)
      authorize payment
      Parameters:
      merchantTransactionCode - the transaction code
      amount - the amount
      currency - the currency
      deliveryAddress - the delivery address (paymentAddress is used if null)
      subscriptionID - the subscriptionID
      Returns:
      Payment Transaction Entry
    • authorize

      PaymentTransactionEntryModel authorize(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID, String cv2, String paymentProvider)
      authorize payment
      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

      PaymentTransactionEntryModel authorize(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card)
      authorize payment
      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

      PaymentTransactionEntryModel authorize(PaymentTransactionModel transaction, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID, String paymentProvider)
      authorize payment
      Parameters:
      transaction - the payment transaction
      amount - the amount
      currency - the currency
      deliveryAddress - the delivery address (paymentAddress is used if null)
      subscriptionID - the subscriptionID
      paymentProvider - code of payment provider
      Returns:
      Payment Transaction Entry
    • authorize

      PaymentTransactionEntryModel authorize(PaymentTransactionModel transaction, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID)
      authorize payment
      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
    • authorize

      PaymentTransactionEntryModel authorize(PaymentTransactionModel transaction, BigDecimal amount, Currency currency, AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card)
      authorize payment
      Parameters:
      transaction - the payment transaction
      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
    • capture

      capture payment
      Parameters:
      transaction - payment transaction
      Returns:
      payment transaction entry
    • cancel

      Cancel payment
      Parameters:
      transaction - payment transaction
      Returns:
      payment transaction entry
    • refundFollowOn

      PaymentTransactionEntryModel refundFollowOn(PaymentTransactionModel transaction, BigDecimal amount)
      Refund transaction
      Parameters:
      transaction - payment transaction
      amount - amount to refund
      Returns:
      payment transaction entry
    • refundStandalone

      PaymentTransactionEntryModel refundStandalone(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel paymentAddress, CardInfo card)
      Refund value to a card (no transaction is obligatory)
      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

      default PaymentTransactionEntryModel refundStandalone(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel paymentAddress, CardInfo card, String providerName, String subscriptionId)
      Refund value to a card (no transaction is obligatory)
      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
    • partialCapture

      PaymentTransactionEntryModel partialCapture(PaymentTransactionModel transaction, BigDecimal amount)
      Take a partial capture of authorized transaction
      Parameters:
      transaction - authorized transaction
      amount - value to capture
      Returns:
      payment transaction entry
    • getPaymentTransaction

      PaymentTransactionModel getPaymentTransaction(String code)
      Parameters:
      code - the code of the PaymentTransactionModel we were looking for
      Returns:
      the PaymentTransactionModel
    • getPaymentTransactionEntry

      PaymentTransactionEntryModel getPaymentTransactionEntry(String code)
      Parameters:
      code - the code of the PaymentTransactionModel we were looking for
      Returns:
      the instance of PaymentTransactionEntryModel
    • attachPaymentInfo

      void attachPaymentInfo(PaymentTransactionModel paymentTransactionModel, UserModel userModel, CardInfo cardInfo, BigDecimal amount)
      Attaches PaymentInfo to the assigned PaymentTransactionModel instance.
      Parameters:
      paymentTransactionModel - the payment transaction
      userModel - the user
      cardInfo - the card info
      amount - the amount expressed as BigDecimal
    • createSubscription

      NewSubscription createSubscription(PaymentTransactionModel transaction, AddressModel paymentAddress, CardInfo card)
      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.
      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

      NewSubscription createSubscription(String merchantTransactionCode, String paymentProvider, Currency currency, AddressModel paymentAddress, CardInfo card)
      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.
      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

      PaymentTransactionEntryModel updateSubscription(String merchantTransactionCode, String subscriptionID, String paymentProvider, AddressModel paymentAddress, CardInfo card)
      Updates the data of the subscription at the payment provider.
      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

      PaymentTransactionEntryModel getSubscriptionData(String merchantTransactionCode, String subscriptionID, String paymentProvider, BillingInfo billingInfo, CardInfo card)
      Gets the stored card info or payment address
      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

      PaymentTransactionEntryModel deleteSubscription(String merchantTransactionCode, String subscriptionID, String paymentProvider)
      Deletes the subscription at the payment provider. Warning: Deleting a customer profile is permanent. You cannot recover a deleted customer profile.
      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
    • getNewPaymentTransactionEntryCode

      String getNewPaymentTransactionEntryCode(PaymentTransactionModel transaction, PaymentTransactionType paymentTransactionType)
      A new code for a PaymentTransactionEntryModel based on the PaymentTransactionModel associated to it and the number of entries.
      Parameters:
      transaction - An associated Payment transaction
      paymentTransactionType - A type of entry.
      Returns:
      A new unique code withing a transaction context.