Class: Ingenico::Direct::SDK::Merchant::Payments::PaymentsClient

Inherits:
ApiResource
  • Object
show all
Defined in:
lib/ingenico/direct/sdk/merchant/payments/payments_client.rb

Overview

Payments client. Thread-safe.

Instance Attribute Summary

Attributes inherited from ApiResource

#client_meta_info, #communicator

Instance Method Summary collapse

Constructor Details

#initialize(parent, path_context = nil) ⇒ PaymentsClient

Returns a new instance of PaymentsClient.

Parameters:



33
34
35
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 33

def initialize(parent, path_context = nil)
  super(parent, path_context)
end

Instance Method Details

#cancel_payment(payment_id, context = nil) ⇒ Ingenico::Direct::SDK::Domain::CancelPaymentResponse

Resource /v2/{merchantId}/payments/{paymentId}/cancel - Cancel payment

Parameters:

Returns:

Raises:



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 143

def cancel_payment(payment_id, context = nil)
  path_context = {
    'paymentId'.freeze => payment_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payments/{paymentId}/cancel', path_context)
  @communicator.post(
    uri,
    client_headers,
    nil,
    nil,
    Ingenico::Direct::SDK::Domain::CancelPaymentResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#capture_payment(payment_id, body, context = nil) ⇒ Ingenico::Direct::SDK::Domain::CaptureResponse

Resource /v2/{merchantId}/payments/{paymentId}/capture - Capture payment

Parameters:

Returns:

Raises:



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 209

def capture_payment(payment_id, body, context = nil)
  path_context = {
    'paymentId'.freeze => payment_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payments/{paymentId}/capture', path_context)
  @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Direct::SDK::Domain::CaptureResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#complete_payment(payment_id, body, context = nil) ⇒ Ingenico::Direct::SDK::Domain::CompletePaymentResponse

Resource /v2/{merchantId}/payments/{paymentId}/complete - Complete payment

Parameters:

Returns:

Raises:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 111

def complete_payment(payment_id, body, context = nil)
  path_context = {
    'paymentId'.freeze => payment_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payments/{paymentId}/complete', path_context)
  @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Direct::SDK::Domain::CompletePaymentResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::PaymentErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#create_payment(body, context = nil) ⇒ Ingenico::Direct::SDK::Domain::CreatePaymentResponse

Resource /v2/{merchantId}/payments - Create payment

Parameters:

Returns:

Raises:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 50

def create_payment(body, context = nil)
  uri = instantiate_uri('/v2/{merchantId}/payments')
  @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Direct::SDK::Domain::CreatePaymentResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::PaymentErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#get_captures(payment_id, context = nil) ⇒ Ingenico::Direct::SDK::Domain::CapturesResponse

Resource /v2/{merchantId}/payments/{paymentId}/captures - Get Captures Api

Parameters:

Returns:

Raises:



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 241

def get_captures(payment_id, context = nil)
  path_context = {
    'paymentId'.freeze => payment_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payments/{paymentId}/captures', path_context)
  @communicator.get(
    uri,
    client_headers,
    nil,
    Ingenico::Direct::SDK::Domain::CapturesResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#get_payment(payment_id, context = nil) ⇒ Ingenico::Direct::SDK::Domain::PaymentResponse

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

Parameters:

Returns:

Raises:



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 79

def get_payment(payment_id, context = nil)
  path_context = {
    'paymentId'.freeze => payment_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payments/{paymentId}', path_context)
  @communicator.get(
    uri,
    client_headers,
    nil,
    Ingenico::Direct::SDK::Domain::PaymentResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#get_payment_details(payment_id, context = nil) ⇒ Ingenico::Direct::SDK::Domain::PaymentDetailsResponse

Resource /v2/{merchantId}/payments/{paymentId}/details - Get payment details

Parameters:

Returns:

Raises:



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 272

def get_payment_details(payment_id, context = nil)
  path_context = {
    'paymentId'.freeze => payment_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payments/{paymentId}/details', path_context)
  @communicator.get(
    uri,
    client_headers,
    nil,
    Ingenico::Direct::SDK::Domain::PaymentDetailsResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

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

Resource /v2/{merchantId}/payments/{paymentId}/refunds - Get Refunds Api

Parameters:

Returns:

Raises:



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 303

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,
    Ingenico::Direct::SDK::Domain::RefundsResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#refund_payment(payment_id, body, context = nil) ⇒ Ingenico::Direct::SDK::Domain::RefundResponse

Resource /v2/{merchantId}/payments/{paymentId}/refund - Refund payment

Parameters:

Returns:

Raises:



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/ingenico/direct/sdk/merchant/payments/payments_client.rb', line 176

def refund_payment(payment_id, body, context = nil)
  path_context = {
    'paymentId'.freeze => payment_id,
  }
  uri = instantiate_uri('/v2/{merchantId}/payments/{paymentId}/refund', path_context)
  @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Direct::SDK::Domain::RefundResponse,
    context
  )
rescue ResponseException => e
  error_type = Ingenico::Direct::SDK::Domain::RefundErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end