Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 8046

How to process Solana pay deeplink/ qr code on testnet?

$
0
0

I am using typescript with node and returning my Solana responses using a telegram bot. I want to simply do a transfer using a deep link from Solana pay to the provided wallet address. I have successfully obtained a url and qr code from Solana pay on testnet using this code snippet:

    const generateSolanaPayLink = (destinationPublicKey: string, amountSOL: number): string => {     const amount = new BigNumber(amountSOL);     const recipient = new PublicKey(destinationPublicKey);     const reference = keypair.publicKey;     const label = 'Test SOL transfer';     const message = 'SOL transfer ';     const memo = 'JC#4098';     const url = encodeURL({ recipient, amount, reference, label, message, memo });     return url.href; }; // Function to convert Data URL to Buffer function dataURLToBuffer(dataURL: string): Buffer {     const base64Data = dataURL.replace(/^data:image\/png;base64,/, '');     return Buffer.from(base64Data, 'base64'); } const generateQRCode = async (destinationPublicKey: string, amountSOL: number): Promise<Buffer> => {     const solanaPayLink = generateSolanaPayLink(destinationPublicKey, amountSOL);     try {         const qrCodeDataURL = await qrCode.toDataURL(solanaPayLink);         const qrCodeBuffer = dataURLToBuffer(qrCodeDataURL);         return qrCodeBuffer;     } catch (error) {         console.error('Error generating QR code:', error);         throw new Error('Failed to generate QR code');     } };

The issue that I am having is once I open this qr code in phantom the details are all there, but the payment does not process.I know that these qr codes are a way of signing, but how do I know once someone has accessed this qr code to continue with the transaction? I saw that it might require Https as well which I do not have as I am working locally.

I noticed Solana pay also has transfer requests, in which you define endpoints so you can inject your own code there, and I don't know whether that is the more correct way to go about it.

I have all these bits and pieces of info but have been unable to tie them all together. Please may someone assist with some code examples and the best way to work with Solana pay?


Viewing all articles
Browse latest Browse all 8046

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>