upi 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0e39f9a2fd875f3180e609a85f83ff9655615b6d7a488c7e6c429cf8c13116c
4
- data.tar.gz: b022628db4f744f477049ea8dfa9f57359948ff0e55b6c5c02a68ffd16e52855
3
+ metadata.gz: 9a37c055bc91cf1e03c77c5f34e4faf6d4ab3c9a36040b35666f8852bfb2a393
4
+ data.tar.gz: 04af7b5a7bbdd2e5de3f6373b81d07f2249f1fedd6c25dedc8f1da126c007abb
5
5
  SHA512:
6
- metadata.gz: f6d835ac551a922fea2b3b24e3f18f95277895e69953c3516bf80be3e2fe9f0ff38a228e12f9eca7029ad68712d933af78b7fdfe4f40cb1262cbdc21b3cc6c88
7
- data.tar.gz: f95200673d9726028e5ed770b6def9dee46ae7f1cdb743f46bbf45a2fb6348dbce129c8a7cd92779d333ab565ec8d5a7d90ea3861d21cd77bdb30c6b1bf12777
6
+ metadata.gz: 90a0302d1e18d5db151b47d05ea36ee7a4c5b393d2ecfba7fd9ed9dee02eeda464e2f6f021dbe25d9cf2a75e843d523caf3b5950f839917907f7927e408a559f
7
+ data.tar.gz: fa8833dbdd9ea34ab2cad64af8657d4f088302926cf27119a0b5548111d5874d0f7845ecc3b5ebb8ee260f0426f336e75df8c89ce7e98e1094f16de67b0043bb
data/.rubocop.yml CHANGED
@@ -3,11 +3,20 @@ AllCops:
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
6
- EnforcedStyle: double_quotes
6
+ EnforcedStyle: single_quotes
7
7
 
8
8
  Style/StringLiteralsInInterpolation:
9
9
  Enabled: true
10
10
  EnforcedStyle: double_quotes
11
11
 
12
12
  Layout/LineLength:
13
- Max: 120
13
+ Max: 300
14
+
15
+ Metrics/MethodLength:
16
+ Max: 60
17
+
18
+ Metrics/BlockLength:
19
+ Max: 150
20
+
21
+ Metrics/ParameterLists:
22
+ Max: 15
data/Gemfile CHANGED
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in upi.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ gem 'rake', '~> 13.0'
9
9
 
10
- gem "rspec", "~> 3.0"
10
+ gem 'rspec', '~> 3.0'
11
11
 
12
- gem "rubocop", "~> 1.21"
12
+ gem 'rubocop', '~> 1.21'
13
13
 
14
- gem "rqrcode", "~> 1.1"
14
+ gem 'rqrcode', '~> 1.1'
15
15
 
16
16
  gem 'chunky_png'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- upi (1.0.0)
4
+ upi (1.0.1)
5
5
  chunky_png
6
6
  rqrcode (~> 1.1)
7
7
 
@@ -55,6 +55,8 @@ GEM
55
55
 
56
56
  PLATFORMS
57
57
  arm64-darwin-23
58
+ x86_64-darwin-23
59
+ x86_64-linux
58
60
 
59
61
  DEPENDENCIES
60
62
  chunky_png
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Upi
1
+ # UPI
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/upi`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ 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.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,87 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ Usage
24
+ Generating a QR Code
25
+ To generate a UPI QR code, you need to initialize the Upi::Generator class with the required parameters and call the generate_qr method.
26
+
27
+ Example
28
+
29
+ ```ruby
30
+ require 'upi'
31
+ ```
32
+
33
+ ### Create a new UPI QR code generator instance
34
+ ```ruby
35
+ generator = Upi::Generator.new(
36
+ upi_id: 'test@upi',
37
+ name: 'Test Name',
38
+ amount: 100,
39
+ note: 'Test Description'
40
+ )
41
+
42
+ ```
43
+
44
+ ### Generate QR code in SVG format
45
+ ```ruby
46
+ svg_content = generator.generate_qr(mode: :svg)
47
+ File.write('qr_code.svg', svg_content)
48
+ ```
49
+
50
+ ### Generate QR code in PNG format
51
+ ```ruby
52
+ png_content = generator.generate_qr(mode: :png)
53
+ File.binwrite('qr_code.png', png_content)
54
+ ```
55
+
56
+ ### Generating a Payment URL
57
+ 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.
58
+
59
+ Example
60
+ ```ruby
61
+ require 'upi'
62
+
63
+ # Create a new UPI URL generator instance
64
+ generator = Upi::Generator.new(
65
+ upi_id: 'test@upi',
66
+ name: 'Test Name',
67
+ amount: 100,
68
+ note: 'Test Description'
69
+ )
70
+
71
+ # Generate UPI payment URL
72
+ payment_url = generator.generate_url
73
+ puts payment_url
74
+
75
+ # The generate_url method returns a UPI URI string that can be used as a link in your HTML:
76
+ ```
77
+
78
+ ```html
79
+ <a href="<%= payment_url %>">Pay Now</a>
80
+ ```
81
+
82
+ #### In the example above:
83
+
84
+ * Replace `'test@upi'` with the UPI ID of the recipient.
85
+ * Replace `'Test Name'` with the recipient's name.
86
+ * The `amount` parameter specifies the payment amount.
87
+ * `note` is an optional field to include additional information.
88
+ Parameters
89
+ * upi_id: The UPI ID of the recipient.
90
+ * name: The name of the recipient.
91
+ * amount: The amount for the payment (required for UPI transactions).
92
+ * currency: Currency code (default is 'INR').
93
+ * note: Additional note or description for the payment.
94
+ * merchant_code: Optional merchant code.
95
+ * transaction_ref_id: Optional transaction reference ID.
96
+ * transaction_id: Optional transaction ID.
97
+ * url: Optional URL for additional information or payment redirect.
98
+
99
+ #### Handling PNG and SVG
100
+ You can specify the format of the QR code by using the mode parameter:
101
+
102
+ * mode: :svg generates an SVG format QR code.
103
+ * mode: :png generates a PNG format QR code.
26
104
 
27
105
  ## Development
28
106
 
@@ -32,7 +110,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
110
 
33
111
  ## Contributing
34
112
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/upi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/upi/blob/master/CODE_OF_CONDUCT.md).
113
+ 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](https://github.com/[USERNAME]/upi/blob/master/CODE_OF_CONDUCT.md).
36
114
 
37
115
  ## License
38
116
 
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
8
+ require 'rubocop/rake_task'
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "bundler/setup"
5
- require "upi"
4
+ require 'bundler/setup'
5
+ require 'upi'
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -11,5 +11,5 @@ require "upi"
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
- require "irb"
14
+ require 'irb'
15
15
  IRB.start(__FILE__)
data/lib/upi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Upi
4
- VERSION = "1.0.0"
4
+ VERSION = '1.0.1'
5
5
  end
data/lib/upi.rb CHANGED
@@ -1,9 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rqrcode'
4
- require_relative "upi/version"
4
+ require_relative 'upi/version'
5
5
 
6
6
  module Upi
7
+ # The Generator class is responsible for creating UPI QR codes and payment URLs.
8
+ #
9
+ # You can generate a QR code for a UPI payment in either SVG or PNG format,
10
+ # and also create a UPI payment URL for use in HTML links.
11
+ #
12
+ # Example usage:
13
+ #
14
+ # generator = Upi::Generator.new(
15
+ # upi_id: 'test@upi',
16
+ # name: 'Test Name',
17
+ # amount: 100,
18
+ # note: 'Test Description'
19
+ # )
20
+ #
21
+ # svg_content = generator.generate_qr(mode: :svg)
22
+ # png_content = generator.generate_qr(mode: :png)
23
+ # payment_url = generator.generate_url
24
+ #
25
+ # Parameters:
26
+ # - `upi_id`: The UPI ID of the recipient.
27
+ # - `name`: The name of the recipient.
28
+ # - `amount`: The payment amount (required for UPI transactions).
29
+ # - `currency`: The currency code (default is 'INR').
30
+ # - `note`: An optional note or description for the payment.
31
+ # - `merchant_code`: An optional merchant code.
32
+ # - `transaction_ref_id`: An optional transaction reference ID.
33
+ # - `transaction_id`: An optional transaction ID.
34
+ # - `url`: An optional URL for additional information or payment redirect.
35
+ #
36
+ # @example
37
+ # generator = Upi::Generator.new(
38
+ # upi_id: 'test@upi',
39
+ # name: 'Test Name',
40
+ # amount: 100
41
+ # )
42
+ # svg_content = generator.generate_qr(mode: :svg)
43
+ # File.write('qr_code.svg', svg_content)
44
+ #
45
+ # @see https://www.upi.gov.in/ for more details on UPI protocol
7
46
  class Generator
8
47
  attr_reader :params
9
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Faraz Noor
@@ -11,33 +11,33 @@ cert_chain: []
11
11
  date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rqrcode
14
+ name: chunky_png
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.1'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: chunky_png
28
+ name: rqrcode
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.1'
41
41
  description: This gem generates UPI QR codes for payments. It can be used in e-commerce
42
42
  applications to generate QR codes for payments. The QR codes can be scanned by UPI
43
43
  apps to make payments. The gem uses the rqrcode gem to generate the QR codes.