Class: FatZebra::Purchase
- Inherits:
-
APIResource
- Object
- FatZebraObject
- APIResource
- FatZebra::Purchase
- Defined in:
- lib/fat_zebra/purchase.rb
Overview
FatZebra Purchase
Manage purchase for the API
-
search
-
save
-
find
-
void
-
settlement
-
refund
-
capture
Constant Summary
Constants included from APIOperation::Search
APIOperation::Search::DEFAULT_PARAMS
Instance Attribute Summary
Attributes inherited from FatZebraObject
Attributes included from ObjectHelper
Class Method Summary collapse
-
.create(params, options = {}) ⇒ FatZebra::PaymentPlan
Create a payment plan Default currency to AUD.
-
.settlement(params = {}, options = {}) ⇒ FatZebra::Purchase
Return all the settlements.
Instance Method Summary collapse
-
#capture(params = {}, options = {}) ⇒ Response
Captures an authorization.
-
#refund(params = {}, options = {}) ⇒ FatZebra::Refund
Refunds the current purchase.
Methods included from APIOperation::Void
Methods included from APIOperation::Save
Methods included from APIOperation::Search
Methods included from APIOperation::Find
Methods inherited from APIResource
Methods included from APIHelper
included, #request, #resource_name, #resource_path
Methods inherited from FatZebraObject
initialize_from, #load_response_api, #update_from
Methods included from Validation
#errors, #valid!, #valid?, #validates
Methods included from ObjectHelper
#[], #[]=, #add_accessor, #add_accessors, #add_data, #initialize, #inspect, #keys, #method_missing, #remove_accessor, #to_hash, #to_json, #update_attributes
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FatZebra::ObjectHelper
Class Method Details
.create(params, options = {}) ⇒ FatZebra::PaymentPlan
Create a payment plan Default currency to AUD
42 43 44 45 46 |
# File 'lib/fat_zebra/purchase.rb', line 42 def create(params, = {}) params[:currency] ||= 'AUD' super(params, ) end |
.settlement(params = {}, options = {}) ⇒ FatZebra::Purchase
Return all the settlements
55 56 57 58 59 60 |
# File 'lib/fat_zebra/purchase.rb', line 55 def settlement(params = {}, = {}) valid!(params, :settlement) if respond_to?(:valid!) response = request(:get, "#{resource_path}/settlement", params, ) initialize_from(response) end |
Instance Method Details
#capture(params = {}, options = {}) ⇒ Response
Captures an authorization
86 87 88 89 90 91 92 93 |
# File 'lib/fat_zebra/purchase.rb', line 86 def capture(params = {}, = {}) params = { amount: amount }.merge(params) response = request(:post, resource_path("purchases/#{id}/capture"), params, ) update_from(response) end |
#refund(params = {}, options = {}) ⇒ FatZebra::Refund
Refunds the current purchase
71 72 73 74 75 76 77 |
# File 'lib/fat_zebra/purchase.rb', line 71 def refund(params = {}, = {}) Refund.create({ transaction_id: id, amount: amount, reference: reference }.merge(params), ) end |