Class StripeConnectServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.stripe.StripeConnectServiceImpl
-
- All Implemented Interfaces:
StripeConnectService
@Service public class StripeConnectServiceImpl extends java.lang.Object implements StripeConnectService
-
-
Field Summary
Fields Modifier and Type Field Description private AccessManagementService
accessManagementService
private CommerceProperties
commerceProperties
private static com.fasterxml.jackson.databind.ObjectMapper
mapper
private SellerRegistrationService
sellerRegistrationService
private SellerRepository
sellerRepository
private static java.lang.String
STRIPE_KEY
-
Constructor Summary
Constructors Constructor Description StripeConnectServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
checkConnectAccountStatus()
Returns the status of the current seller's accountcom.stripe.model.Account
createAccount(java.lang.String businessType, java.lang.String businessStructure, java.lang.String tosIp)
This method creates a Stripe Connect AccountStripeAccountDTO
createAccount(java.util.LinkedHashMap<java.lang.String,java.lang.Object> metaInfo)
This method creates a Stripe Connect Account based on meta informationprivate com.stripe.model.Account
createCompanyAccount(java.lang.String businessStructure, java.lang.String tosIp)
boolean
createExternalBankAccount(java.util.LinkedHashMap<java.lang.String,java.lang.Object> bankData)
CreatesExternalAccount
of a bank type.boolean
createExternalCardAccount(java.util.LinkedHashMap<java.lang.String,java.lang.Object> cardData)
CreatesExternalAccount
of a card type.private com.stripe.model.Account
createIndividualAccount(java.lang.String tosIp)
private com.stripe.param.AccountCreateParams.Settings
getAccountSettings()
java.util.List<java.lang.String>
getBusinessStructures(java.lang.String businessType)
Gets list of suitable companyAccountCreateParams.Company.Structure
's for current Seller's country and givenAccountCreateParams.BusinessType
.java.util.List<java.lang.String>
getBusinessTypes()
Gets list ofAccountCreateParams.BusinessType
's values for current Seller's country.private java.lang.Object
getCapabilities(boolean update)
StripePersonDTO
getInitialPerson()
Gets person with fields, pre-filled from current loggedProfile
.java.util.Map<java.lang.String,java.lang.String>
getMCCs()
Gets map of merchant category names and codes.private java.util.Map<java.lang.String,java.lang.Object>
getStripeMap(Seller seller)
private java.lang.Object
getTosAcceptance(boolean update, java.lang.String ip)
private java.lang.String
mapRequirement(java.lang.String requirement)
private java.util.Set<java.lang.String>
mapRequirements(java.util.List<java.lang.String> requirements)
java.lang.String
obtainConnectOnboardingLink(java.lang.String refreshUrl, java.lang.String returnUrl)
ObtainsAccountLink
and returns single-use Stripe URL that the platform can redirect the current user to in order to take them through the Connect Onboarding flow.private void
setStripeMap(Seller seller, com.stripe.model.Account account)
com.stripe.model.Account
updateAccount(java.lang.String accountId, StripeAccountDTO stripeAccountDTO)
This method update a Stripe Connect AccountStripeAccountDTO
verifyAccount(java.lang.String refreshUrl, java.lang.String returnUrl, java.util.LinkedHashMap<java.lang.String,java.lang.Object> metaInfo)
This method does update for SellerSeller
entity with meta information which contains necessary data for Stripe Connect Account
-
-
-
Field Detail
-
sellerRegistrationService
@Autowired private SellerRegistrationService sellerRegistrationService
-
accessManagementService
@Autowired private AccessManagementService accessManagementService
-
commerceProperties
@Autowired private CommerceProperties commerceProperties
-
sellerRepository
@Autowired private SellerRepository sellerRepository
-
STRIPE_KEY
private static final java.lang.String STRIPE_KEY
- See Also:
- Constant Field Values
-
mapper
private static final com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Method Detail
-
checkConnectAccountStatus
public java.lang.String checkConnectAccountStatus()
Description copied from interface:StripeConnectService
Returns the status of the current seller's account- Specified by:
checkConnectAccountStatus
in interfaceStripeConnectService
- Returns:
- status
-
createAccount
@Transactional public com.stripe.model.Account createAccount(java.lang.String businessType, java.lang.String businessStructure, java.lang.String tosIp) throws com.stripe.exception.StripeException
Description copied from interface:StripeConnectService
This method creates a Stripe Connect Account- Specified by:
createAccount
in interfaceStripeConnectService
- Parameters:
businessType
- type of businessbusinessStructure
- structure of businesstosIp
- client ip-address- Returns:
- created stripe account entity
Account
- Throws:
com.stripe.exception.StripeException
- different Stripe errors
-
createAccount
public StripeAccountDTO createAccount(java.util.LinkedHashMap<java.lang.String,java.lang.Object> metaInfo)
Description copied from interface:StripeConnectService
This method creates a Stripe Connect Account based on meta information- Specified by:
createAccount
in interfaceStripeConnectService
- Parameters:
metaInfo
- map with extra information which is necessary to have- Returns:
- created stripe account entity
StripeAccountDTO
-
updateAccount
public com.stripe.model.Account updateAccount(java.lang.String accountId, StripeAccountDTO stripeAccountDTO) throws com.stripe.exception.StripeException
Description copied from interface:StripeConnectService
This method update a Stripe Connect Account- Specified by:
updateAccount
in interfaceStripeConnectService
- Parameters:
accountId
- stripe connect account idstripeAccountDTO
- data to update- Returns:
- created stripe account entity
Account
- Throws:
com.stripe.exception.StripeException
- different Stripe errors
-
createIndividualAccount
private com.stripe.model.Account createIndividualAccount(java.lang.String tosIp) throws com.stripe.exception.StripeException
- Throws:
com.stripe.exception.StripeException
-
createCompanyAccount
private com.stripe.model.Account createCompanyAccount(java.lang.String businessStructure, java.lang.String tosIp) throws com.stripe.exception.StripeException
- Throws:
com.stripe.exception.StripeException
-
getStripeMap
private java.util.Map<java.lang.String,java.lang.Object> getStripeMap(Seller seller)
-
setStripeMap
private void setStripeMap(Seller seller, com.stripe.model.Account account) throws com.stripe.exception.StripeException
- Throws:
com.stripe.exception.StripeException
-
getInitialPerson
public StripePersonDTO getInitialPerson()
Description copied from interface:StripeConnectService
Gets person with fields, pre-filled from current loggedProfile
. This person has representative status- Specified by:
getInitialPerson
in interfaceStripeConnectService
- Returns:
- dto with fields
-
getTosAcceptance
private java.lang.Object getTosAcceptance(boolean update, java.lang.String ip)
-
createExternalBankAccount
public boolean createExternalBankAccount(java.util.LinkedHashMap<java.lang.String,java.lang.Object> bankData)
Description copied from interface:StripeConnectService
CreatesExternalAccount
of a bank type. Binds it with current's SellerAccount
- Specified by:
createExternalBankAccount
in interfaceStripeConnectService
- Parameters:
bankData
- data, format described inBankExternalAccountDTO
- Returns:
- true if successful
-
createExternalCardAccount
public boolean createExternalCardAccount(java.util.LinkedHashMap<java.lang.String,java.lang.Object> cardData)
Description copied from interface:StripeConnectService
CreatesExternalAccount
of a card type. Binds it with current's SellerAccount
- Specified by:
createExternalCardAccount
in interfaceStripeConnectService
- Parameters:
cardData
- data, format described inCardExternalAccountDTO
- Returns:
- true if successful
-
getBusinessTypes
public java.util.List<java.lang.String> getBusinessTypes()
Description copied from interface:StripeConnectService
Gets list ofAccountCreateParams.BusinessType
's values for current Seller's country.- Specified by:
getBusinessTypes
in interfaceStripeConnectService
- Returns:
- list of business types
-
getBusinessStructures
public java.util.List<java.lang.String> getBusinessStructures(java.lang.String businessType)
Description copied from interface:StripeConnectService
Gets list of suitable companyAccountCreateParams.Company.Structure
's for current Seller's country and givenAccountCreateParams.BusinessType
.- Specified by:
getBusinessStructures
in interfaceStripeConnectService
- Parameters:
businessType
- business type- Returns:
- list of structures
-
getMCCs
public java.util.Map<java.lang.String,java.lang.String> getMCCs()
Description copied from interface:StripeConnectService
Gets map of merchant category names and codes.- Specified by:
getMCCs
in interfaceStripeConnectService
- Returns:
- map
-
verifyAccount
public StripeAccountDTO verifyAccount(java.lang.String refreshUrl, java.lang.String returnUrl, java.util.LinkedHashMap<java.lang.String,java.lang.Object> metaInfo)
Description copied from interface:StripeConnectService
This method does update for SellerSeller
entity with meta information which contains necessary data for Stripe Connect Account- Specified by:
verifyAccount
in interfaceStripeConnectService
- Parameters:
refreshUrl
- The URL the user will be redirected to if the account link is expired, has been previously-visited, or is otherwise invalid. The URL you specify should attempt to generate a new account link with the same parameters used to create the original account link, then redirect the user to the new account link’s URL so they can continue with Connect Onboarding. If a new account link cannot be generated or the redirect fails you should display a useful error to the user.returnUrl
- The URL that the user will be redirected to upon leaving or completing the linked flowmetaInfo
- stripe data for Stripe Connect Account- Returns:
- updated entity
-
obtainConnectOnboardingLink
public java.lang.String obtainConnectOnboardingLink(java.lang.String refreshUrl, java.lang.String returnUrl)
Description copied from interface:StripeConnectService
ObtainsAccountLink
and returns single-use Stripe URL that the platform can redirect the current user to in order to take them through the Connect Onboarding flow. If Stripe Connect Account does not exist for the current user - creates new Account with the part of prefilled fields.- Specified by:
obtainConnectOnboardingLink
in interfaceStripeConnectService
- Parameters:
refreshUrl
- The URL the user will be redirected to if the account link is expired, has been previously-visited, or is otherwise invalid. The URL you specify should attempt to generate a new account link with the same parameters used to create the original account link, then redirect the user to the new account link’s URL so they can continue with Connect Onboarding. If a new account link cannot be generated or the redirect fails you should display a useful error to the user.returnUrl
- The URL that the user will be redirected to upon leaving or completing the linked flow- Returns:
- link
-
mapRequirements
private java.util.Set<java.lang.String> mapRequirements(java.util.List<java.lang.String> requirements)
-
mapRequirement
private java.lang.String mapRequirement(java.lang.String requirement)
-
getCapabilities
private java.lang.Object getCapabilities(boolean update)
-
getAccountSettings
private com.stripe.param.AccountCreateParams.Settings getAccountSettings()
-
-