-
Notifications
You must be signed in to change notification settings - Fork 13
Integrate Daimo Pay #1104
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
Merged
Merged
Integrate Daimo Pay #1104
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
61a21b4
add daimo pay
Zishan-7 669af30
minor improvements
Zishan-7 8746b07
cleanup and add success state
Zishan-7 b1f31bf
resolve dependency issues
Zishan-7 77a5d03
fix: formatting
Zishan-7 e5297b3
fix: recent methods redirection
Zishan-7 506ec1d
add functions for daimo payment in request fulfilment flow
Zishan-7 fc2322e
Integrate daimo in request fulfilment flow
Zishan-7 1047c84
remove hardcoded address
Zishan-7 4c8a87b
add separate arbitrum usdc flow for deposits
Zishan-7 7fe6042
Add risk modal
Zishan-7 feeaea8
fix overlay blur
Zishan-7 0129b72
Enhance loading state indication in payment process
Zishan-7 213d6ef
Add payer's address in deposit history entry
Zishan-7 6c14b59
Add validation
Zishan-7 8cebbaf
add error handling
Zishan-7 281cf66
remove action and move logic to API route
Zishan-7 ba99ea8
Merge remote-tracking branch 'origin/peanut-wallet-dev' into feat/int…
Zishan-7 a4e3b2a
fix errors
Zishan-7 0114c2d
fix: request flow
Zishan-7 1e72702
fix: validation
Zishan-7 563bc88
fixes
Zishan-7 31557c2
Merge remote-tracking branch 'origin/peanut-wallet-dev' into feat/int…
Zishan-7 0b3f720
add daimo flow in country specific method
Zishan-7 5cdad60
fix: slider not working on first attempt
Zishan-7 1f36903
filter supported networks
Zishan-7 ecef7a9
create reusable daimo button
Zishan-7 d4939b7
remove space
Zishan-7 60b650b
remove route.ts file and move logic to server actions
Zishan-7 92e9063
fix: infinite loading edge case
Zishan-7 6741c9f
update api and remove delay
Zishan-7 c3e6a08
fix: layout shift
Zishan-7 73ad4e8
fix: shadow
Zishan-7 7a21e90
update function name
Zishan-7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,100 @@ | ||
'use client' | ||
|
||
import PaymentPage from '@/app/[...recipient]/client' | ||
import ErrorAlert from '@/components/Global/ErrorAlert' | ||
import NavHeader from '@/components/Global/NavHeader' | ||
import PeanutLoading from '@/components/Global/PeanutLoading' | ||
import { useAppDispatch, useUserStore } from '@/redux/hooks' | ||
import { paymentActions } from '@/redux/slices/payment-slice' | ||
import { useRouter, useSearchParams } from 'next/navigation' | ||
import { useEffect, useState } from 'react' | ||
import TokenAmountInput from '@/components/Global/TokenAmountInput' | ||
import DaimoPayButton from '@/components/Global/DaimoPayButton' | ||
import DirectSuccessView from '@/components/Payment/Views/Status.payment.view' | ||
import { useWallet } from '@/hooks/wallet/useWallet' | ||
import { useRouter } from 'next/navigation' | ||
import { useState } from 'react' | ||
import { trackDaimoDepositTransactionHash } from '@/app/actions/users' | ||
|
||
export default function AddMoneyCryptoDirectPage() { | ||
const router = useRouter() | ||
const searchParams = useSearchParams() | ||
const { user } = useUserStore() | ||
const [recipientUsername, setRecipientUsername] = useState<string | null>(null) | ||
const [isLoading, setIsLoading] = useState(true) | ||
const dispatch = useAppDispatch() | ||
|
||
useEffect(() => { | ||
dispatch(paymentActions.resetPaymentState()) | ||
}, [dispatch]) | ||
|
||
useEffect(() => { | ||
if (user?.user.username) { | ||
setRecipientUsername(user.user.username) | ||
} else { | ||
router.replace('/add-money/crypto') | ||
return | ||
const { address } = useWallet() | ||
const [inputTokenAmount, setInputTokenAmount] = useState<string>('') | ||
const [isPaymentSuccess, setisPaymentSuccess] = useState(false) | ||
const [isUpdatingDepositStatus, setIsUpdatingDepositStatus] = useState(false) | ||
const [error, setError] = useState<string | null>(null) | ||
|
||
const onPaymentCompleted = async (e: any) => { | ||
Zishan-7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
setIsUpdatingDepositStatus(true) | ||
|
||
// Save deposit txn hash in the backend to track the user's deposit | ||
try { | ||
await trackDaimoDepositTransactionHash(e.txHash, e.payment.source.payerAddress) | ||
} catch (error) { | ||
console.error('Error updating depositor address:', error) | ||
} finally { | ||
setIsUpdatingDepositStatus(false) | ||
setisPaymentSuccess(true) | ||
} | ||
setIsLoading(false) | ||
}, [searchParams, router, user]) | ||
} | ||
|
||
if (isLoading) { | ||
if (isUpdatingDepositStatus) { | ||
return <PeanutLoading /> | ||
} | ||
|
||
const recipientPathSegments = [recipientUsername ?? ''] | ||
if (isPaymentSuccess) { | ||
return ( | ||
<DirectSuccessView | ||
key={`success-add-money}`} | ||
Zishan-7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
headerTitle={'Add Money'} | ||
type="SEND" | ||
currencyAmount={`$${inputTokenAmount}`} | ||
isWithdrawFlow={false} | ||
redirectTo={'/add-money'} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<div className="flex min-h-[inherit] flex-col justify-between gap-8"> | ||
<NavHeader | ||
onPrev={() => { | ||
if (window.history.length > 1) { | ||
router.back() | ||
} else { | ||
router.push('/') | ||
} | ||
}} | ||
title={'Add Money'} | ||
/> | ||
<div className="my-auto flex h-full flex-col justify-center space-y-4"> | ||
<div className="text-sm font-bold">How much do you want to add?</div> | ||
<TokenAmountInput | ||
tokenValue={inputTokenAmount} | ||
setTokenValue={(value: string | undefined) => setInputTokenAmount(value || '')} | ||
className="w-full" | ||
currency={{ | ||
code: 'USD', | ||
symbol: '$', | ||
price: 1, | ||
}} | ||
hideCurrencyToggle | ||
hideBalance | ||
/> | ||
|
||
{address && ( | ||
<DaimoPayButton | ||
amount={inputTokenAmount} | ||
toAddress={address} | ||
onPaymentCompleted={onPaymentCompleted} | ||
variant="purple" | ||
icon="plus" | ||
iconSize={16} | ||
minAmount={0.1} | ||
maxAmount={4000} | ||
onValidationError={setError} | ||
> | ||
Add Money | ||
</DaimoPayButton> | ||
)} | ||
Zishan-7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return <PaymentPage recipient={recipientPathSegments} flow="external_wallet" /> | ||
Zishan-7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div className="min-h-[20px]">{error && <ErrorAlert description={error} />}</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.