Class: OnlinePayments::SDK::Merchant::Payouts::PayoutsClient

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

Overview

Payouts client. Thread-safe.

Instance Attribute Summary

Attributes inherited from ApiResource

#client_meta_info, #communicator

Instance Method Summary collapse

Constructor Details

#initialize(parent, path_context) ⇒ PayoutsClient

Returns a new instance of PayoutsClient.

Parameters:



20
21
22
# File 'lib/onlinepayments/sdk/merchant/payouts/payouts_client.rb', line 20

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

Instance Method Details

#create_payout(body, context = nil) ⇒ OnlinePayments::SDK::Domain::PayoutResponse

Resource /v2/{merchantId}/payouts - Create payout

Parameters:

  • (defaults to: nil)

Returns:

Raises:

  • if the payment platform declined / rejected the payout. The payout result will be available from the exception.

  • 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



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

def create_payout(body, context = nil)
  uri = instantiate_uri('/v2/{merchantId}/payouts', nil)


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

#get_payout(payout_id, context = nil) ⇒ OnlinePayments::SDK::Domain::PayoutResponse

Resource /v2/{merchantId}/payouts/{payoutId} - Get payout

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



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/onlinepayments/sdk/merchant/payouts/payouts_client.rb', line 70

def get_payout(payout_id, context = nil)
  path_context = {
    'payoutId'.freeze => payout_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payouts/{payoutId}', path_context)


  @communicator.get(
    uri,
    client_headers,
    nil,
    OnlinePayments::SDK::Domain::PayoutResponse,
    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