Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/mobility-core/src/Kernel/External/Payment/Interface.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,18 @@ autoRefunds serviceConfig mRoutingId req = case serviceConfig of
JuspayConfig cfg -> Juspay.autoRefund cfg mRoutingId req
StripeConfig _ -> throwError $ InternalError "Stripe Auto Refunds not supported."

createIndividualConnectAccount ::
createConnectAccount ::
( EncFlow m r,
CoreMetrics m,
HasRequestId r,
MonadReader r m
) =>
PaymentServiceConfig ->
IndividualConnectAccountReq ->
m IndividualConnectAccountResp
createIndividualConnectAccount serviceConfig req = case serviceConfig of
JuspayConfig _ -> throwError $ InternalError "Juspay Create Individual Connect Account not supported."
StripeConfig cfg -> Stripe.createIndividualConnectAccount cfg req
CreateConnectAccountReq ->
m CreateConnectAccountResp
createConnectAccount serviceConfig req = case serviceConfig of
JuspayConfig _ -> throwError $ InternalError "Juspay Create Connect Account not supported."
StripeConfig cfg -> Stripe.createConnectAccount cfg req

retryAccountLink ::
( CoreMetrics m,
Expand Down
61 changes: 36 additions & 25 deletions lib/mobility-core/src/Kernel/External/Payment/Interface/Stripe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import Kernel.Types.Error
import Kernel.Types.Id
import Kernel.Utils.Common

createIndividualConnectAccount ::
createConnectAccount ::
( Metrics.CoreMetrics m,
EncFlow m r,
HasRequestId r,
MonadReader r m
) =>
StripeCfg ->
IndividualConnectAccountReq ->
m IndividualConnectAccountResp
createIndividualConnectAccount config req = do
CreateConnectAccountReq ->
m CreateConnectAccountResp
createConnectAccount config req = do
let url = config.url
apiKey <- decrypt config.apiKey
let accountReq = mkAccountReq
Expand All @@ -44,7 +44,7 @@ createIndividualConnectAccount config req = do
accountLinkResp <- Stripe.createAccountLink url apiKey accountLinkReq
let accountUrl = accountLinkResp.url
let accountUrlExpiry = posixSecondsToUTCTime accountLinkResp.expires_at
pure $ IndividualConnectAccountResp {..}
pure $ CreateConnectAccountResp {..}
where
mkAccountReq :: Stripe.AccountsReq
mkAccountReq =
Expand Down Expand Up @@ -78,7 +78,7 @@ createIndividualConnectAccount config req = do
Stripe.AccountSettings
{ payouts = Stripe.PayoutsSettings {debit_negative_balances = True, statement_descriptor = "Bridge Rideshare"}
}
business_type = Stripe.Individual
business_type = req.businessType
(year', month, day) = toGregorian req.dateOfBirth
individual =
Just $
Expand All @@ -92,27 +92,38 @@ createIndividualConnectAccount config req = do
phone = req.mobileNumber,
ssn_last_4 = req.ssnLast4
}
default_business_profile =
Just $
Stripe.BusinessProfile
{ mcc = Just "4121",
product_description = Just "Rideshare driver",
support_phone = Just "7605636815", -- dummy number
url = Just "https://bridge.cab",
support_address =
Just $
Stripe.BusinessSupportAddress
{ city = Just "St. Louis Park",
country = Just "US",
line1 = Just "Suite 100, 1650, West End Blvd",
line2 = Nothing,
postal_code = Just "55416",
state = Just "MN"
}
}
business_profile = config.businessProfile <|> default_business_profile
configBusinessProfile = fromMaybe defaultBussinessProfile config.businessProfile
business_profile = case req.businessType of
Stripe.Individual -> Just configBusinessProfile
_ ->
Just
configBusinessProfile{support_phone = Just req.mobileNumber,
support_address = (castAddress <$> req.address) <|> configBusinessProfile.support_address
}
in Stripe.AccountsReq {..}

castAddress :: Address -> BusinessSupportAddress
castAddress Address {..} = BusinessSupportAddress {..}

defaultBussinessProfile :: Stripe.BusinessProfile
defaultBussinessProfile =
Stripe.BusinessProfile
{ mcc = Just "4121",
product_description = Just "Rideshare driver",
support_phone = Just "7605636815", -- dummy number
url = Just "https://bridge.cab",
support_address =
Just $
Stripe.BusinessSupportAddress
{ city = Just "St. Louis Park",
country = Just "US",
line1 = Just "Suite 100, 1650, West End Blvd",
line2 = Nothing,
postal_code = Just "55416",
state = Just "MN"
}
}

retryAccountLink ::
( Metrics.CoreMetrics m,
EncFlow m r,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ data RefundsData = RefundsData
deriving anyclass (FromJSON, ToJSON, ToSchema)

-- | Request to create a Connect Account
data IndividualConnectAccountReq = IndividualConnectAccountReq
data CreateConnectAccountReq = CreateConnectAccountReq
{ country :: Context.Country,
email :: Maybe Text,
mobileNumber :: Text,
Expand All @@ -577,12 +577,13 @@ data IndividualConnectAccountReq = IndividualConnectAccountReq
lastName :: Maybe Text,
ssnLast4 :: Maybe Text,
idNumber :: Maybe Text,
address :: Maybe Address
address :: Maybe Address,
businessType :: BusinessType
}
deriving stock (Show, Eq, Generic)
deriving anyclass (FromJSON, ToJSON, ToSchema)

data IndividualConnectAccountResp = IndividualConnectAccountResp
data CreateConnectAccountResp = CreateConnectAccountResp
{ accountId :: AccountId,
accountUrl :: Text,
accountUrlExpiry :: UTCTime,
Expand Down
Loading