Skip to content
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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

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
@@ -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
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"

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.

щось таке

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

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)
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
2 participants