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 BillingService
billingService
private CommerceItemService
commerceItemService
private CommerceProperties
commerceProperties
private OrderRepository
orderRepository
private SellerRepository
sellerRepository
private StripeConnectService
stripeConnectService
private StripeService
stripeService
private YooKassaService
yooKassaService
-
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.OrderDTO
calculateOrder(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.Tax
calculateTax(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.String
cancelPayment(java.lang.String paymentId)
Cancels a payment.boolean
changePaymentMethod(java.lang.String paymentId, java.lang.String paymentMethodId)
Changes the payment method for a payment.java.lang.String
checkConnectAccountStatus()
Returns the status of the current seller's accountjava.lang.String
createPayment(Order order, Seller buyer, Seller vendor)
Creates a payment for the specified order with the given netto amount and tax.java.lang.String
get3DSecureLink(java.lang.String paymentId)
Gets the 3D Secure link for a payment.java.lang.String
getPaymentMethod(Seller buyer, java.util.LinkedHashMap<java.lang.String,java.lang.Object> paymentMethod)
Creates payment method and - if needed - customer for Stripe.boolean
isActive()
Checks if the payment provider is active.PaymentStatus
pay(Order order)
Pays for the given order and returns the payment status.java.lang.String
payoutToVendor(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:PaymentProviderService
Checks if the payment provider is active.- Specified by:
isActive
in interfacePaymentProviderService
- Returns:
- true if the payment provider is active, false otherwise.
-
pay
public PaymentStatus pay(Order order)
Description copied from interface:PaymentProviderService
Pays for the given order and returns the payment status.- Specified by:
pay
in 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:PaymentProviderService
Pays out an amount to a vendor.- Specified by:
payoutToVendor
in 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:PaymentProviderService
Creates a payment for the specified order with the given netto amount and tax.- Specified by:
createPayment
in 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:PaymentProviderService
Cancels a payment.- Specified by:
cancelPayment
in 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:PaymentProviderService
Creates payment method and - if needed - customer for Stripe.- Specified by:
getPaymentMethod
in 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:PaymentProviderService
Changes the payment method for a payment.- Specified by:
changePaymentMethod
in 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:PaymentProviderService
Gets the 3D Secure link for a payment.- Specified by:
get3DSecureLink
in 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:PaymentProviderService
Returns the status of the current seller's account- Specified by:
checkConnectAccountStatus
in interfacePaymentProviderService
- Returns:
- status
-
calculateTotalPrice
public java.util.Map<java.lang.String,java.lang.Object> calculateTotalPrice(java.lang.String orderId)
Description copied from interface:PaymentProviderService
Sums prices of commerce items.- Specified by:
calculateTotalPrice
in 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:PaymentProviderService
Calculates tax amount for order.- Specified by:
calculateTaxAmountPrice
in 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:PaymentProviderService
Calculates total gross amount for order.- Specified by:
calculateItemsTotalBruttoAmount
in 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:PaymentProviderService
Calculates service fee for order.- Specified by:
calculateServiceFeeBruttoAmount
in 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:PaymentProviderService
Calculates payout amount for order.- Specified by:
calculatePayoutAmount
in interfacePaymentProviderService
- Parameters:
orderId
- order identifier- Returns:
- payout amount as map-property
-
calculateOrder
public OrderDTO calculateOrder(Order order)
Description copied from interface:PaymentProviderService
Maps an Order object to an OrderDTO object.- Specified by:
calculateOrder
in 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:PaymentProviderService
Calculates the tax for an order based on the buyer, seller, and tax rates.- Specified by:
calculateTax
in interfacePaymentProviderService
- Parameters:
buyer
- the user who is buying the orderseller
- the user who is selling the order- Returns:
- the tax amount for the order
-
-