From 9264934cd76c24d24ab7180d4c25c418f12252a5 Mon Sep 17 00:00:00 2001 From: Dharit Tantiviramanond Date: Tue, 1 Aug 2023 17:44:20 -0400 Subject: [PATCH 1/2] [PAY-1685] Wire up Stripe UI in mobile --- .../StripePurchaseConfirmationButton.tsx | 15 ++++++++++++--- packages/mobile/src/services/buyCrypto.ts | 7 +++++-- .../web/src/services/audius-backend/BuyAudio.ts | 7 +++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/mobile/src/components/premium-track-purchase-drawer/StripePurchaseConfirmationButton.tsx b/packages/mobile/src/components/premium-track-purchase-drawer/StripePurchaseConfirmationButton.tsx index 624ef90f22..593bc6ee43 100644 --- a/packages/mobile/src/components/premium-track-purchase-drawer/StripePurchaseConfirmationButton.tsx +++ b/packages/mobile/src/components/premium-track-purchase-drawer/StripePurchaseConfirmationButton.tsx @@ -1,11 +1,12 @@ import { useCallback } from 'react' import { accountSelectors } from '@audius/common' -import { useSelector } from 'react-redux' +import { useSelector, useDispatch } from 'react-redux' import { Button } from 'app/components/core' import { useNavigation } from 'app/hooks/useNavigation' import { createStripeSession, getUSDCUserBank } from 'app/services/buyCrypto' +import { setVisibility } from 'app/store/drawers/slice' import { useThemeColors } from 'app/utils/theme' const { getAccountERCWallet } = accountSelectors @@ -21,6 +22,7 @@ type StripePurchaseConfirmationButtonProps = { export const StripePurchaseConfirmationButton = ({ price }: StripePurchaseConfirmationButtonProps) => { + const dispatch = useDispatch() const navigation = useNavigation() const { specialLightGreen1 } = useThemeColors() const ethWallet = useSelector(getAccountERCWallet) @@ -38,20 +40,27 @@ export const StripePurchaseConfirmationButton = ({ } const res = await createStripeSession({ amount: price, - destinationWallet: usdcUserBank.toString() + destinationWallet: usdcUserBank.toString(), + destinationCurrency: 'usdc' }) if (res === undefined || res.client_secret === undefined) { throw new Error( 'Stripe session creation failed: could not get client secret' ) } + dispatch( + setVisibility({ + drawer: 'PremiumTrackPurchase', + visible: false + }) + ) navigation.navigate('StripeOnrampEmbed', { clientSecret: res.client_secret }) } catch (e) { console.error(e) } - }, [ethWallet, navigation, price]) + }, [dispatch, ethWallet, navigation, price]) return (