Class: OnlinePayments::SDK::Merchant::Refunds::RefundsClient

Inherits:
ApiResource
  • Object
show all
Defined in:
lib/onlinepayments/sdk/merchant/refunds/refunds_client.rb

Overview

Refunds client. Thread-safe.

Instance Attribute Summary

Attributes inherited from ApiResource

#client_meta_info, #communicator

Instance Method Summary collapse

Constructor Details

#initialize(parent, path_context) ⇒ RefundsClient

Returns a new instance of RefundsClient.

Parameters:



19
20
21
# File 'lib/onlinepayments/sdk/merchant/refunds/refunds_client.rb', line 19

def initialize(parent, path_context)
  super(parent: parent, path_context: path_context)
end

Instance Method Details

#get_refunds(payment_id, context = nil) ⇒ OnlinePayments::SDK::Domain::RefundsResponse

Resource /v2/{merchantId}/payments/{paymentId}/refunds - Get refunds of payment

Parameters:

  • (defaults to: nil)

Returns:

Raises:

  • if an idempotent request caused a conflict (HTTP status code 409)

  • if the request was not correct and couldn't be processed (HTTP status code 400)

  • if the request was not allowed (HTTP status code 403)

  • if an object was attempted to be referenced that doesn't exist or has been removed, or there was a conflict (HTTP status code 404, 409 or 410)

  • if something went wrong at the payment platform, the payment platform was unable to process a message from a downstream partner/acquirer, or the service that you're trying to reach is temporary unavailable (HTTP status code 500, 502 or 503)

  • if the payment platform returned any other error



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/onlinepayments/sdk/merchant/refunds/refunds_client.rb', line 37

def get_refunds(payment_id, context = nil)
  path_context = {
    'paymentId'.freeze => payment_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payments/{paymentId}/refunds', path_context)


  @communicator.get(
    uri,
    client_headers,
    nil,
    OnlinePayments::SDK::Domain::RefundsResponse,
    context)
rescue OnlinePayments::SDK::Communication::ResponseException => e
  error_type = OnlinePayments::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise OnlinePayments::SDK.create_exception(e.status_code, e.body, error_object, context)
end