class Pin::Charges
This class models Pin's Charges
API
Public Class Methods
Lists all of the charges for your account args: page (Fixnum), pagination (Boolean) returns: a collection of charge objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
pinpayments.com/docs/api/charges#get-charges
# File lib/pin_up/charge.rb, line 14 def self.all(page = nil, pagination = false) build_collection_response(make_request(:get, { url: "charges?page=#{page}" }), pagination) end
Captures a previously authorised charge and returns its details. args: charge-token (String) returns: charge object pinpayments.com/docs/api/charges#put-charges
# File lib/pin_up/charge.rb, line 58 def self.capture(token) build_response(make_request(:put, { url: "charges/#{token}/capture" } )) end
Create a charge given charge details and a card, a card_token or a customer_token args: options (Hash) returns: a charge object pinpayments.com/docs/api/charges#post-charges
# File lib/pin_up/charge.rb, line 50 def self.create(options = {}) build_response(make_request(:post, {url: 'charges', options: options} )) end
Find a charge for your account given a token args: token (String) returns: a charge object pinpayments.com/docs/api/charges#get-charge
# File lib/pin_up/charge.rb, line 23 def self.find(token) build_response(make_request(:get, {url: "charges/#{token}" } )) end
Find a charge(s) for your account given a search term or set of terms args: options (Hash) returns: a collection of charge objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
pinpayments.com/docs/api/charges#search-charges
# File lib/pin_up/charge.rb, line 35 def self.search(page = nil, pagination = false, **options) term = '' options.merge! page: page if page options.each do |key, option| term += "#{key.to_s}=#{URI.encode(option.to_s)}&" end build_collection_response(make_request(:get, {url: "charges/search?#{term}" } ), pagination) end