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

Support additional fields in QRCode comment #1

Open
dcolley opened this issue Jun 12, 2022 · 2 comments
Open

Support additional fields in QRCode comment #1

dcolley opened this issue Jun 12, 2022 · 2 comments

Comments

@dcolley
Copy link

dcolley commented Jun 12, 2022

Feature request

We are implementing "Pay with Polkadot" Point-of-Sale feature here:
https://github.com/metaspan/metapay

The solution is opensource and can be self-hosted by any vendor / merchant.

Use cases

  1. Point-of-sale / Kiosk: generate QRcode with all relevant data - user scans with wallet and approves payment
    substrate://<address>:<genesisHash>:amount=1&reference=ref123
    The POS module can watch the address for any payment with reference, and mark the payment as complete.

  2. Webshop: Send a link to user to request payment
    https://pay.metaspan.io/paymentRequest/<address>:<genesisHash>?amount=1&reference=ref123 (to be implemented shortly ;)
    The browser will display a QRcode for wallet to scan
    Also, if available, will connect to polkadot.js (in the browser)
    An optional callback will notify the webshop that payment is done / error.

Broadly, it will embrace similar work already done at Solana Pay
https://github.com/solana-labs/solana-pay/blob/master/SPEC.md

Nova Wallet should support additional fields via URL encoding in the comment

Current support - a QR code with:
substrate:<walletid>:<genesisHash>[:<comment>] - is supported

We need support for:
substrate:[//]<walletid>:<genesisHash>:[?]<url-encoded-fields>

Options for detecting additional fields

const parts = decodedQRString.split(':')
const protocol    = parts[0]
const address     = parts[1]
const genesisHash = parts[2]
const comment     = parts[3]

// Option 1
if (address.startsWith('//')) {}

// Option 2
if (comment && comment.startsWith('?')) {}

Example handler:

const parts = decodedQRString.split(':')
const protocol = parts[0]
if (protocol === 'substrate') {
  const address = parts[1]
  const comment = parts[3]
  if (address.startsWith('//') || ( comment && comment.startsWith('?') ) ) {
    // we have URL-encoded `comment` field
    /*
      [?]amount=<amount>
      &reference=<reference>
      &label=<label>
      &message=<message>
      &memo=<memo>
    */
  } else {
    // simple QR format
  }
} else {
  console.error('Invalid protocol')
}
@ERussel
Copy link
Contributor

ERussel commented Jun 13, 2022

Hey! Thank you for the suggestion. Looks like we need not only support proper QR encoding/decoding, but also pass additional data to the extrinsic from the URL encoded fields. We can't promise to support this feature in the near future due to other priorities on our roadmap. But could you share a more formal protocol description from the Polkadot point of view (not Solana).

Alternatively, you can open a pull request to the library implementing the encoder/decoder for the QR. This for sure will speed up the process of integration.

@dcolley
Copy link
Author

dcolley commented Jun 13, 2022

Hi @ERussel
Thanks for the quick response!

I am engaging with various people to gather support.
We will apply for a Polkadot Grant to do main portion of the work.

I will submit a standard / protocol enhancement - and for this I would prefer to get consensus from the community before I submit.

Please see the ref SPEC.md here. (Yes it's originally from Solana as I think they did a great job). I just realised I have not published this yet. I'll share this shortly for your review.

Any comments or suggestions are most welcome!

In the meantime I'll have a look at the library for a PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants