Class: PaymentRecipes::PayPal::REST::Refund
- Inherits:
-
Object
- Object
- PaymentRecipes::PayPal::REST::Refund
- Includes:
- Utils::Converters, Utils::Equality
- Defined in:
- lib/payment_recipes/paypal/rest/refund.rb
Instance Attribute Summary collapse
-
#capture ⇒ Object
readonly
Returns the value of attribute capture.
-
#capture_id ⇒ Object
readonly
Returns the value of attribute capture_id.
-
#create_time ⇒ Object
readonly
Returns the value of attribute create_time.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#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.
-
#raw_refund ⇒ Object
readonly
Returns the value of attribute raw_refund.
-
#sale ⇒ Object
readonly
Returns the value of attribute sale.
-
#sale_id ⇒ Object
readonly
Returns the value of attribute sale_id.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#update_time ⇒ Object
readonly
Returns the value of attribute update_time.
Class Method Summary collapse
Instance Method Summary collapse
- #authorization ⇒ Object
- #authorizations ⇒ Object
- #completed? ⇒ Boolean
- #extract_and_store(paypal_refund) ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(paypal_refund, payment: nil) ⇒ Refund
constructor
A new instance of Refund.
- #inspect ⇒ Object
- #pending? ⇒ Boolean
- #reload! ⇒ Object
- #reload_capture! ⇒ Object
- #reload_payment! ⇒ Object
- #reload_sale! ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ 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_refund, payment: nil) ⇒ Refund
Returns a new instance of Refund.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 26 def initialize(paypal_refund, payment: nil) unless paypal_refund.is_a?(::PayPal::SDK::REST::DataTypes::Refund) raise Exception, "#{ self.class.name } must be initialized with a PayPal Refund" 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(paypal_refund) end |
Instance Attribute Details
#capture ⇒ Object (readonly)
Returns the value of attribute capture.
19 20 21 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 19 def capture @capture end |
#capture_id ⇒ Object (readonly)
Returns the value of attribute capture_id.
18 19 20 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 18 def capture_id @capture_id end |
#create_time ⇒ Object (readonly)
Returns the value of attribute create_time.
12 13 14 |
# File 'lib/payment_recipes/paypal/rest/refund.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/refund.rb', line 6 def currency @currency end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/payment_recipes/paypal/rest/refund.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/refund.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/refund.rb', line 9 def payment_id @payment_id end |
#raw_refund ⇒ Object (readonly)
Returns the value of attribute raw_refund.
21 22 23 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 21 def raw_refund @raw_refund end |
#sale ⇒ Object (readonly)
Returns the value of attribute sale.
16 17 18 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 16 def sale @sale end |
#sale_id ⇒ Object (readonly)
Returns the value of attribute sale_id.
15 16 17 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 15 def sale_id @sale_id end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
10 11 12 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 10 def state @state end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
7 8 9 |
# File 'lib/payment_recipes/paypal/rest/refund.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/refund.rb', line 13 def update_time @update_time end |
Class Method Details
.find(id) ⇒ Object
123 124 125 126 127 128 129 130 131 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 123 def find(id) paypal_refund = find_raw(id) if paypal_refund new(paypal_refund, payment: nil) else nil end end |
.find_raw(id) ⇒ Object
133 134 135 136 137 138 139 140 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 133 def find_raw(id) begin ::PayPal::SDK::REST::Refund.find(id) rescue ::PayPal::SDK::Core::Exceptions::ResourceNotFound nil end end |
Instance Method Details
#authorization ⇒ Object
94 95 96 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 94 def payment. end |
#authorizations ⇒ Object
90 91 92 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 90 def payment. end |
#completed? ⇒ Boolean
102 103 104 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 102 def completed? @state == :completed end |
#extract_and_store(paypal_refund) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 143 def extract_and_store(paypal_refund) @id = convert_to_string(paypal_refund.id) @currency = convert_to_string(paypal_refund.amount.currency) @total = convert_to_money(amount: paypal_refund.amount.total, currency: paypal_refund.amount.currency) @payment_id = convert_to_string(paypal_refund.parent_payment) @state = convert_to_symbol(paypal_refund.state) @create_time = convert_to_time(paypal_refund.create_time) @update_time = convert_to_time(paypal_refund.update_time) @sale_id = convert_to_string(paypal_refund.sale_id) @capture_id = convert_to_string(paypal_refund.capture_id) @raw_refund = paypal_refund end |
#failed? ⇒ Boolean
106 107 108 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 106 def failed? @state == :failed end |
#inspect ⇒ Object
110 111 112 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 110 def inspect to_str end |
#pending? ⇒ Boolean
98 99 100 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 98 def pending? @state == :pending end |
#reload! ⇒ Object
43 44 45 46 47 48 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 43 def reload! paypal_refund = self.class.find_raw(@id) extract_and_store(paypal_refund) self end |
#reload_capture! ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 64 def reload_capture! return unless @capture_id @capture = ::PaymentRecipes::PayPal::REST::Capture.find(@capture_id) @capture end |
#reload_payment! ⇒ Object
50 51 52 53 54 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 50 def reload_payment! @payment = ::PaymentRecipes::PayPal::REST::Payment.find(@payment_id) @payment end |
#reload_sale! ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 56 def reload_sale! return unless @sale_id @sale = ::PaymentRecipes::PayPal::REST::Sale.find(@sale_id) @sale end |
#to_s ⇒ Object
114 115 116 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 114 def to_s to_str end |
#to_str ⇒ Object
118 119 120 |
# File 'lib/payment_recipes/paypal/rest/refund.rb', line 118 def to_str "<#{ self.class.name } total=#{ @total.format } state=#{ @state } id=#{ @id }>" end |