Class: Paylike::Transaction

Inherits:
Base show all
Defined in:
lib/paylike.rb

Overview

Transactions endpoint resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

all, extract_error, find, parse_response, uri_sans_merchant_id

Class Method Details

.create(*args) ⇒ Paylike::Transaction

Delegate the resource creation to the gateway, but maintain the rest

Returns:



51
52
53
54
# File 'lib/paylike.rb', line 51

def self.create(*args)
  gw_tran = Gateway::Transaction.create(*args)
  find(gw_tran.id)
end

Instance Method Details

#capture(params) ⇒ NilClass

Capture helper

Parameters:

  • params (Hash)

    the ‘amount` and the `descriptor`.

Returns:

  • (NilClass)


81
82
83
84
85
86
# File 'lib/paylike.rb', line 81

def capture(params)
  captures_uri = self.class.uri_sans_merchant_id(id, :captures)
  data = self.class.request(:post, captures_uri, json: params)
  symbolized = JSON.parse(data.to_json, symbolize_names: true)
  marshal_load(symbolized) if data.is_a?(Hash)
end

#refund(params) ⇒ NilClass

Refunds helper

Parameters:

  • params (Hash)

    the ‘amount` and the `descriptor`.

Returns:

  • (NilClass)


70
71
72
73
74
75
# File 'lib/paylike.rb', line 70

def refund(params)
  refunds_uri = self.class.uri_sans_merchant_id(id, :refunds)
  data = self.class.request(:post, refunds_uri, json: params)
  symbolized = JSON.parse(data.to_json, symbolize_names: true)
  marshal_load(symbolized) if data.is_a?(Hash)
end

#voidNilClass

Refunds helper

Returns:

  • (NilClass)


59
60
61
62
63
64
# File 'lib/paylike.rb', line 59

def void
  voids_uri = self.class.uri_sans_merchant_id(id, :voids)
  data = self.class.request(:post, voids_uri, json: { amount: amount })
  symbolized = JSON.parse(data.to_json, symbolize_names: true)
  marshal_load(symbolized) if data.is_a?(Hash)
end