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 Jan 13, 2025
1 parent 0c1d671 commit 0ffaace
Show file tree
Hide file tree
Showing 44 changed files with 2,380 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 @@ -33,6 +33,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 @@ -135,6 +136,12 @@ gql`
code
}
... on CashfreeProvider {
id
name
code
}
... on AdyenProvider {
id
name
Expand Down Expand Up @@ -470,6 +477,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 @@ -16,6 +16,7 @@ import {
NetsuiteCustomer,
ProviderCustomer,
ProviderPaymentMethodsEnum,
ProviderTypeEnum,
SalesforceCustomer,
UpdateCustomerInput,
XeroCustomer,
Expand Down Expand Up @@ -106,9 +107,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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import Adyen from '~/public/images/adyen.svg'
import Cashfree from '~/public/images/cashfree.svg'
import GoCardless from '~/public/images/gocardless.svg'
import Stripe from '~/public/images/stripe.svg'

Expand All @@ -24,6 +25,13 @@ gql`
query paymentProvidersListForCustomerCreateEditExternalAppsAccordion($limit: Int) {
paymentProviders(limit: $limit) {
collection {
... on CashfreeProvider {
__typename
id
name
code
}
... on StripeProvider {
__typename
id
Expand Down Expand Up @@ -55,9 +63,10 @@ interface PaymentProvidersAccordionProps {
}

const avatarMapping: Record<ProviderTypeEnum, ReactNode> = {
[ProviderTypeEnum.Stripe]: <Stripe />,
[ProviderTypeEnum.Gocardless]: <GoCardless />,
[ProviderTypeEnum.Adyen]: <Adyen />,
[ProviderTypeEnum.Cashfree]: <Cashfree />,
[ProviderTypeEnum.Gocardless]: <GoCardless />,
[ProviderTypeEnum.Stripe]: <Stripe />,
}

export const PaymentProvidersAccordion: FC<PaymentProvidersAccordionProps> = ({
Expand Down Expand Up @@ -89,6 +98,13 @@ export const PaymentProvidersAccordion: FC<PaymentProvidersAccordionProps> = ({
}))
}, [paymentProviders?.collection])

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

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

return (
<div>
<Typography variant="captionHl" color="grey700" className="mb-1">
Expand Down Expand Up @@ -149,7 +165,7 @@ export const PaymentProvidersAccordion: FC<PaymentProvidersAccordionProps> = ({
}}
/>

{!!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 0ffaace

Please sign in to comment.