Class: PinPays::Charges

Inherits:
Api
  • Object
show all
Defined in:
lib/pin_pays/charges.rb

Constant Summary collapse

PATH =
'/charges'

Constants inherited from Api

Api::LIVE_URI, Api::TEST_URI

Class Method Summary collapse

Methods inherited from Api

setup

Class Method Details

.capture(charge_token) ⇒ Object

Captures a previously authorized charge



17
18
19
# File 'lib/pin_pays/charges.rb', line 17

def capture(charge_token)
  api_response(api_put("#{PATH}/#{charge_token}/capture"))
end

.create(options) ⇒ Object

Create a charge for a customer or card Options (hash) containing:

(mandatory)         email, description, amount, and remote_ip
(mandatory, one of) customer_token, card_token, or card (a hash of card details)
(optional)          currency, capture


12
13
14
# File 'lib/pin_pays/charges.rb', line 12

def create(options)
  api_response(api_post(PATH, options))
end

.list(page = nil) ⇒ Object

Lists all charges Page - the page number to return (optional)



23
24
25
26
# File 'lib/pin_pays/charges.rb', line 23

def list(page = nil)
  options = (page.nil? ? nil : { page: page })
  api_paginated_response(api_get(PATH, options))
end

.search(criteria) ⇒ Object

Search for charges that match one or more criteria Criteria - a hash of search criteria



30
31
32
# File 'lib/pin_pays/charges.rb', line 30

def search(criteria)
  api_paginated_response(api_get("#{PATH}/search", criteria))
end

.show(charge_token) ⇒ Object

Retrieve details of a specific charge



35
36
37
# File 'lib/pin_pays/charges.rb', line 35

def show(charge_token)
  api_response(api_get("#{PATH}/#{charge_token}"))
end