
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
The upi
gem allows you to generate UPI QR codes for user-to-user payments. It supports both PNG and SVG formats for QR codes.
Add this line to your application's Gemfile:
gem 'upi'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install upi
Generating a QR Code To generate a UPI QR code, you need to initialize the Upi::Generator class with the required parameters and call the generate_qr method.
require 'upi'
generator = Upi::Generator.new(
upi_id: 'test@upi',
name: 'Test Name'
)
# NOTE: For Individual Mode the Merchant Code is always 0000 which the code handles by default
svg_content = generator.generate_qr(100, 'Personal Payment', mode: :svg)
File.write('qr_code.svg', svg_content)
png_content = generator.generate_qr(100, 'Personal Payment', mode: :png)
File.binwrite('qr_code.png', png_content)
You can generate a UPI payment URL suitable for use in HTML links by using the generate_url method. This URL can be used as the href attribute in a "Pay Now" button or link.
# Generate UPI payment URL
payment_url = generator.upi_content(100, 'Personal Payment')
puts payment_url
# The generate_url method returns a UPI URI string that can be used as a link in your HTML:
<a href="<%= payment_url %>">Pay Now</a>
require 'upi'
generator = Upi::Generator.new(
upi_id: 'test@upi',
name: 'Test Name',
merchant_code: '1234',
currency: 'INR'
)
# NOTE: For Merchant Mode the Merchant Code needs to be set explicitly
svg_content = generator.generate_qr(500, 'Payment for Goods', transaction_ref_id: 'REF123', transaction_id: 'TXN456', url: 'https://merchant.com/payment', mode: :svg)
File.write('qr_code_merchant.svg', svg_content)
png_content = generator.generate_qr(500, 'Payment for Goods', transaction_ref_id: 'REF123', transaction_id: 'TXN456', url: 'https://merchant.com/payment', mode: :png)
File.binwrite('qr_code_merchant.png', png_content)
You can generate a UPI payment URL suitable for use in HTML links by using the generate_url method. This URL can be used as the href attribute in a "Pay Now" button or link.
# Generate UPI payment URL
payment_url = generator.upi_content(500, 'Payment for Goods', transaction_ref_id: 'REF123', transaction_id: 'TXN456', url: 'https://merchant.com/payment')
puts payment_url
# The generate_url method returns a UPI URI string that can be used as a link in your HTML:
<a href="<%= payment_url %>">Pay Now</a>
'test@upi'
with the UPI ID of the recipient.'Test Name'
with the recipient's name.amount
parameter specifies the payment amount.note
is an optional field to include additional information.
ParametersYou can specify the format of the QR code by using the mode parameter:
If you want to generate a QR code without parsing the UPI address, you can use the no_uri_parse option:
svg_content = generator.generate_qr(100, 'Personal Payment', no_uri_parse: true, mode: :svg)
uri_content = generator.upi_content(100, 'Personal Payment', no_uri_parse: true)
# The no_uri_parse option will generate the QR code without URI parsing the UPI address.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/stingrayzboy/upi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Upi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that upi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.