Class: PaymentRecipes::PayPal::REST::Authorization
- Inherits:
-
Object
- Object
- PaymentRecipes::PayPal::REST::Authorization
- Includes:
- Utils::Converters, Utils::Equality
- Defined in:
- lib/payment_recipes/paypal/rest/authorization.rb
Instance Attribute Summary collapse
-
#create_time ⇒ Object
readonly
Returns the value of attribute create_time.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#expanded ⇒ Object
readonly
Returns the value of attribute expanded.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#payment ⇒ Object
readonly
Returns the value of attribute payment.
-
#payment_id ⇒ Object
readonly
Returns the value of attribute payment_id.
-
#payment_mode ⇒ Object
readonly
Returns the value of attribute payment_mode.
-
#protection_eligibility ⇒ Object
readonly
Returns the value of attribute protection_eligibility.
-
#protection_eligibility_type ⇒ Object
readonly
Returns the value of attribute protection_eligibility_type.
-
#raw_authorization ⇒ Object
readonly
Returns the value of attribute raw_authorization.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#subtotal ⇒ Object
readonly
Returns the value of attribute subtotal.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#update_time ⇒ Object
readonly
Returns the value of attribute update_time.
-
#valid_until ⇒ Object
readonly
Returns the value of attribute valid_until.
Class Method Summary collapse
Instance Method Summary collapse
- #authorized? ⇒ Boolean
- #can_be_captured? ⇒ Boolean
- #capture ⇒ Object
- #captured? ⇒ Boolean
- #captures ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(paypal_authorization, payment: nil, expanded: false) ⇒ Authorization
constructor
A new instance of Authorization.
- #inspect ⇒ Object
- #partially_captured? ⇒ Boolean
- #pending? ⇒ Boolean
- #reload! ⇒ Object
- #reload_payment! ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
- #voided? ⇒ Boolean
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_authorization, payment: nil, expanded: false) ⇒ Authorization
Returns a new instance of Authorization.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 26 def initialize(, payment: nil, expanded: false) unless .is_a?(::PayPal::SDK::REST::DataTypes::Authorization) raise Exception, "#{ self.class.name } must be initialized with a PayPal Authorization" end if payment unless payment.is_a?(::PaymentRecipes::PayPal::REST::Payment) raise Exception, "Parameter payment must be a PaymentRecipes::PayPal::Payment" end @payment = payment @payment_id = payment.id end extract_and_store() @expanded = end |
Instance Attribute Details
#create_time ⇒ Object (readonly)
Returns the value of attribute create_time.
12 13 14 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 12 def create_time @create_time end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
6 7 8 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 6 def currency @currency end |
#expanded ⇒ Object (readonly)
Returns the value of attribute expanded.
20 21 22 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 20 def @expanded end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 5 def id @id end |
#payment ⇒ Object (readonly)
Returns the value of attribute payment.
8 9 10 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 8 def payment @payment end |
#payment_id ⇒ Object (readonly)
Returns the value of attribute payment_id.
9 10 11 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 9 def payment_id @payment_id end |
#payment_mode ⇒ Object (readonly)
Returns the value of attribute payment_mode.
16 17 18 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 16 def payment_mode @payment_mode end |
#protection_eligibility ⇒ Object (readonly)
Returns the value of attribute protection_eligibility.
17 18 19 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 17 def protection_eligibility @protection_eligibility end |
#protection_eligibility_type ⇒ Object (readonly)
Returns the value of attribute protection_eligibility_type.
18 19 20 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 18 def protection_eligibility_type @protection_eligibility_type end |
#raw_authorization ⇒ Object (readonly)
Returns the value of attribute raw_authorization.
21 22 23 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 21 def @raw_authorization end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
11 12 13 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 11 def state @state end |
#subtotal ⇒ Object (readonly)
Returns the value of attribute subtotal.
10 11 12 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 10 def subtotal @subtotal end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
7 8 9 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 7 def total @total end |
#update_time ⇒ Object (readonly)
Returns the value of attribute update_time.
13 14 15 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 13 def update_time @update_time end |
#valid_until ⇒ Object (readonly)
Returns the value of attribute valid_until.
14 15 16 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 14 def valid_until @valid_until end |
Class Method Details
.find(id) ⇒ Object
131 132 133 134 135 136 137 138 139 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 131 def find(id) = find_raw(id) if new(, payment: nil, expanded: true) else nil end end |
.find_raw(id) ⇒ Object
141 142 143 144 145 146 147 148 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 141 def find_raw(id) begin ::PayPal::SDK::REST::Authorization.find(id) rescue ::PayPal::SDK::Core::Exceptions::ResourceNotFound nil end end |
Instance Method Details
#authorized? ⇒ Boolean
98 99 100 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 98 def @state == :authorized end |
#can_be_captured? ⇒ Boolean
118 119 120 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 118 def can_be_captured? || partially_captured? end |
#capture ⇒ Object
86 87 88 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 86 def capture captures.first end |
#captured? ⇒ Boolean
106 107 108 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 106 def captured? @state == :captured end |
#captures ⇒ Object
82 83 84 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 82 def captures payment.captures end |
#expired? ⇒ Boolean
110 111 112 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 110 def expired? @state == :expired end |
#inspect ⇒ Object
90 91 92 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 90 def inspect to_str end |
#partially_captured? ⇒ Boolean
102 103 104 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 102 def partially_captured? @state == :partially_captured end |
#pending? ⇒ Boolean
94 95 96 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 94 def pending? @state == :pending end |
#reload! ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 44 def reload! = self.class.find_raw(@id) extract_and_store() @expanded = true self end |
#reload_payment! ⇒ Object
52 53 54 55 56 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 52 def reload_payment! @payment = ::PaymentRecipes::PayPal::REST::Payment.find(@payment_id) @payment end |
#to_s ⇒ Object
122 123 124 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 122 def to_s to_str end |
#to_str ⇒ Object
126 127 128 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 126 def to_str "<#{ self.class.name } total=#{ @total.format } state=#{ @state } id=#{ @id }>" end |
#voided? ⇒ Boolean
114 115 116 |
# File 'lib/payment_recipes/paypal/rest/authorization.rb', line 114 def voided? @state == :voided end |