Class: WebPay::Charge
- Inherits:
-
ApiResource
- Object
- ApiResource
- WebPay::Charge
- Defined in:
- lib/webpay/charge.rb
Instance Method Summary collapse
-
#all(params = {}) ⇒ ChargeResponseList
List charges filtered by params.
-
#capture(params = {}) ⇒ ChargeResponse
Capture a not captured charge specified by charge id.
-
#create(params = {}) ⇒ ChargeResponse
Create a charge object with given parameters.
-
#refund(params = {}) ⇒ ChargeResponse
Refund a paid charge specified by charge id.
-
#retrieve(params = {}) ⇒ ChargeResponse
Retrieve a existing charge object by charge id.
Methods inherited from ApiResource
Constructor Details
This class inherits a constructor from WebPay::ApiResource
Instance Method Details
#all(params = {}) ⇒ ChargeResponseList
List charges filtered by params.
48 49 50 51 52 |
# File 'lib/webpay/charge.rb', line 48 def all(params = {}) req = WebPay::ChargeListRequest.create(params) raw_response = @client._request(:get, 'charges', req) WebPay::ChargeResponseList.new(raw_response) end |
#capture(params = {}) ⇒ ChargeResponse
Capture a not captured charge specified by charge id.
38 39 40 41 42 |
# File 'lib/webpay/charge.rb', line 38 def capture(params = {}) req = WebPay::ChargeRequestWithAmount.create(params) raw_response = @client._request(:post, 'charges' + '/' + req.id.to_s + '/' + 'capture', req) WebPay::ChargeResponse.new(raw_response) end |
#create(params = {}) ⇒ ChargeResponse
Create a charge object with given parameters. In live mode, this issues a transaction.
7 8 9 10 11 |
# File 'lib/webpay/charge.rb', line 7 def create(params = {}) req = WebPay::ChargeRequestCreate.create(params) raw_response = @client._request(:post, 'charges', req) WebPay::ChargeResponse.new(raw_response) end |
#refund(params = {}) ⇒ ChargeResponse
Refund a paid charge specified by charge id. Optional argument amount is to refund partially.
28 29 30 31 32 |
# File 'lib/webpay/charge.rb', line 28 def refund(params = {}) req = WebPay::ChargeRequestRefund.create(params) raw_response = @client._request(:post, 'charges' + '/' + req.id.to_s + '/' + 'refund', req) WebPay::ChargeResponse.new(raw_response) end |
#retrieve(params = {}) ⇒ ChargeResponse
Retrieve a existing charge object by charge id.
17 18 19 20 21 |
# File 'lib/webpay/charge.rb', line 17 def retrieve(params = {}) req = WebPay::ChargeIdRequest.create(params) raw_response = @client._request(:get, 'charges' + '/' + req.id.to_s, req) WebPay::ChargeResponse.new(raw_response) end |