Skip to content

Commit

Permalink
used named params in create payment method, fix README with Grammarly
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriyAndriyovuch committed Sep 16, 2023
1 parent c9cf3ba commit e272515
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Install the gem and add to the application's Gemfile by executing:
bundle add "monopay-ruby"
```

If bundler is not being used to manage dependencies, install the gem by executing:
If bundler is not being used to manage dependencies, install the gem by executing the:

```ruby
gem install "monopay-ruby"
Expand Down Expand Up @@ -46,7 +46,7 @@ Development: [https://api.monobank.ua/](https://api.monobank.ua/)

Production: [https://fop.monobank.ua/](https://fop.monobank.ua/)

Just get the token and go to earn moneys! 🚀
Just get the token and go to earn money! 🚀


_______________________________________________________________
Expand All @@ -58,14 +58,14 @@ You may add a minimum value to your payment:
```ruby
# config/initializers/monopay-ruby.rb
MonopayRuby.configure do |config|
config.min_value = 1
config.min_price = 1
end
```
* 0.01 UAH - it is a minimal valid value for Monobank:
- if you use 1 as an Integer it is equal to 0.01 UAH
- if you use BigDeciamal(5) it's equal to 5 UAH
- if you use BigDecimal(1) it's equal to 1 UAH

Default value is 1 (0.01 UAH)
The default value is 1 (0.01 UAH)


### Generate payment request
Expand All @@ -82,7 +82,7 @@ class PaymentsController < ApplicationController
)

if payment.create(amount: 100, destination: "Payment description")
# your success code processing
# your successful code processing
else
# your error code processing
# flash[:error] = payment.error_messages
Expand All @@ -103,7 +103,7 @@ class PaymentsController < ApplicationController
)

if payment.create(amount: 100, discount: 20, discount_is_fixed: true, destination: "Payment description")
# your success code processing
# your successful code processing
else
# your error code processing
# flash[:error] = payment.error_messages
Expand All @@ -112,11 +112,11 @@ class PaymentsController < ApplicationController
end
```

Where:
Options:
- discount - is an number, which represents a % of discount if discount_is_fixed: false and an amount of discount if discount_is_fixed: true
- discount_is_fixed - a Boolean which set type of discount:
- ```true``` if it's with fixed amount, for example a coupon
- ```false``` if you need a some percentage of discount
- discount_is_fixed - a Boolean which sets the type of discount:
- ```true``` fixed amount of discount will be applied, for example a coupon
- ```false``` discount amount will be preceded by %.
* can be Integer, Float or BigDecimal


Expand All @@ -131,7 +131,7 @@ class PaymentsController < ApplicationController
webhook_validator = MonopayRuby::Webhooks::Validator.new(request)

if webhook_validator.valid?
# your success code processing
# your successful code processing
else
# your error code processing
# flash[:error] = webhook_validator.error_messages
Expand Down
4 changes: 2 additions & 2 deletions lib/monopay-ruby/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class MonopayRuby::Configuration
attr_accessor :api_token, :min_value
attr_accessor :api_token, :min_price

def initialize
@api_token = ENV["MONOBANK_API_TOKEN"]
@min_value = ENV["MIN_VALUE"] || 1
@min_price = ENV["MIN_PRICE"] || 1
end
end
4 changes: 2 additions & 2 deletions lib/monopay-ruby/invoices/simple_invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def initialize(redirect_url: nil, webhook_url: nil)
# @param [String] destination - additional info about payment
# @param [String] reference - bill number or other reference
# @return [Boolean] true if invoice was created successfully, false otherwise
def create(amount, discount=nil, discount_is_fixed=false, destination: nil, reference: nil)
def create(amount, discount: nil, discount_is_fixed: false, destination: nil, reference: nil)

begin
@min_amount = MonopayRuby::Services::ValidateValue.call(MonopayRuby.configuration.min_value, DEFAULT_CURRENCY, "Minimal amount")
@min_amount = MonopayRuby::Services::ValidateValue.call(MonopayRuby.configuration.min_price, DEFAULT_CURRENCY, "Minimal amount")
@amount = MonopayRuby::Services::ValidateValue.call(amount, DEFAULT_CURRENCY)

@destination = destination
Expand Down

0 comments on commit e272515

Please sign in to comment.