Module: Brickwall::API::Charge
- Defined in:
- lib/brickwall/api/charge.rb
Class Method Summary collapse
- .capture(charge_id) ⇒ Object
- .create(params = {}) ⇒ Object
- .get(charge_id) ⇒ Object
- .refund(charge_id) ⇒ Object
- .void(charge_id) ⇒ Object
Class Method Details
.capture(charge_id) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/brickwall/api/charge.rb', line 33 def self.capture(charge_id) response = RestClient.post API.url("charge/#{charge_id}/capture"), {}, { 'X-ApiKey' => Brickwall.configuration.brick_private_key } JSON.parse response end |
.create(params = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/brickwall/api/charge.rb', line 4 def self.create(params = {}) api_params = params if api_params.has_key?('browser_ip') && !api_params.has_key?('browser_domain') api_params = params.clone api_params['browser_domain'] = Brickwall.configuration.application_domain end response = RestClient.post API.url('charge'), api_params, { 'X-ApiKey' => Brickwall.configuration.brick_private_key } JSON.parse response rescue RestClient::Exception => e err = JSON.parse e.response Error.new err['type'], err['error'], err['code'] end |
.get(charge_id) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/brickwall/api/charge.rb', line 19 def self.get(charge_id) response = RestClient.get API.url("charge/#{charge_id}"), { 'X-ApiKey' => Brickwall.configuration.brick_private_key } JSON.parse response end |
.refund(charge_id) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/brickwall/api/charge.rb', line 26 def self.refund(charge_id) response = RestClient.post API.url("charge/#{charge_id}/refund"), {}, { 'X-ApiKey' => Brickwall.configuration.brick_private_key } JSON.parse response end |
.void(charge_id) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/brickwall/api/charge.rb', line 40 def self.void(charge_id) response = RestClient.post API.url("charge/#{charge_id}/void"), {}, { 'X-ApiKey' => Brickwall.configuration.brick_private_key } JSON.parse response end |