-
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
add advanced invoice #8
base: master
Are you sure you want to change the base?
Conversation
882cf4f
to
d7cfca0
Compare
@@ -35,6 +36,7 @@ def create(amount, destination: nil, reference: nil) | |||
@amount = convert_to_cents(amount) | |||
@destination = destination | |||
@reference = reference | |||
binding.pry |
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,5 +1,6 @@ | |||
require "bigdecimal" | |||
require "money" | |||
require "pry" |
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.
не треба тут
require_relative 'simple_invoice' | ||
module MonopayRuby |
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.
require_relative 'simple_invoice' | |
module MonopayRuby | |
require_relative 'simple_invoice' | |
module MonopayRuby |
827aeab
to
ae19af2
Compare
CHANGELOG.md
Outdated
@@ -1,3 +1,7 @@ | |||
## [1.1.0] - 2024-08-12 | |||
- add `MonopayRuby::Invoices::AdvancedInvoice` |
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.
а чому AdvancedInvoice? В чім його різниця порівняно з simple invoice? І потрібно описати детально функціонал який додається
CHANGELOG.md
Outdated
@@ -1,3 +1,7 @@ | |||
## [1.1.0] - 2024-08-12 | |||
- add `MonopayRuby::Invoices::AdvancedInvoice` | |||
- change private method `request_body` to private |
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.
тобто прайват змінився на прайват? Виглядає по опису що нічого не змінилося, опиши детально що відбулося тут
CHANGELOG.md
Outdated
## [1.1.0] - 2024-08-12 | ||
- add `MonopayRuby::Invoices::AdvancedInvoice` | ||
- change private method `request_body` to private | ||
- modify `README.md` |
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.
яка саме модифікація відбулася?
README.md
Outdated
"https://example.com", | ||
"https://example.com/payments/webhook" |
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.
що це за лінки? Де дока для них?
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.
цей код взагалі не працює
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.
буде помилка параметрів, бо мають бути неймед параметри
@basketOrder = basketOrder | ||
@otherParams = otherParams |
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.
чому тут використаний кемл кейс?
c4494c9
to
e04bf70
Compare
e04bf70
to
9018f07
Compare
README.md
Outdated
"https://example.com", | ||
"https://example.com/payments/webhook" |
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.
цей код взагалі не працює
README.md
Outdated
"https://example.com", | ||
"https://example.com/payments/webhook" |
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.
буде помилка параметрів, бо мають бути неймед параметри
# TODO: add "ccy" and another missing params | ||
# TODO: remove nil valued params |
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.
resolve this todos, or remove
} | ||
} | ||
|
||
request_body[:merchantPaymInfo][:basketOrder] = basketOrder if basketOrder.any? |
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.
а якщо request_body[:merchantPaymInfo]
буде ніл?
} | ||
|
||
request_body[:merchantPaymInfo][:basketOrder] = basketOrder if basketOrder.any? | ||
request_body.merge!(otherParams).to_json |
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.
навіщо тобі бенг метод тут?
request_body[:merchantPaymInfo] = request_body[:merchantPaymInfo].merge!(other_merchant_paymant_info_params) # add additional merchant_payment_info params if they are present | ||
request_body.merge!(other_params) # add additional params if they are present |
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.
remove redundant comments, because they describe the code point in point
if request_body[:merchantPaymInfo].has_key?(:basketOrder) | ||
request_body[:merchantPaymInfo][:basketOrder].first[:sum] = convert_to_cents(amount) |
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.
this is unsafe, cehck if first param present to prevent NilClass undefined method error
if request_body[:merchantPaymInfo].has_key?(:basketOrder) | ||
request_body[:merchantPaymInfo][:basketOrder].first[:sum] = convert_to_cents(amount) | ||
elsif request_body.has_key?(:items) | ||
request_body[:items].first[:sum] = convert_to_cents(amount) |
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.
this is also unsafe, so, you check for the key presence, but value might be nil
private | ||
|
||
def sum_param_into_basket | ||
request_body[:merchantPaymInfo][:basketOrder][:qty] * amount |
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.
add some return if any of parameter is blank
def sum_param_into_basket | ||
request_body[:merchantPaymInfo][:basketOrder][:qty] * amount |
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.
this method isn't used anywhere
222b580
to
bd97df8
Compare
@@ -6,3 +6,5 @@ source "https://rubygems.org" | |||
gemspec | |||
|
|||
gem "rake", "~> 13.0" | |||
gem 'activesupport', '~> 7.0' |
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.
це точно потрібно?
Gemfile
Outdated
@@ -6,3 +6,5 @@ source "https://rubygems.org" | |||
gemspec | |||
|
|||
gem "rake", "~> 13.0" | |||
gem 'activesupport', '~> 7.0' | |||
gem 'yard' |
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.
а це взагалі видаляй
CHANGELOG.md
Outdated
- change private methods to protected | ||
- modify `request_body` for additional params | ||
- add protected method `default_params` | ||
- add more details about `MonopayRuby::Invoices::AdvancedInvoice` into `README.md` |
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.
це не потрібно
CHANGELOG.md
Outdated
- change private methods to protected | ||
- modify `request_body` for additional params | ||
- add protected method `default_params` |
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.
це вже прям деталі реалізації, вони не важливі для користувача
# | ||
# @example Create a payment with amount and additional parameters | ||
# create(100, additional_params: { merchantPaymInfo: { destination: "Happy payment", reference: "ref123" } }) | ||
|
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,3 +1,4 @@ | |||
require 'active_support/all' |
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.
так а це навіщо?)
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.
це, як і гем мені потрібний для методу blank?
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.
ну диви, в сімпл інвойсі воно не потрібне точно, бо не юзається, а так, то хз, я б сказав, що оке, най буде поки що
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.
ну ок, тоді додам в едванс інвойс
end | ||
|
||
it "returns true" do | ||
expect(simple_invoice_instance.create(2000, other_merchant_paymant_info_params: {basketOrder: [basket_order]}, other_params: other_params)).to be_truthy |
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.
винеси параметри в let
@destination = @additional_params&.dig(:merchantPaymInfo, :destination) | ||
@reference = @additional_params&.dig(:merchantPaymInfo, :reference) |
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.
так це ріквайред параметри, вони не можуть бути відсутні, якщо ж відсутні, то рейзани якусь помилку
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.
але ж вони по дефолту ніл, то чому ж вони ріквайред?
|
||
current_params.merge!(additional_params.except(:merchantPaymInfo)) | ||
|
||
# TODO: add sum and qty params into present additional params |
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.
а щодо цього комента що?
set_sum_and_qty_params(current_params&.dig(:merchantPaymInfo, :basketOrder)) | ||
set_sum_and_qty_params(current_params[:items]) |
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.
поясни будь ласка, що тут відбувається
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.
я спробувала розписати це у коментарях
b2acd0c
to
d86027e
Compare
@@ -1,3 +1,4 @@ | |||
require 'active_support/all' |
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.
ну диви, в сімпл інвойсі воно не потрібне точно, бо не юзається, а так, то хз, я б сказав, що оке, най буде поки що
# TODO: add and modify sum and qty params of merchantPaymInfo[basketOrder] parameters if it is present | ||
# TODO: add and modify sum and qty params of items parameters if it is present |
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.
для чого ці ту-ду?)
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.
або пофіксай, або прибери)
d86027e
to
5ed9a41
Compare
No description provided.