Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add Cashfree Payment Provider #1720

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions src/components/customers/CustomerMainInfos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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 Netsuite from '~/public/images/netsuite.svg'
import Stripe from '~/public/images/stripe.svg'
Expand Down Expand Up @@ -112,6 +113,12 @@ gql`
code
}

... on CashfreeProvider {
id
name
code
}

... on AdyenProvider {
id
name
Expand Down Expand Up @@ -385,6 +392,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 @@ -40,6 +40,7 @@ import {
NetsuiteCustomer,
ProviderCustomer,
ProviderPaymentMethodsEnum,
ProviderTypeEnum,
TimezoneEnum,
UpdateCustomerInput,
XeroCustomer,
Expand Down Expand Up @@ -128,9 +129,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 @@ -46,6 +46,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 Netsuite from '~/public/images/netsuite.svg'
import PSPIcons from '~/public/images/psp-icons.svg'
Expand Down Expand Up @@ -95,6 +96,13 @@ gql`
code
}

... on CashfreeProvider {
__typename
id
name
code
}

... on AdyenProvider {
__typename
id
Expand Down Expand Up @@ -221,6 +229,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 @@ -387,6 +403,8 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
<GoCardless />
) : formikProps.values.paymentProvider === ProviderTypeEnum?.Adyen ? (
<Adyen />
) : formikProps.values.paymentProvider === ProviderTypeEnum?.Cashfree ? (
<Cashfree />
) : null}
</>
) : (
Expand Down Expand Up @@ -453,7 +471,7 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
}}
/>

{!!formikProps.values.paymentProviderCode && (
{!!formikProps.values.paymentProviderCode && isSyncWithProviderSupported && (
<>
<TextInputField
name="providerCustomer.providerCustomerId"
Expand Down
3 changes: 3 additions & 0 deletions src/components/settings/integrations/AddAdyenDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ gql`
... on GocardlessProvider {
id
}
... on CashfreeProvider {
id
}
... on StripeProvider {
id
}
Expand Down
Loading