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
20 changes: 20 additions & 0 deletions src/components/icons/payment-methods/payment-methods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ const PaymentMethodIcon: React.FC<{
</Svg>
);

case 'cashApp':
return (
<Svg width={width ?? 40} height={height ?? 40} viewBox="0 0 210 210">
<Rect
width={150}
height={150}
x={25}
y={25}
rx={7.81424}
fill={theme.dark ? '#3C4043' : White}
/>
<Path
fill={theme.dark ? White : '#00e013'}
fill-rule="evenodd"
clip-rule="evenodd"
d="M206.398,30.286c-4.502-12.394-14.307-22.189-26.713-26.687C168.48,0,158.075,0,136.865,0h-63.63 c-21.11,0-31.615,0-42.92,3.498C17.909,7.996,8.104,17.792,3.602,30.186C0,41.58,0,52.075,0,73.165v63.57 c0,21.19,0,31.585,3.502,42.98c4.502,12.394,14.307,22.189,26.713,26.687C41.62,210,52.125,210,73.135,210h63.63 c21.11,0,31.615,0,42.92-3.598c12.406-4.498,22.211-14.293,26.713-26.687C210,168.32,210,157.825,210,136.735v-63.47 C210,52.175,210,41.68,206.398,30.286z M151.472,71.866l-12.106,9.895c-1.101,0.9-2.601,0.7-3.402-0.4 c-6.203-7.596-15.807-11.894-26.312-11.894c-11.706,0-19.009,5.098-19.009,12.294c-0.2,6.097,5.503,9.196,23.011,12.994 c22.111,4.698,32.215,13.893,32.215,29.386c0,19.391-15.808,33.684-40.519,35.283l-2.401,11.495 c-0.2,1.099-1.201,1.899-2.401,1.899H81.539c-1.601,0-2.701-1.499-2.401-2.999l3.001-12.794 c-12.206-3.498-22.111-10.295-27.813-18.591c-0.7-1.099-0.5-2.499,0.5-3.298l13.206-10.395c1.101-0.9,2.701-0.6,3.502,0.5 c7.003,9.795,17.808,15.593,30.815,15.593c11.706,0,20.51-5.697,20.51-13.893c0-6.297-4.402-9.196-19.309-12.294 c-25.412-5.497-35.517-14.793-35.517-30.286c0-17.991,15.107-31.485,37.918-33.284l2.501-11.894c0.2-1.099,1.201-1.899,2.401-1.899h18.709c1.501,0,2.701,1.399,2.401,2.899l-2.901,13.294c9.805,2.999,17.808,8.396,22.811,15.093 C152.673,69.567,152.473,71.066,151.472,71.866z"
/>
</Svg>
);

case 'other':
return (
<Svg width={width ?? 16} height={height ?? 17} viewBox="0 0 16 17">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
getPaymentMethodIconByKey,
} from '../constants/BuyCryptoConstants';
import {showBottomNotificationModal} from '../../../../store/app/app.actions';
import {getCachedExternalServicesConfig} from '../../../../store/external-services/external-services.effects';
import {sleep} from '../../../../utils/helper-methods';
import {BottomSheetScrollView} from '@gorhom/bottom-sheet';
import {TouchableOpacity} from '@components/base/TouchableOpacity';
Expand Down Expand Up @@ -155,6 +156,7 @@ const PaymentMethodsModal = ({
);

const getEnabledPaymentMethods = () => {
const externalServicesConfig = getCachedExternalServicesConfig()?.config;
switch (context) {
case 'buyCrypto':
return getBuyEnabledPaymentMethods(
Expand All @@ -163,6 +165,7 @@ const PaymentMethodsModal = ({
chain,
locationData?.countryShortCode || 'US',
preSetPartner as BuyCryptoExchangeKey,
externalServicesConfig?.buyCrypto,
);

case 'sellCrypto':
Expand All @@ -173,6 +176,7 @@ const PaymentMethodsModal = ({
locationData?.countryShortCode || 'US',
user?.country,
preSetPartner as SellCryptoExchangeKey,
externalServicesConfig?.sellCrypto,
);

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Platform} from 'react-native';
import PaymentMethodIcon from '../../../../components/icons/payment-methods/payment-methods';
import {
countriesWithACH,
countriesWithCashApp,
countriesWithPIX,
countriesWithSEPA,
} from '../../constants/PaymentMethodsConstants';
Expand All @@ -11,6 +12,7 @@ import {BuyCryptoExchangeKey} from '../utils/buy-crypto-utils';
export type PaymentMethodKey =
| 'ach'
| 'applePay'
| 'cashApp'
| 'creditCard'
| 'debitCard'
| 'googlePay'
Expand Down Expand Up @@ -110,6 +112,33 @@ export const PaymentMethodsAvailable: PaymentMethods = {
},
enabled: Platform.OS === 'ios',
},
cashApp: {
order: 3.5,
label: 'Cash App Pay',
method: 'cashApp',
waitingTimeDescription: '< 10 mins',
imgLogo: (
<PaymentMethodIcon paymentMethodId="cashApp" width={40} height={40} />
),
imgIcon: (
<PaymentMethodIcon
iconOnly={true}
paymentMethodId="cashApp"
width={20}
height={20}
/>
),
supportedExchanges: {
banxa: false,
moonpay: true,
ramp: false,
sardine: false,
simplex: false,
transak: false,
},
supportedCountries: countriesWithCashApp,
enabled: true,
},
creditCard: {
order: 5,
label: 'Credit Card',
Expand Down
69 changes: 18 additions & 51 deletions src/navigation/services/buy-crypto/utils/buy-crypto-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import {
} from './transak-utils';
import pickBy from 'lodash.pickby';
import {LocationData} from '../../../../store/location/location.models';
import {getExternalServiceSymbol} from '../../utils/external-services-utils';
import {BuyCryptoConfig} from '../../../../store/external-services/external-services.types';
import {
getExternalServiceSymbol,
isPaymentMethodDisabledForPartner,
} from '../../utils/external-services-utils';

export type BuyCryptoExchangeKey =
| 'banxa'
Expand All @@ -54,10 +58,12 @@ export const getBuyEnabledPaymentMethods = (
chain?: string,
country?: string,
exchange?: BuyCryptoExchangeKey | undefined,
buyCryptoConfig?: BuyCryptoConfig,
): Partial<PaymentMethods> => {
if (!currency || !coin || !chain) {
return {};
}
const paymentMethodsConfig = buyCryptoConfig?.paymentMethods;
Object.values(PaymentMethodsAvailable).forEach(pm => {
if (
pm.enabled &&
Expand All @@ -69,57 +75,18 @@ export const getBuyEnabledPaymentMethods = (
});

const EnabledPaymentMethods = pickBy(PaymentMethodsAvailable, method => {
if (!method.enabled || paymentMethodsConfig?.[method.method]?.disabled) {
return false;
}
const isSupportedByExchange = (exch: BuyCryptoExchangeKey) =>
!isPaymentMethodDisabledForPartner(
buyCryptoConfig?.[exch],
method.method,
) &&
isPaymentMethodSupported(exch, method, coin, chain, currency, country);
return exchange && BuyCryptoSupportedExchanges.includes(exchange)
? method.enabled &&
isPaymentMethodSupported(
exchange,
method,
coin,
chain,
currency,
country,
)
: method.enabled &&
(isPaymentMethodSupported(
'banxa',
method,
coin,
chain,
currency,
country,
) ||
isPaymentMethodSupported(
'moonpay',
method,
coin,
chain,
currency,
country,
) ||
isPaymentMethodSupported('ramp', method, coin, chain, currency) ||
isPaymentMethodSupported(
'sardine',
method,
coin,
chain,
currency,
country,
) ||
isPaymentMethodSupported(
'simplex',
method,
coin,
chain,
currency,
) ||
isPaymentMethodSupported(
'transak',
method,
coin,
chain,
currency,
country,
));
? isSupportedByExchange(exchange)
: BuyCryptoSupportedExchanges.some(isSupportedByExchange);
});

return EnabledPaymentMethods;
Expand Down
3 changes: 3 additions & 0 deletions src/navigation/services/buy-crypto/utils/moonpay-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ export const getMoonpayPaymentMethodFormat = (
case 'venmo':
moonpayPaymentMethod = 'venmo';
break;
case 'cashApp':
moonpayPaymentMethod = 'cash_app';
break;
default:
moonpayPaymentMethod = undefined;
break;
Expand Down
Loading
Loading