Comments (2)
This is a little bit fiddly with the architecture of the app, but you can do it with relatively little change by updating PaymentProvider
Taking a step back, the reason this doesn't work currently is because recipient, label and message all come from ConfigProvider
, which gets its initial values by parsing the URL. This is because in this simple example app we don't have UI for setting those values. Whereas amount
is set in the UI, and it comes from PaymentProvider
, a different context provider. Currently this does not read the URL for values, it's just client side state that's passed between pages by sharing the context provider.
So if we want to make this work we need to read the amount
from the URL in PaymentProvider
. Here's one way to do it:
In PaymentProvider.tsx
Replace the line const [amount, setAmount] = useState<BigNumber>();
With this:
const router = useRouter(); // import { useRouter } from 'next/router';
const { amount: queryAmount } = router.query;
const initialAmount = useMemo(() => {
if (!queryAmount) return undefined;
if (Array.isArray(queryAmount)) return new BigNumber(queryAmount[0]);
return new BigNumber(queryAmount)
}, [queryAmount])
const [amount, setAmount] = useState<BigNumber | undefined>(initialAmount);
Now the amount
set on page load is read from the query param if there's one present, otherwise it defaults to undefined as it currently does. Your example URL should then work :)
Example commit making this change: master...mcintyre94:solana-pay:cm-url-amount
from solana-pay.
Thank you very much. Did you commited this line to the main brunch? Cool. I am looking forward to use this tool. Perfect for so many use cases.
from solana-pay.
Related Issues (20)
- Cannot load from CDN: Uncaught ReferenceError: exports is not defined
- Confirmed Page Not Showing Up HOT 1
- Add a reference project for WooCommerce
- Transferring multiple NFTs in a single QR Code HOT 1
- [feature] add ts package for express middleware around transaction handling HOT 1
- Error parsing recipient from url HOT 1
- Sol Pay method has little visibility/contrast on Shopify. HOT 2
- Pay bills
- Proposal: Solana Pay e-store directory HOT 1
- Not being able to sell my own accounts
- I want to cancel my transaction and send to another wallet 41edaa5901d112216083edc935b268f0faffa0020ce6661e082e5f2b81e01a04 HOT 1
- I want to cancel my transaction and send to another wallet 41edaa5901d112216083edc935b268f0faffa0020ce6661e082e5f2b81e01a04 HOT 1
- If you have been waiting for a long period for your transaction to be processed, the most likely reason is a low transaction fee.
- ValidateTransferError: invalid memo keys HOT 1
- [feature] universal link support
- RC#SYSTEM HOT 1
- createQR function is not compatible with react-native
- Integration with FourthWall
- Solana pay
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solana-pay.