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



27
28
29
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 27

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

_merchantId__payments__paymentId__approve_post Capture 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 GlobalCollect platform,

the GlobalCollect 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 GlobalCollect platform returned any other error



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

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 = {
    402 => Ingenico::Connect::SDK::Domain::Errors::ErrorResponse,
    404 => Ingenico::Connect::SDK::Domain::Errors::ErrorResponse,
  }.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

#cancel(payment_id, context = nil) ⇒ Object

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

_merchantId__payments__paymentId__cancel_post 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 GlobalCollect platform,

the GlobalCollect 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 GlobalCollect platform returned any other error



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

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 = {
    402 => Ingenico::Connect::SDK::Domain::Errors::ErrorResponse,
  }.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

#cancelapproval(payment_id, context = nil) ⇒ Object

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

_merchantId__payments__paymentId__cancelapproval_post Undo capture payment request

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 GlobalCollect platform,

the GlobalCollect 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 GlobalCollect platform returned any other error



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 187

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 = {
    404 => Ingenico::Connect::SDK::Domain::Errors::ErrorResponse,
  }.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

#create(body, context = nil) ⇒ Object

Resource /{merchantId}/payments

_merchantId__payments_post Create payment

body

Domain::Payment::CreatePaymentRequest

context

CallContext

Returns

Domain::Payment::CreatePaymentResponse

Raises

DeclinedPaymentException if the GlobalCollect 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 GlobalCollect platform,

the GlobalCollect 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 GlobalCollect platform returned any other error



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

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

#get(payment_id, context = nil) ⇒ Object

Resource /{merchantId}/payments/{paymentId}

_merchantId__payments__paymentId__get 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 GlobalCollect platform,

the GlobalCollect 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 GlobalCollect platform returned any other error



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 83

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

_merchantId__payments__paymentId__processchallenged_post 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 GlobalCollect platform,

the GlobalCollect 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 GlobalCollect platform returned any other error



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 222

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 = {
    404 => Ingenico::Connect::SDK::Domain::Errors::ErrorResponse,
    405 => Ingenico::Connect::SDK::Domain::Errors::ErrorResponse,
  }.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

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

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

_merchantId__payments__paymentId__refund_post Create refund

payment_id

String

body

Domain::Refund::RefundRequest

context

CallContext

Returns

Domain::Refund::RefundResponse

Raises

DeclinedRefundException if the GlobalCollect 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 GlobalCollect platform,

the GlobalCollect 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 GlobalCollect platform returned any other error



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 260

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

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

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

_merchantId__payments__paymentId__tokenize_post 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 GlobalCollect platform,

the GlobalCollect 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 GlobalCollect platform returned any other error



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/ingenico/connect/sdk/merchant/payments/payments_client.rb', line 297

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 = {
    404 => Ingenico::Connect::SDK::Domain::Errors::ErrorResponse,
  }.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