Class: PaymentRecipes::PayPal::REST::Payment
- Inherits:
-
Object
- Object
- PaymentRecipes::PayPal::REST::Payment
- Includes:
- Utils::Converters, Utils::Equality
- Defined in:
- lib/payment_recipes/paypal/rest/payment.rb
Instance Attribute Summary collapse
-
#authorizations ⇒ Object
readonly
Returns the value of attribute authorizations.
-
#captures ⇒ Object
readonly
Returns the value of attribute captures.
-
#create_time ⇒ Object
readonly
Returns the value of attribute create_time.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#intent ⇒ Object
readonly
Returns the value of attribute intent.
-
#payer ⇒ Object
readonly
Returns the value of attribute payer.
-
#raw_payment ⇒ Object
readonly
Returns the value of attribute raw_payment.
-
#refunds ⇒ Object
readonly
Returns the value of attribute refunds.
-
#sales ⇒ Object
readonly
Returns the value of attribute sales.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#transactions ⇒ Object
readonly
Returns the value of attribute transactions.
-
#update_time ⇒ Object
readonly
Returns the value of attribute update_time.
Class Method Summary collapse
- .find(id, expand: false) ⇒ Object
- .find_raw(id) ⇒ Object
- .history(count:, page: 1, expand: false) ⇒ Object
Instance Method Summary collapse
- #authorization ⇒ Object
- #capture ⇒ Object
-
#initialize(paypal_payment, expand: false) ⇒ Payment
constructor
A new instance of Payment.
- #inspect ⇒ Object
- #refund ⇒ Object
- #reload! ⇒ Object
- #sale ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
- #transaction ⇒ Object
Methods included from Utils::Equality
Methods included from Utils::Converters
#convert_to_money, #convert_to_string, #convert_to_symbol, #convert_to_time
Constructor Details
#initialize(paypal_payment, expand: false) ⇒ Payment
Returns a new instance of Payment.
21 22 23 24 25 26 27 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 21 def initialize(paypal_payment, expand: false) unless paypal_payment.is_a?(::PayPal::SDK::REST::DataTypes::Payment) raise Exception, "#{ self.class.name } must be initialized with a PayPal Payment" end extract_and_store(paypal_payment, expand: ) end |
Instance Attribute Details
#authorizations ⇒ Object (readonly)
Returns the value of attribute authorizations.
12 13 14 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 12 def @authorizations end |
#captures ⇒ Object (readonly)
Returns the value of attribute captures.
13 14 15 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 13 def captures @captures end |
#create_time ⇒ Object (readonly)
Returns the value of attribute create_time.
7 8 9 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 7 def create_time @create_time end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 5 def id @id end |
#intent ⇒ Object (readonly)
Returns the value of attribute intent.
6 7 8 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 6 def intent @intent end |
#payer ⇒ Object (readonly)
Returns the value of attribute payer.
15 16 17 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 15 def payer @payer end |
#raw_payment ⇒ Object (readonly)
Returns the value of attribute raw_payment.
16 17 18 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 16 def raw_payment @raw_payment end |
#refunds ⇒ Object (readonly)
Returns the value of attribute refunds.
14 15 16 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 14 def refunds @refunds end |
#sales ⇒ Object (readonly)
Returns the value of attribute sales.
11 12 13 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 11 def sales @sales end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
9 10 11 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 9 def state @state end |
#transactions ⇒ Object (readonly)
Returns the value of attribute transactions.
10 11 12 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 10 def transactions @transactions end |
#update_time ⇒ Object (readonly)
Returns the value of attribute update_time.
8 9 10 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 8 def update_time @update_time end |
Class Method Details
.find(id, expand: false) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 69 def find(id, expand: false) paypal_payment = find_raw(id) if paypal_payment new(paypal_payment, expand: ) else nil end end |
.find_raw(id) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 79 def find_raw(id) begin ::PayPal::SDK::REST::Payment.find(id) rescue ::PayPal::SDK::Core::Exceptions::ResourceNotFound nil end end |
.history(count:, page: 1, expand: false) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 88 def history(count:, page: 1, expand: false) paypal_payment_history = ::PayPal::SDK::REST::Payment.all(count: count, start_index: count * (page - 1)) paypal_payment_history.payments.map do |paypal_payment| new(paypal_payment, expand: ) end end |
Instance Method Details
#authorization ⇒ Object
44 45 46 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 44 def @authorizations.first end |
#capture ⇒ Object
48 49 50 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 48 def capture @captures.first end |
#inspect ⇒ Object
56 57 58 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 56 def inspect to_str end |
#refund ⇒ Object
52 53 54 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 52 def refund @refunds.first end |
#reload! ⇒ Object
29 30 31 32 33 34 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 29 def reload! paypal_payment = self.class.find_raw(@id) extract_and_store(paypal_payment) self end |
#sale ⇒ Object
40 41 42 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 40 def sale @sales.first end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 60 def to_s to_str end |
#to_str ⇒ Object
64 65 66 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 64 def to_str "<#{ self.class.name } intent=#{ @intent } state=#{ @state } id=#{ @id }>" end |
#transaction ⇒ Object
36 37 38 |
# File 'lib/payment_recipes/paypal/rest/payment.rb', line 36 def transaction @transactions.first end |