Class PaymentProviderServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.PaymentProviderServiceImpl
-
- All Implemented Interfaces:
PaymentProviderService
@Service public class PaymentProviderServiceImpl extends java.lang.Object implements PaymentProviderService
-
-
Field Summary
Fields Modifier and Type Field Description private BillingServicebillingServiceprivate CommerceItemServicecommerceItemServiceprivate CommercePropertiescommercePropertiesprivate OrderRepositoryorderRepositoryprivate SellerRepositorysellerRepositoryprivate StripeConnectServicestripeConnectServiceprivate StripeServicestripeServiceprivate YooKassaServiceyooKassaService
-
Constructor Summary
Constructors Constructor Description PaymentProviderServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>calculateItemsTotalBruttoAmount(java.lang.String orderId)Calculates total gross amount for order.OrderDTOcalculateOrder(Order order)Maps an Order object to an OrderDTO object.java.util.Map<java.lang.String,java.lang.Object>calculatePayoutAmount(java.lang.String orderId)Calculates payout amount for order.java.util.Map<java.lang.String,java.lang.Object>calculateServiceFeeBruttoAmount(java.lang.String orderId)Calculates service fee for order.Order.TaxcalculateTax(Seller buyer, Seller seller)Calculates the tax for an order based on the buyer, seller, and tax rates.java.util.Map<java.lang.String,java.lang.Object>calculateTaxAmountPrice(java.lang.String orderId)Calculates tax amount for order.java.util.Map<java.lang.String,java.lang.Object>calculateTotalPrice(java.lang.String orderId)Sums prices of commerce items.java.lang.StringcancelPayment(java.lang.String paymentId)Cancels a payment.booleanchangePaymentMethod(java.lang.String paymentId, java.lang.String paymentMethodId)Changes the payment method for a payment.java.lang.StringcheckConnectAccountStatus()Returns the status of the current seller's accountjava.lang.StringcreatePayment(Order order, Seller buyer, Seller vendor)Creates a payment for the specified order with the given netto amount and tax.java.lang.Stringget3DSecureLink(java.lang.String paymentId)Gets the 3D Secure link for a payment.java.lang.StringgetPaymentMethod(Seller buyer, java.util.LinkedHashMap<java.lang.String,java.lang.Object> paymentMethod)Creates payment method and - if needed - customer for Stripe.booleanisActive()Checks if the payment provider is active.PaymentStatuspay(Order order)Pays for the given order and returns the payment status.java.lang.StringpayoutToVendor(Order order, Seller vendor)Pays out an amount to a vendor.
-
-
-
Field Detail
-
stripeService
@Autowired private StripeService stripeService
-
stripeConnectService
@Autowired private StripeConnectService stripeConnectService
-
yooKassaService
@Autowired private YooKassaService yooKassaService
-
billingService
@Autowired private BillingService billingService
-
commerceItemService
@Autowired private CommerceItemService commerceItemService
-
orderRepository
@Autowired private OrderRepository orderRepository
-
sellerRepository
@Autowired private SellerRepository sellerRepository
-
commerceProperties
@Autowired private CommerceProperties commerceProperties
-
-
Method Detail
-
isActive
public boolean isActive()
Description copied from interface:PaymentProviderServiceChecks if the payment provider is active.- Specified by:
isActivein interfacePaymentProviderService- Returns:
- true if the payment provider is active, false otherwise.
-
pay
public PaymentStatus pay(Order order)
Description copied from interface:PaymentProviderServicePays for the given order and returns the payment status.- Specified by:
payin interfacePaymentProviderService- Parameters:
order- the order to be paid- Returns:
- the payment status of the order
-
payoutToVendor
public java.lang.String payoutToVendor(Order order, Seller vendor) throws com.stripe.exception.StripeException
Description copied from interface:PaymentProviderServicePays out an amount to a vendor.- Specified by:
payoutToVendorin interfacePaymentProviderService- Parameters:
order- the order to be payoutvendor- the vendor to be paid- Returns:
- the status of the payout
- Throws:
com.stripe.exception.StripeException- if the payout fails
-
createPayment
public java.lang.String createPayment(Order order, Seller buyer, Seller vendor)
Description copied from interface:PaymentProviderServiceCreates a payment for the specified order with the given netto amount and tax.- Specified by:
createPaymentin interfacePaymentProviderService- Parameters:
order- the order to be paidbuyer- the buyer who will payvendor- the vendor to be paid- Returns:
- A string representing the created payment.
-
cancelPayment
public java.lang.String cancelPayment(java.lang.String paymentId)
Description copied from interface:PaymentProviderServiceCancels a payment.- Specified by:
cancelPaymentin interfacePaymentProviderService- Parameters:
paymentId- the payment id to cancel- Returns:
- the cancellation result
-
getPaymentMethod
public java.lang.String getPaymentMethod(Seller buyer, java.util.LinkedHashMap<java.lang.String,java.lang.Object> paymentMethod)
Description copied from interface:PaymentProviderServiceCreates payment method and - if needed - customer for Stripe.- Specified by:
getPaymentMethodin interfacePaymentProviderService- Parameters:
buyer- the buyer for whom the payment method will be createdpaymentMethod- the map representation of payment method- Returns:
- map as object
-
changePaymentMethod
public boolean changePaymentMethod(java.lang.String paymentId, java.lang.String paymentMethodId)Description copied from interface:PaymentProviderServiceChanges the payment method for a payment.- Specified by:
changePaymentMethodin interfacePaymentProviderService- Parameters:
paymentId- the payment id to change the payment method forpaymentMethodId- the new payment method id- Returns:
- true if the payment method is successfully changed, false otherwise
-
get3DSecureLink
public java.lang.String get3DSecureLink(java.lang.String paymentId)
Description copied from interface:PaymentProviderServiceGets the 3D Secure link for a payment.- Specified by:
get3DSecureLinkin interfacePaymentProviderService- Parameters:
paymentId- the payment id to get the 3D Secure link for- Returns:
- the 3D Secure link
-
checkConnectAccountStatus
public java.lang.String checkConnectAccountStatus()
Description copied from interface:PaymentProviderServiceReturns the status of the current seller's account- Specified by:
checkConnectAccountStatusin interfacePaymentProviderService- Returns:
- status
-
calculateTotalPrice
public java.util.Map<java.lang.String,java.lang.Object> calculateTotalPrice(java.lang.String orderId)
Description copied from interface:PaymentProviderServiceSums prices of commerce items.- Specified by:
calculateTotalPricein interfacePaymentProviderService- Parameters:
orderId- order identifier- Returns:
- items total amount as map-property
-
calculateTaxAmountPrice
public java.util.Map<java.lang.String,java.lang.Object> calculateTaxAmountPrice(java.lang.String orderId)
Description copied from interface:PaymentProviderServiceCalculates tax amount for order.- Specified by:
calculateTaxAmountPricein interfacePaymentProviderService- Parameters:
orderId- order identifier- Returns:
- tax amount as map-property
-
calculateItemsTotalBruttoAmount
public java.util.Map<java.lang.String,java.lang.Object> calculateItemsTotalBruttoAmount(java.lang.String orderId)
Description copied from interface:PaymentProviderServiceCalculates total gross amount for order.- Specified by:
calculateItemsTotalBruttoAmountin interfacePaymentProviderService- Parameters:
orderId- order identifier- Returns:
- order gross amount as map-property
-
calculateServiceFeeBruttoAmount
public java.util.Map<java.lang.String,java.lang.Object> calculateServiceFeeBruttoAmount(java.lang.String orderId)
Description copied from interface:PaymentProviderServiceCalculates service fee for order.- Specified by:
calculateServiceFeeBruttoAmountin interfacePaymentProviderService- Parameters:
orderId- order identifier- Returns:
- service fee amount as map-property
-
calculatePayoutAmount
public java.util.Map<java.lang.String,java.lang.Object> calculatePayoutAmount(java.lang.String orderId)
Description copied from interface:PaymentProviderServiceCalculates payout amount for order.- Specified by:
calculatePayoutAmountin interfacePaymentProviderService- Parameters:
orderId- order identifier- Returns:
- payout amount as map-property
-
calculateOrder
public OrderDTO calculateOrder(Order order)
Description copied from interface:PaymentProviderServiceMaps an Order object to an OrderDTO object.- Specified by:
calculateOrderin interfacePaymentProviderService- Parameters:
order- the Order object to be mapped- Returns:
- the mapped OrderDTO object
-
calculateTax
public Order.Tax calculateTax(Seller buyer, Seller seller)
Description copied from interface:PaymentProviderServiceCalculates the tax for an order based on the buyer, seller, and tax rates.- Specified by:
calculateTaxin interfacePaymentProviderService- Parameters:
buyer- the user who is buying the orderseller- the user who is selling the order- Returns:
- the tax amount for the order
-
-