monopay-ruby 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41fd7749af56a446e34fc1062984cc1c08800180128cf24d839d27a7ba5d23a2
4
- data.tar.gz: feae13953aa57ed285104d43d952498f56a5fed2a7038446d132ab02d00dd31b
3
+ metadata.gz: c7f7b55974b07c60a80ba1251ae477f186566b9589342b8e941a8afaa3cfe41d
4
+ data.tar.gz: 305d7898044358fc96ece83e506daba1f5282146218026352c5cbbda85140c66
5
5
  SHA512:
6
- metadata.gz: 3ea0a349f488c37fb62678f781d5190b5be574a4c243e328c19687ac54a2fa83041c807846b35784e9426a18a1ab9b0e76b5bf6590f420e318246e7dade5c3c8
7
- data.tar.gz: 2f7f47cd045e28f826b03347490d5c0d1fbe042ec28916a0cb4c1c9292e3ed1963aeb0a29bc1e76a72d8fb5e2c1b1c33bec12b68e65d887907b680cabf7ccfb7
6
+ metadata.gz: 3ffbc464d1238fee91fbe8dcfa9177b34536419092c7aa24cea40c583b3f729c9064ae3518c90e61cef6d15d033c45db5678830dcac9411d1644a002f6916ae5
7
+ data.tar.gz: a636899d2837e6213d6014549dff9a62fddba0b4b6cc123ea1b20531a453f96f3729e898fa38a3934f8d0d1bb52c6e6dbad9d8b2094d8b200a399d449fd90cac
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
- ## [Unreleased]
1
+ ## [1.0.0] - 2023-06-27
2
2
 
3
- ## [0.1.0] - 2023-06-15
3
+ ### Changed
4
4
 
5
- - Initial release
5
+ ### Breaking Change
6
+ Updated method signatures in the gem to use keyword arguments instead of named arguments.
7
+
8
+ ###### Specifically
9
+ `MonopayRuby::Invoices::SimpleInvoice::new` method was affected by this change.
10
+ ###### Previously
11
+ the method was called like `new("redirect/url", "webhook/url")`. Now, it should be called like `new(redirect_url: "redirect/url", webhook_url: "webhook/url")`.
12
+ #### Note
13
+ This is a breaking change and will require updating your code if you are updating to this version of the gem from an earlier version.
14
+
15
+ ## [0.1.1] - 2023-06-19
16
+
17
+ - Fix typo in a `README.md` file
18
+ - Add ability to pass reference to an invoice by `reference` parameter in a `MonopayRuby::Invoices::SimpleInvoice::create` method
19
+ - Use keyword parameter of `destination` for "MonopayRuby::Invoices::SimpleInvoice::create" method
20
+
21
+ ## [0.1.0] - 2023-06-18
22
+
23
+ - Initial public release
data/Gemfile.lock CHANGED
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monopay-ruby (0.1.0)
4
+ monopay-ruby (1.0.0)
5
5
  base64 (~> 0.1.1)
6
6
  json (~> 2.5)
7
7
  money (~> 6.13)
8
- openssl (~> 2.1)
9
8
  rest-client (~> 2.1)
10
9
 
11
10
  GEM
@@ -23,7 +22,6 @@ GEM
23
22
  domain_name (~> 0.5)
24
23
  i18n (1.14.1)
25
24
  concurrent-ruby (~> 1.0)
26
- ipaddr (1.2.5)
27
25
  json (2.6.3)
28
26
  method_source (1.0.0)
29
27
  mime-types (3.4.1)
@@ -32,8 +30,6 @@ GEM
32
30
  money (6.16.0)
33
31
  i18n (>= 0.6.4, <= 2)
34
32
  netrc (0.11.0)
35
- openssl (2.2.3)
36
- ipaddr
37
33
  pry (0.14.2)
38
34
  coderay (~> 1.1)
39
35
  method_source (~> 1.0)
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Actions Status](https://github.com/loqimean/monopay-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/loqimean/monopay-ruby/actions)
2
+
1
3
  # MonopayRuby
2
4
 
3
5
  The "monopay-ruby" gem simplifies Monobank payment integration in Ruby and Rails applications. It provides an intuitive interface and essential functionalities for generating payment requests, verifying transactions, handling callbacks, and ensuring data integrity. With this gem, you can quickly and securely implement Monobank payments, saving development time and delivering a seamless payment experience to your users.
@@ -37,8 +39,10 @@ The second one - add to the environment variable:
37
39
  MONOPAY_API_TOKEN=your_api_token
38
40
  ```
39
41
 
40
- You can get the API token depending on the environment:
42
+ #### You can get the API token depending on the environment:
43
+
41
44
  Development: [https://api.monobank.ua/](https://api.monobank.ua/)
45
+
42
46
  Production: [https://fop.monobank.ua/](https://fop.monobank.ua/)
43
47
 
44
48
  Just get the token and go to earn moneys! 🚀
@@ -50,11 +54,11 @@ Just get the token and go to earn moneys! 🚀
50
54
  class PaymentsController < ApplicationController
51
55
  def create
52
56
  payment = MonopayRuby::Invoices::SimpleInvoice.new(
53
- redirect_url: "https://example.com",
54
- webhook_url: "https://example.com/payments/webhook"
57
+ "https://example.com",
58
+ "https://example.com/payments/webhook"
55
59
  )
56
60
 
57
- if payment.create(amount: 100, description: "Payment description",)
61
+ if payment.create(amount: 100, destination: "Payment description",)
58
62
  # your success code processing
59
63
  else
60
64
  # your error code processing
@@ -4,11 +4,11 @@ require "money"
4
4
  module MonopayRuby
5
5
  module Invoices
6
6
  class SimpleInvoice < MonopayRuby::Base
7
- attr_reader :invoice_id, :page_url, :error_messages, :amount, :destination, :redirect_url, :webhook_url
7
+ attr_reader :invoice_id, :page_url, :error_messages, :amount, :destination, :reference, :redirect_url, :webhook_url
8
8
 
9
9
  API_CREATE_INVOICE_URL = "#{API_URL}/merchant/invoice/create".freeze
10
10
 
11
- CURRENCY = "UAH".freeze
11
+ DEFAULT_CURRENCY = "UAH".freeze
12
12
 
13
13
  PAGE_URL_KEY = "pageUrl".freeze
14
14
  INVOICE_ID_KEY = "invoiceId".freeze
@@ -17,7 +17,7 @@ module MonopayRuby
17
17
  #
18
18
  # @param [String] redirect_url - url where user will be redirected after payment
19
19
  # @param [String] webhook_url - url where Monobank will send webhook after payment
20
- def initialize(redirect_url = nil, webhook_url = nil)
20
+ def initialize(redirect_url: nil, webhook_url: nil)
21
21
  @redirect_url = redirect_url
22
22
  @webhook_url = webhook_url
23
23
 
@@ -28,11 +28,13 @@ module MonopayRuby
28
28
  #
29
29
  # @param [BigDecimal,Integer] amount in UAH (cents) to request payment
30
30
  # @param [String] destination - additional info about payment
31
+ # @param [String] reference - bill number or other reference
31
32
  # @return [Boolean] true if invoice was created successfully, false otherwise
32
- def create(amount, destination = nil)
33
+ def create(amount, destination: nil, reference: nil)
33
34
  begin
34
35
  @amount = convert_to_cents(amount)
35
36
  @destination = destination
37
+ @reference = reference
36
38
 
37
39
  response = RestClient.post(API_CREATE_INVOICE_URL, request_body, headers)
38
40
  response_body = JSON.parse(response.body)
@@ -64,6 +66,7 @@ module MonopayRuby
64
66
  redirectUrl: redirect_url,
65
67
  webHookUrl: webhook_url,
66
68
  merchantPaymInfo: {
69
+ reference: reference,
67
70
  destination: destination
68
71
  }
69
72
  }.to_json
@@ -71,7 +74,7 @@ module MonopayRuby
71
74
 
72
75
  def convert_to_cents(amount)
73
76
  if amount.is_a?(BigDecimal)
74
- Money.from_amount(amount, CURRENCY).cents
77
+ Money.from_amount(amount, DEFAULT_CURRENCY).cents
75
78
  else
76
79
  amount
77
80
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MonopayRuby
4
- VERSION = "0.1.0"
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monopay-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - loqimean
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-18 00:00:00.000000000 Z
11
+ date: 2023-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.5'
55
- - !ruby/object:Gem::Dependency
56
- name: openssl
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '2.1'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '2.1'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: money
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +134,6 @@ files:
148
134
  - lib/monopay-ruby/version.rb
149
135
  - lib/monopay-ruby/webhooks/public_key.rb
150
136
  - lib/monopay-ruby/webhooks/validator.rb
151
- - monopay-ruby.gemspec
152
137
  - sig/monopay_ruby.rbs
153
138
  homepage: https://github.com/loqimean/monopay-ruby
154
139
  licenses:
@@ -172,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
157
  - !ruby/object:Gem::Version
173
158
  version: '0'
174
159
  requirements: []
175
- rubygems_version: 3.3.7
160
+ rubygems_version: 3.4.12
176
161
  signing_key:
177
162
  specification_version: 4
178
163
  summary: The "monopay-ruby" gem is a powerful Ruby library designed for seamless integration
data/monopay-ruby.gemspec DELETED
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # to load all /lib files
4
- $LOAD_PATH.push File.expand_path("lib", __dir__)
5
-
6
- require_relative "lib/monopay-ruby/version"
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = "monopay-ruby"
10
- spec.version = MonopayRuby::VERSION
11
- spec.authors = ["loqimean"]
12
- spec.email = ["vanuha277@gmail.com"]
13
-
14
- spec.summary = "The \"monopay-ruby\" gem is a powerful Ruby library designed for seamless integration with Monobank's payment system. It provides a convenient way to handle Monobank payments within Ruby and Rails applications, simplifying the process and saving you valuable development time."
15
- spec.description = "The \"monopay-ruby\" gem simplifies Monobank payment integration in Ruby and Rails applications. It provides an intuitive interface and essential functionalities for generating payment requests, verifying transactions, handling callbacks, and ensuring data integrity. With this gem, you can quickly and securely implement Monobank payments, saving development time and delivering a seamless payment experience to your users."
16
- spec.homepage = "https://github.com/loqimean/monopay-ruby"
17
- spec.license = "MIT"
18
- spec.required_ruby_version = ">= 2.6.0"
19
-
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = "https://github.com/loqimean/monopay-ruby"
22
- spec.metadata["changelog_uri"] = "https://github.com/loqimean/monopay-ruby/blob/master/CHANGELOG.md"
23
-
24
- # Specify which files should be added to the gem when it is released.
25
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
- spec.files = Dir.chdir(__dir__) do
27
- `git ls-files -z`.split("\x0").reject do |f|
28
- (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
29
- end
30
- end
31
- spec.bindir = "exe"
32
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
- spec.require_paths = ["lib"]
34
-
35
- # Uncomment to register a new dependency of your gem
36
- # TODO: Use metal versions of gems where possible to avoid unnecessary extra
37
- spec.add_dependency "rest-client", "~> 2.1"
38
- spec.add_dependency "base64", "~> 0.1.1"
39
- spec.add_dependency "json", "~> 2.5"
40
- spec.add_dependency "openssl", "~> 2.1"
41
- spec.add_dependency "money", "~> 6.13"
42
-
43
- spec.add_development_dependency "rspec", "~> 3.0"
44
- spec.add_development_dependency "pry", "~> 0.14.2"
45
- spec.add_development_dependency "simplecov", "~> 0.22.0"
46
-
47
- # For more information and examples about making a new gem, check out our
48
- # guide at: https://bundler.io/guides/creating_gem.html
49
- end