Skip to content

Commit

Permalink
feat: add Cashfree Payment Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushChothe authored and ansmonjol committed Dec 4, 2024
1 parent 9e850ac commit 9ddd3ce
Show file tree
Hide file tree
Showing 44 changed files with 2,391 additions and 416 deletions.
9 changes: 9 additions & 0 deletions src/components/customers/CustomerMainInfos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
import { useInternationalization } from '~/hooks/core/useInternationalization'
import Adyen from '~/public/images/adyen.svg'
import Anrok from '~/public/images/anrok.svg'
import Cashfree from '~/public/images/cashfree.svg'
import Gocardless from '~/public/images/gocardless.svg'
import Hubspot from '~/public/images/hubspot.svg'
import Netsuite from '~/public/images/netsuite.svg'
Expand Down Expand Up @@ -134,6 +135,12 @@ gql`
code
}
... on CashfreeProvider {
id
name
code
}
... on AdyenProvider {
id
name
Expand Down Expand Up @@ -458,6 +465,8 @@ export const CustomerMainInfos = ({ loading, customer, onEdit }: CustomerMainInf
<Gocardless />
) : paymentProvider === ProviderTypeEnum?.Adyen ? (
<Adyen />
) : paymentProvider === ProviderTypeEnum?.Cashfree ? (
<Cashfree />
) : null}
</Avatar>
<Typography color="grey700">{linkedProvider?.name}</Typography>
Expand Down
9 changes: 6 additions & 3 deletions src/components/customers/addDrawer/AddCustomerDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
NetsuiteCustomer,
ProviderCustomer,
ProviderPaymentMethodsEnum,
ProviderTypeEnum,
SalesforceCustomer,
TimezoneEnum,
UpdateCustomerInput,
Expand Down Expand Up @@ -141,9 +142,11 @@ export const AddCustomerDrawer = forwardRef<AddCustomerDrawerRef>((_, ref) => {
return false
}

// if syncWithProvider is false, providerCustomerId is required
if (!value?.syncWithProvider && !value?.providerCustomerId) {
return false
if (from?.[1].value.paymentProvider !== ProviderTypeEnum.Cashfree) {
// if syncWithProvider is false, providerCustomerId is required
if (!value?.syncWithProvider && !value?.providerCustomerId) {
return false
}
}

return true
Expand Down
20 changes: 19 additions & 1 deletion src/components/customers/addDrawer/ExternalAppsAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
import { useInternationalization } from '~/hooks/core/useInternationalization'
import Adyen from '~/public/images/adyen.svg'
import Anrok from '~/public/images/anrok.svg'
import Cashfree from '~/public/images/cashfree.svg'
import GoCardless from '~/public/images/gocardless.svg'
import Hubspot from '~/public/images/hubspot.svg'
import Netsuite from '~/public/images/netsuite.svg'
Expand Down Expand Up @@ -130,6 +131,13 @@ gql`
code
}
... on CashfreeProvider {
__typename
id
name
code
}
... on AdyenProvider {
__typename
id
Expand Down Expand Up @@ -303,6 +311,14 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
})

const isSyncWithProviderDisabled = !!formikProps.values.providerCustomer?.syncWithProvider

const isSyncWithProviderSupported = useMemo(() => {
if (!formikProps.values.paymentProvider) return false
const unsupportedPaymentProviders: ProviderTypeEnum[] = [ProviderTypeEnum.Cashfree]

return !unsupportedPaymentProviders.includes(formikProps.values.paymentProvider)
}, [formikProps.values.paymentProvider])

const hadInitialNetsuiteIntegrationCustomer =
!!formikProps.initialValues.integrationCustomers?.find(
(i) => i.integrationType === IntegrationTypeEnum.Netsuite,
Expand Down Expand Up @@ -504,6 +520,8 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
<GoCardless />
) : formikProps.values.paymentProvider === ProviderTypeEnum?.Adyen ? (
<Adyen />
) : formikProps.values.paymentProvider === ProviderTypeEnum?.Cashfree ? (
<Cashfree />
) : null}
</Avatar>
) : (
Expand Down Expand Up @@ -571,7 +589,7 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
}}
/>

{!!formikProps.values.paymentProviderCode && (
{!!formikProps.values.paymentProviderCode && isSyncWithProviderSupported && (
<>
<TextInputField
name="providerCustomer.providerCustomerId"
Expand Down
5 changes: 5 additions & 0 deletions src/components/settings/integrations/AddAdyenDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
useUpdateAdyenApiKeyMutation,
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { IntegrationsTabsOptionsEnum } from '~/pages/settings/Integrations'
import { theme } from '~/styles'

import { DeleteAdyenIntegrationDialogRef } from './DeleteAdyenIntegrationDialog'
Expand All @@ -44,6 +45,9 @@ gql`
... on GocardlessProvider {
id
}
... on CashfreeProvider {
id
}
... on StripeProvider {
id
}
Expand Down Expand Up @@ -96,6 +100,7 @@ export const AddAdyenDialog = forwardRef<AddAdyenDialogRef>((_, ref) => {
navigate(
generatePath(ADYEN_INTEGRATION_DETAILS_ROUTE, {
integrationId: addAdyenPaymentProvider.id,
integrationGroup: IntegrationsTabsOptionsEnum.Lago,
}),
)

Expand Down
2 changes: 2 additions & 0 deletions src/components/settings/integrations/AddAnrokDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { AnrokIntegrationDetailsTabs } from '~/pages/settings/AnrokIntegrationDetails'
import { IntegrationsTabsOptionsEnum } from '~/pages/settings/Integrations'
import { theme } from '~/styles'

import { DeleteAnrokIntegrationDialogRef } from './DeleteAnrokIntegrationDialog'
Expand Down Expand Up @@ -82,6 +83,7 @@ export const AddAnrokDialog = forwardRef<AddAnrokDialogRef>((_, ref) => {
generatePath(ANROK_INTEGRATION_DETAILS_ROUTE, {
integrationId: createAnrokIntegration.id,
tab: AnrokIntegrationDetailsTabs.Settings,
integrationGroup: IntegrationsTabsOptionsEnum.Lago,
}),
)

Expand Down
Loading

0 comments on commit 9ddd3ce

Please sign in to comment.