Skip to content
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

Can the library be used on the front end? #10

Open
suparpat opened this issue May 14, 2018 · 3 comments
Open

Can the library be used on the front end? #10

suparpat opened this issue May 14, 2018 · 3 comments
Labels

Comments

@suparpat
Copy link

I believe the API library is written for Node.js? Can it also be used on the front end? Thank you!

@suparpat
Copy link
Author

suparpat commented May 14, 2018

OK, I got it working using Browserify:

  1. Clone promptpay-qr
  2. npm install
  3. browserify index.js --s promptpayqr -o front.js
  4. Clone https://github.com/soldair/node-qrcode
  5. npm install
  6. npm run build

then in html file add

<canvas id="qrcode"></canvas>
<script src="front.js"></script>
<script src="qrcode.js"></script> (in node-qrcode's build/ folder)

<script>
var output = promptpayqr('123',{amount:12});
QRCode.toCanvas(document.getElementById('qrcode'), output, function (error) {
    if (error){
    	console.error(error)
	}else{
	    console.log('success!');		    		
	}
  })
 </script>

@dtinth
Copy link
Owner

dtinth commented May 15, 2018

Thanks for sharing!

@dtinth
Copy link
Owner

dtinth commented May 15, 2018

Yes it can be used on frontend but it needs to be compiled, e.g. using browserify/rollup/webpack. 😄

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

No branches or pull requests

2 participants