Class: Spree::Gateway::BraintreeVzeroBase::Transaction
- Inherits:
-
Object
- Object
- Spree::Gateway::BraintreeVzeroBase::Transaction
- Defined in:
- app/models/spree/gateway/braintree_vzero_base/transaction.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(provider, transaction_id = nil) ⇒ Transaction
constructor
A new instance of Transaction.
- #refund(cents) ⇒ Object
- #sale(data) ⇒ Object
- #status ⇒ Object
- #submit_for_settlement(amount) ⇒ Object
- #void ⇒ Object
Constructor Details
#initialize(provider, transaction_id = nil) ⇒ Transaction
Returns a new instance of Transaction.
7 8 9 10 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 7 def initialize(provider, transaction_id = nil) @transaction_id = transaction_id @request = provider::Transaction end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
5 6 7 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 5 def request @request end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
5 6 7 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 5 def transaction_id @transaction_id end |
Instance Method Details
#clone ⇒ Object
16 17 18 19 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 16 def clone t = @request.find(transaction_id) sale(payment_method_token: t.credit_card_details.token, amount: t.amount, options: { submit_for_settlement: true }) end |
#refund(cents) ⇒ Object
33 34 35 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 33 def refund(cents) @request.refund(transaction_id, cents) end |
#sale(data) ⇒ Object
21 22 23 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 21 def sale(data) @request.sale(data) end |
#status ⇒ Object
25 26 27 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 25 def status @request.find(transaction_id).status end |
#submit_for_settlement(amount) ⇒ Object
12 13 14 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 12 def submit_for_settlement(amount) @request.submit_for_settlement(transaction_id, amount) end |
#void ⇒ Object
29 30 31 |
# File 'app/models/spree/gateway/braintree_vzero_base/transaction.rb', line 29 def void @request.void(transaction_id) end |