Module: Simpal::Order

Defined in:
lib/simpal/order.rb

Overview

See Also:

Class Method Summary collapse

Class Method Details

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

Authorize the payment for an order.

Parameters:

  • id (String)

    The ID of an existing order.

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

    The parameters for the authorize 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 order.

See Also:



56
57
58
59
# File 'lib/simpal/order.rb', line 56

def self.authorize(id, params = {}, headers: {}, client: nil)
  resource = API::Orders.authorize(id, params, headers: headers, client: client)
  PayPalObject.new(resource)
end

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

Capture the payment for an order.

Parameters:

  • id (String)

    The ID of an existing order.

  • 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 order.

See Also:



70
71
72
73
# File 'lib/simpal/order.rb', line 70

def self.capture(id, params = {}, headers: {}, client: nil)
  resource = API::Orders.capture(id, params, headers: headers, client: client)
  PayPalObject.new(resource)
end

.create(params = {}, headers: {}, client: nil) ⇒ Simpal::PayPalObject

Create an order.

Parameters:

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

    The parameters for the create 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:

See Also:



15
16
17
18
# File 'lib/simpal/order.rb', line 15

def self.create(params = {}, headers: {}, client: nil)
  resource = API::Orders.create(params, headers: headers, client: client)
  PayPalObject.new(resource)
end

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

Retrieve an order.

Parameters:

  • id (String)

    The ID of an existing order.

  • 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 order.

See Also:



42
43
44
45
# File 'lib/simpal/order.rb', line 42

def self.retrieve(id, headers: {}, client: nil)
  resource = API::Orders.retrieve(id, headers: headers, client: client)
  PayPalObject.new(resource)
end

.update(id, params = [], headers: {}, client: nil) ⇒ Boolean

Update an order.

Parameters:

  • id (String)

    The ID of an existing order.

  • params (Array<Hash>) (defaults to: [])

    The collection of patches to apply to the order.

  • 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` if the order was updated, else an exception is raised.

See Also:



29
30
31
32
# File 'lib/simpal/order.rb', line 29

def self.update(id, params = [], headers: {}, client: nil)
  API::Orders.update(id, params, headers: headers, client: client)
  true
end