Class: Ingenico::Connect::SDK::Merchant::Payments::PaymentsClient

Inherits:
ApiResource
  • Object
show all
Defined in:
lib/ingenico/connect/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) ⇒ PaymentsClient

parent

ApiResource

path_context

Hash of String to String



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

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

Instance Method Details

#approve(payment_id, body, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/approve

Approve payment

payment_id

String

body

Domain::Payment::ApprovePaymentRequest

context

CallContext

Returns

Domain::Payment::PaymentApprovalResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 283

def approve(payment_id, body, context=nil)
  path_context = {
    'paymentId' => payment_id,
  }
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments/{paymentId}/approve', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Connect::SDK::Domain::Payment::PaymentApprovalResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#cancel(payment_id, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/cancel

Cancel payment

payment_id

String

context

CallContext

Returns

Domain::Payment::CancelPaymentResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 453

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

#cancelapproval(payment_id, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/cancelapproval

Undo capture payment

payment_id

String

context

CallContext

Returns

Domain::Payment::CancelApprovalPaymentResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 350

def cancelapproval(payment_id, context=nil)
  path_context = {
    'paymentId' => payment_id,
  }
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments/{paymentId}/cancelapproval', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    nil,
    Ingenico::Connect::SDK::Domain::Payment::CancelApprovalPaymentResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#capture(payment_id, body, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/capture

Capture payment

payment_id

String

body

Domain::Payment::CapturePaymentRequest

context

CallContext

Returns

Domain::Capture::CaptureResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 317

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

#captures(payment_id, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/captures

Get captures of payment

payment_id

String

context

CallContext

Returns

Domain::Capture::CapturesResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 383

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

#complete(payment_id, body, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/complete

Complete payment

payment_id

String

body

Domain::Payment::CompletePaymentRequest

context

CallContext

Returns

Domain::Payment::CompletePaymentResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 150

def complete(payment_id, body, context=nil)
  path_context = {
    'paymentId' => payment_id,
  }
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments/{paymentId}/complete', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Connect::SDK::Domain::Payment::CompletePaymentResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#create(body, context = nil) ⇒ Object

Resource /{merchantId}/payments

Create payment

body

Domain::Payment::CreatePaymentRequest

context

CallContext

Returns

Domain::Payment::CreatePaymentResponse

Raises

DeclinedPaymentException if the Ingenico ePayments platform declined / rejected the payment. The payment result will be available from the exception.

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 52

def create(body, context=nil)
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments', nil)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Connect::SDK::Domain::Payment::CreatePaymentResponse,
    context)
rescue ResponseException => e
  error_type = {
    400 => Ingenico::Connect::SDK::Domain::Payment::PaymentErrorResponse,
    402 => Ingenico::Connect::SDK::Domain::Payment::PaymentErrorResponse,
    403 => Ingenico::Connect::SDK::Domain::Payment::PaymentErrorResponse,
    502 => Ingenico::Connect::SDK::Domain::Payment::PaymentErrorResponse,
    503 => Ingenico::Connect::SDK::Domain::Payment::PaymentErrorResponse,
  }.fetch(e.status_code, Ingenico::Connect::SDK::Domain::Errors::ErrorResponse)
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#find(query, context = nil) ⇒ Object

Resource /{merchantId}/payments

Find payments

query

FindPaymentsParams

context

CallContext

Returns

Domain::Payment::FindPaymentsResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 88

def find(query, context=nil)
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments', nil)
  return @communicator.get(
    uri,
    client_headers,
    query,
    Ingenico::Connect::SDK::Domain::Payment::FindPaymentsResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#get(payment_id, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}

Get payment

payment_id

String

context

CallContext

Returns

Domain::Payment::PaymentResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 117

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

#processchallenged(payment_id, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/processchallenged

Approves challenged payment

payment_id

String

context

CallContext

Returns

Domain::Payment::PaymentResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 249

def processchallenged(payment_id, context=nil)
  path_context = {
    'paymentId' => payment_id,
  }
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments/{paymentId}/processchallenged', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    nil,
    Ingenico::Connect::SDK::Domain::Payment::PaymentResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#refund(payment_id, body, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/refund

Create refund

payment_id

String

body

Domain::Refund::RefundRequest

context

CallContext

Returns

Domain::Refund::RefundResponse

Raises

DeclinedRefundException if the Ingenico ePayments platform declined / rejected the refund. The refund result will be available from the exception.

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 417

def refund(payment_id, body, context=nil)
  path_context = {
    'paymentId' => payment_id,
  }
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments/{paymentId}/refund', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Connect::SDK::Domain::Refund::RefundResponse,
    context)
rescue ResponseException => e
  error_type = {
    400 => Ingenico::Connect::SDK::Domain::Refund::RefundErrorResponse,
    404 => Ingenico::Connect::SDK::Domain::Refund::RefundErrorResponse,
  }.fetch(e.status_code, Ingenico::Connect::SDK::Domain::Errors::ErrorResponse)
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#third_party_status(payment_id, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/thirdpartystatus

Third party status poll

payment_id

String

context

CallContext

Returns

Domain::Payment::ThirdPartyStatusResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 183

def third_party_status(payment_id, context=nil)
  path_context = {
    'paymentId' => payment_id,
  }
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments/{paymentId}/thirdpartystatus', path_context)
  return @communicator.get(
    uri,
    client_headers,
    nil,
    Ingenico::Connect::SDK::Domain::Payment::ThirdPartyStatusResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#tokenize(payment_id, body, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}/tokenize

Create a token from payment

payment_id

String

body

Domain::Payment::TokenizePaymentRequest

context

CallContext

Returns

Domain::Token::CreateTokenResponse

Raises

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

Raises

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

Raises

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

Raises

ReferenceException 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)

Raises

GlobalCollectException if something went wrong at the Ingenico ePayments platform,

the Ingenico ePayments 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)

Raises

ApiException if the Ingenico ePayments platform returned any other error



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 216

def tokenize(payment_id, body, context=nil)
  path_context = {
    'paymentId' => payment_id,
  }
  uri = instantiate_uri('/{apiVersion}/{merchantId}/payments/{paymentId}/tokenize', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    Ingenico::Connect::SDK::Domain::Token::CreateTokenResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end