Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
[PAY-1685] Wire up stripe UI for USDC purchase in mobile (#3837)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored Aug 1, 2023
1 parent 6337949 commit 8a76f7c
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 52 deletions.
6 changes: 3 additions & 3 deletions packages/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"url": "https://github.com/AudiusProject/audius-client/issues"
},
"dependencies": {
"@audius/sdk": "3.0.3-beta.99",
"@audius/sdk": "3.0.3-beta.104",
"@fingerprintjs/fingerprintjs-pro": "3.5.6",
"@metaplex-foundation/mpl-token-metadata": "2.5.2",
"@optimizely/optimizely-sdk": "4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/embed/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"webpack-cli": "4.5.0"
},
"dependencies": {
"@audius/sdk": "3.0.3-beta.99",
"@audius/sdk": "3.0.3-beta.104",
"@audius/stems": "1.5.35",
"amplitude-js": "8.11.1",
"axios": "0.19.2",
Expand Down
62 changes: 31 additions & 31 deletions packages/mobile/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@amplitude/react-native": "2.6.0",
"@audius/common": "1.5.35",
"@audius/sdk": "3.0.3-beta.99",
"@audius/sdk": "3.0.3-beta.104",
"@fingerprintjs/fingerprintjs-pro-react-native": "2.0.0-test.2",
"@gorhom/portal": "1.0.9",
"@hcaptcha/react-native-hcaptcha": "1.3.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,6 +22,7 @@ type StripePurchaseConfirmationButtonProps = {
export const StripePurchaseConfirmationButton = ({
price
}: StripePurchaseConfirmationButtonProps) => {
const dispatch = useDispatch()
const navigation = useNavigation()
const { specialLightGreen1 } = useThemeColors()
const ethWallet = useSelector(getAccountERCWallet)
Expand All @@ -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 (
<Button
Expand Down
7 changes: 5 additions & 2 deletions packages/mobile/src/services/buyCrypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ export const getUSDCUserBank = async (ethWallet: string) => {

export const createStripeSession = async ({
destinationWallet,
amount
amount,
destinationCurrency
}: {
destinationWallet: string
amount: string
destinationCurrency: 'sol' | 'usdc'
}) => {
await waitForLibsInit()
return await audiusLibs?.identityService?.createStripeSession({
destinationWallet,
amount
amount,
destinationCurrency
})
}
Loading

0 comments on commit 8a76f7c

Please sign in to comment.