-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1d264a
commit 91f6faf
Showing
13 changed files
with
1,260 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Braintree | ||
class TransactionLineItem | ||
include BaseModule | ||
attr_reader :quantity | ||
attr_reader :name | ||
attr_reader :description | ||
attr_reader :kind | ||
attr_reader :unit_amount | ||
attr_reader :unit_tax_amount | ||
attr_reader :unit_of_measure | ||
attr_reader :discount_amount | ||
attr_reader :total_amount | ||
attr_reader :product_code | ||
attr_reader :commodity_code | ||
attr_reader :url | ||
|
||
def initialize(gateway, attributes) # :nodoc: | ||
@gateway = gateway | ||
set_instance_variables_from_hash(attributes) | ||
@quantity = Util.to_big_decimal(quantity) | ||
@unit_amount = Util.to_big_decimal(unit_amount) | ||
@unit_tax_amount = Util.to_big_decimal(unit_tax_amount) | ||
@discount_amount = Util.to_big_decimal(discount_amount) | ||
@total_amount = Util.to_big_decimal(total_amount) | ||
end | ||
|
||
class << self | ||
protected :new | ||
def _new(*args) # :nodoc: | ||
self.new *args | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Braintree | ||
class TransactionLineItemGateway # :nodoc: | ||
def initialize(gateway) | ||
@gateway = gateway | ||
@config = gateway.config | ||
@config.assert_has_access_token_or_keys | ||
end | ||
|
||
def find_all(transaction_id) | ||
raise ArgumentError, "transaction_id cannot be blank" if transaction_id.nil? || transaction_id.strip.to_s == "" | ||
response = @config.http.get("#{@config.base_merchant_path}/transactions/#{transaction_id}/line_items") | ||
response[:line_items].map do |line_item_params| | ||
TransactionLineItem._new(@gateway, line_item_params) | ||
end | ||
rescue NotFoundError | ||
raise NotFoundError, "transaction with id #{transaction_id.inspect} not found" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.