-
Notifications
You must be signed in to change notification settings - Fork 1
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
feature/ability to apply coupon for price #2
base: master
Are you sure you want to change the base?
feature/ability to apply coupon for price #2
Conversation
…emove confictable require 'pry'
… to MonopayRuby.configuration , add ability to make discount
lib/monopay-ruby/configuration.rb
Outdated
@@ -1,7 +1,8 @@ | |||
class MonopayRuby::Configuration | |||
attr_accessor :api_token | |||
attr_accessor :api_token, :min_value | |||
|
|||
def initialize | |||
@api_token = ENV["MONOBANK_API_TOKEN"] # note ability to use ENV variable in docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можеш цей комент забрати і буду просити створити розділ Configuration
в рідмі, також вкажи там, що можна передати такий параметер і яке значення по дефолту та яке мінімальне, також дай рейз, якщо задане значення меньше мінімального, щось типу Configuration value error: minimal allowed value is 0.01, your is "0"
amount | ||
else | ||
raise TypeError, "expected amount will be an Integer or BigDecimal, got #{amount.class}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
або allowed to use only a BigDecimal or Integer price
README.md
Outdated
``` | ||
* 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
чому не 1? давай теж 1, щоб було зрозуміло різницю
README.md
Outdated
```ruby | ||
# config/initializers/monopay-ruby.rb | ||
MonopayRuby.configure do |config| | ||
config.min_value = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
краще не min_value
, а min_price
README.md
Outdated
Where: | ||
- 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 | ||
* can be Integer, Float or BigDecimal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options:
discount
- ..
discount_is_fixed
- with false
(default) means that discount amount will be preceded by %
. When true
used, means fixed amount of discount will be applied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
щось таке
@@ -30,12 +30,21 @@ 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, destination: nil, reference: nil) | |||
def create(amount, discount=nil, discount_is_fixed=false, destination: nil, reference: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нє, ну це ж кпц), юзай неймед параметри
@@ -30,12 +30,21 @@ 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, destination: nil, reference: nil) | |||
def create(amount, discount: nil, discount_is_fixed: false, destination: nil, reference: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
щось трохи забагато аргументів, по конвеншинам так краще не робити, ну передавати можна, але от явно прописаних вже забагато, макс 3 гуд є, чи близько того
Added: