Skip to content

Conversation

@AndriyAndriyovuch
Copy link
Collaborator

@AndriyAndriyovuch AndriyAndriyovuch commented Jul 12, 2023

Added:

  • ability to make discount
  • set minimum value
  • checks to avoid payment with amount which is less than minimum value
  • default minimum value (0.01 UAH)

@AndriyAndriyovuch AndriyAndriyovuch added the enhancement New feature or request label Jul 12, 2023
@AndriyAndriyovuch AndriyAndriyovuch self-assigned this Jul 12, 2023
@AndriyAndriyovuch AndriyAndriyovuch linked an issue Jul 12, 2023 that may be closed by this pull request
attr_accessor :api_token, :min_value

def initialize
@api_token = ENV["MONOBANK_API_TOKEN"] # note ability to use ENV variable in docs
Copy link
Owner

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"

elsif amount.is_a?(Integer)
amount
else
raise TypeError, "expected amount will be an Integer or BigDecimal, got #{amount.class}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be

Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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
Comment on lines 114 to 119
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
Copy link
Owner

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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

щось таке

# @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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нє, ну це ж кпц), юзай неймед параметри

# @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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

щось трохи забагато аргументів, по конвеншинам так краще не робити, ну передавати можна, але от явно прописаних вже забагато, макс 3 гуд є, чи близько того

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to apply coupon for price

3 participants