Module: Simpal::API::Payments::Authorizations

Defined in:
lib/simpal/api/payments/authorizations.rb

Overview

Class Method Summary collapse

Class Method Details

.capture(id, params = {}, headers: {}, client: nil) ⇒ Hash

Capture an authorized payment.

Parameters:

  • id (String)

    The ID of an authorized payment.

  • params (Hash) (defaults to: {})

    The parameters for the capture request.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Hash)

    A Hash representing the captured payment.



32
33
34
35
36
# File 'lib/simpal/api/payments/authorizations.rb', line 32

def self.capture(id, params = {}, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post("/v2/payments/authorizations/#{id}/capture", params, headers)
  response.body
end

.reauthorize(id, params = {}, headers: {}, client: nil) ⇒ Hash

Reauthorize an authorized payment.

Parameters:

  • id (String)

    The ID of an authorized payment.

  • params (Hash) (defaults to: {})

    The parameters for the reauthorize request.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Hash)

    A Hash representing the reauthorized payment.



46
47
48
49
50
# File 'lib/simpal/api/payments/authorizations.rb', line 46

def self.reauthorize(id, params = {}, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post("/v2/payments/authorizations/#{id}/reauthorize", params, headers)
  response.body
end

.retrieve(id, headers: {}, client: nil) ⇒ Hash

Retrieve an authorized payment.

Parameters:

  • id (String)

    The ID of an authorized payment.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Hash)

    A Hash representing the authorized payment.



18
19
20
21
22
# File 'lib/simpal/api/payments/authorizations.rb', line 18

def self.retrieve(id, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.get("/v2/payments/authorizations/#{id}", headers)
  response.body
end

.void(id, headers: {}, client: nil) ⇒ Boolean

Void an authorized payment.

Parameters:

  • id (String)

    The ID of an authorized payment.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Boolean)

    ‘true` when the authorization has been voided, `false` otherwise.



59
60
61
62
63
# File 'lib/simpal/api/payments/authorizations.rb', line 59

def self.void(id, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post("/v2/payments/authorizations/#{id}/void", nil, headers)
  response.success?
end