Skip to content

Commit 8a76f7c

Browse files
authored
[PAY-1685] Wire up stripe UI for USDC purchase in mobile (#3837)
1 parent 6337949 commit 8a76f7c

File tree

11 files changed

+67
-52
lines changed

11 files changed

+67
-52
lines changed

packages/common/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/common/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"url": "https://github.com/AudiusProject/audius-client/issues"
2929
},
3030
"dependencies": {
31-
"@audius/sdk": "3.0.3-beta.99",
31+
"@audius/sdk": "3.0.3-beta.104",
3232
"@fingerprintjs/fingerprintjs-pro": "3.5.6",
3333
"@metaplex-foundation/mpl-token-metadata": "2.5.2",
3434
"@optimizely/optimizely-sdk": "4.0.0",

packages/embed/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/embed/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"webpack-cli": "4.5.0"
3535
},
3636
"dependencies": {
37-
"@audius/sdk": "3.0.3-beta.99",
37+
"@audius/sdk": "3.0.3-beta.104",
3838
"@audius/stems": "1.5.35",
3939
"amplitude-js": "8.11.1",
4040
"axios": "0.19.2",

packages/mobile/package-lock.json

+31-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mobile/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"@amplitude/react-native": "2.6.0",
4747
"@audius/common": "1.5.35",
48-
"@audius/sdk": "3.0.3-beta.99",
48+
"@audius/sdk": "3.0.3-beta.104",
4949
"@fingerprintjs/fingerprintjs-pro-react-native": "2.0.0-test.2",
5050
"@gorhom/portal": "1.0.9",
5151
"@hcaptcha/react-native-hcaptcha": "1.3.4",

packages/mobile/src/components/premium-track-purchase-drawer/StripePurchaseConfirmationButton.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { useCallback } from 'react'
22

33
import { accountSelectors } from '@audius/common'
4-
import { useSelector } from 'react-redux'
4+
import { useSelector, useDispatch } from 'react-redux'
55

66
import { Button } from 'app/components/core'
77
import { useNavigation } from 'app/hooks/useNavigation'
88
import { createStripeSession, getUSDCUserBank } from 'app/services/buyCrypto'
9+
import { setVisibility } from 'app/store/drawers/slice'
910
import { useThemeColors } from 'app/utils/theme'
1011

1112
const { getAccountERCWallet } = accountSelectors
@@ -21,6 +22,7 @@ type StripePurchaseConfirmationButtonProps = {
2122
export const StripePurchaseConfirmationButton = ({
2223
price
2324
}: StripePurchaseConfirmationButtonProps) => {
25+
const dispatch = useDispatch()
2426
const navigation = useNavigation()
2527
const { specialLightGreen1 } = useThemeColors()
2628
const ethWallet = useSelector(getAccountERCWallet)
@@ -38,20 +40,27 @@ export const StripePurchaseConfirmationButton = ({
3840
}
3941
const res = await createStripeSession({
4042
amount: price,
41-
destinationWallet: usdcUserBank.toString()
43+
destinationWallet: usdcUserBank.toString(),
44+
destinationCurrency: 'usdc'
4245
})
4346
if (res === undefined || res.client_secret === undefined) {
4447
throw new Error(
4548
'Stripe session creation failed: could not get client secret'
4649
)
4750
}
51+
dispatch(
52+
setVisibility({
53+
drawer: 'PremiumTrackPurchase',
54+
visible: false
55+
})
56+
)
4857
navigation.navigate('StripeOnrampEmbed', {
4958
clientSecret: res.client_secret
5059
})
5160
} catch (e) {
5261
console.error(e)
5362
}
54-
}, [ethWallet, navigation, price])
63+
}, [dispatch, ethWallet, navigation, price])
5564

5665
return (
5766
<Button

packages/mobile/src/services/buyCrypto.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ export const getUSDCUserBank = async (ethWallet: string) => {
1010

1111
export const createStripeSession = async ({
1212
destinationWallet,
13-
amount
13+
amount,
14+
destinationCurrency
1415
}: {
1516
destinationWallet: string
1617
amount: string
18+
destinationCurrency: 'sol' | 'usdc'
1719
}) => {
1820
await waitForLibsInit()
1921
return await audiusLibs?.identityService?.createStripeSession({
2022
destinationWallet,
21-
amount
23+
amount,
24+
destinationCurrency
2225
})
2326
}

0 commit comments

Comments
 (0)