Class: Payabli::MoneyIn::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/payabli/money_in/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/payabli/money_in/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#authorize(request_options: {}, **params) ⇒ Payabli::Types::AuthResponse

This endpoint is deprecated. New integrations should use the [Authorize endpoint](/developers/api-reference/moneyinV2/authorize-a-transaction), then capture, void, or refund the resulting transaction with the corresponding endpoints. Transactions created with this legacy endpoint must be managed with the legacy lifecycle endpoints — they aren't interchangeable with the current ones.

Authorize a card transaction. This returns an authorization code and reserves funds for the merchant. Authorized transactions aren't flagged for settlement until captured.

Only card transactions can be authorized. This endpoint can't be used for ACH transactions.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :force_customer_creation (Boolean, nil)
  • :idempotency_key (String, nil)

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/payabli/money_in/client.rb', line 38

def authorize(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[force_customer_creation]
  query_params = {}
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
  params = params.except(*query_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/authorize",
    headers: headers,
    query: query_params,
    body: Payabli::Types::TransRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::AuthResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#authorizev_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Authorize a card transaction. This returns an authorization code and reserves funds for the merchant. Authorized transactions aren't flagged for settlement until captured. This is the v2 version of the api/MoneyIn/authorize endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

Note: Only card transactions can be authorized. This endpoint can't be used for ACH transactions.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :force_customer_creation (Boolean, nil)
  • :idempotency_key (String, nil)

Returns:



681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'lib/payabli/money_in/client.rb', line 681

def authorizev_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[force_customer_creation]
  query_params = {}
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
  params = params.except(*query_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/authorize",
    headers: headers,
    query: query_params,
    body: Payabli::Types::TransRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#capture(request_options: {}, **params) ⇒ Payabli::Types::CaptureResponse

This endpoint is deprecated. Use [POST `/capture/transId`](/developers/api-reference/moneyin/capture-an-authorized-transaction) instead, which supports partial captures and service fee adjustments.
Capture an [authorized

transaction](/developers/api-reference/moneyin/authorize-a-transaction) to complete the transaction and move funds from the customer to merchant account.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :amount (Integer)

Returns:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/payabli/money_in/client.rb', line 92

def capture(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/capture/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::CaptureResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#capture_auth(request_options: {}, **params) ⇒ Payabli::Types::CaptureResponse

This endpoint is deprecated. Use it only to capture transactions originally authorized with the legacy [Authorize endpoint](/developers/api-reference/moneyin/authorize-a-transaction). New integrations should use the [Capture endpoint](/developers/api-reference/moneyinV2/capture-an-authorized-transaction), which only works on transactions authorized with the current [Authorize endpoint](/developers/api-reference/moneyinV2/authorize-a-transaction).

Capture an authorized transaction to complete the transaction and move funds from the customer to merchant account.

You can use this endpoint to capture both full and partial amounts of the original authorized transaction. See Capture an authorized transaction for more information about this endpoint.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/payabli/money_in/client.rb', line 139

def capture_auth(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/capture/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    body: Payabli::Types::CaptureRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::CaptureResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#capturev_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Capture an authorized transaction to complete the transaction and move funds from the customer to merchant account. This is the v2 version of the api/MoneyIn/capture/{transId} endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
# File 'lib/payabli/money_in/client.rb', line 729

def capturev_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/capture/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    body: Payabli::Types::CaptureRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#credit(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse0

Make a temporary microdeposit in a customer account to verify the customer's ownership and access to the target account. Reverse the microdeposit with reverseCredit. Payabli doesn't automatically make microdeposits when you add a bank account, you must manually make the requests.

This feature must be enabled by Payabli on a per-merchant basis. Contact support for help.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :force_customer_creation (Boolean, nil)
  • :idempotency_key (String, nil)

Returns:



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/payabli/money_in/client.rb', line 179

def credit(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::MoneyIn::Types::RequestCredit.new(params).to_h
  non_body_param_names = %w[forceCustomerCreation idempotencyKey]
  body = request_data.except(*non_body_param_names)

  query_params = {}
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/makecredit",
    headers: headers,
    query: query_params,
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliApiResponse0.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#details(request_options: {}, **params) ⇒ Payabli::Types::TransactionQueryRecordsCustomer

Retrieve a processed transaction's details.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/payabli/money_in/client.rb', line 226

def details(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/details/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::TransactionQueryRecordsCustomer.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#getpaid(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseGetPaid

This endpoint is deprecated. New integrations should use the [Make a transaction endpoint](/developers/api-reference/moneyinV2/make-a-transaction) and manage the resulting transaction with the corresponding void or refund endpoints. Transactions created with this legacy endpoint must be managed with the legacy lifecycle endpoints — they aren't interchangeable with the current ones.

Make a single transaction. This method authorizes and captures a payment in one step.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :ach_validation (Boolean, nil)
  • :force_customer_creation (Boolean, nil)
  • :include_details (Boolean, nil)
  • :idempotency_key (String, nil)
  • :validation_code (String, nil)

Returns:



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/payabli/money_in/client.rb', line 271

def getpaid(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[ach_validation force_customer_creation include_details]
  query_params = {}
  query_params["achValidation"] = params[:ach_validation] if params.key?(:ach_validation)
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
  query_params["includeDetails"] = params[:include_details] if params.key?(:include_details)
  params = params.except(*query_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]
  headers["validationCode"] = params[:validation_code] if params[:validation_code]

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/getpaid",
    headers: headers,
    query: query_params,
    body: Payabli::Types::TransRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliApiResponseGetPaid.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#getpaidv_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Make a single transaction. This method authorizes and captures a payment in one step. This is the v2 version of the api/MoneyIn/getpaid endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :ach_validation (Boolean, nil)
  • :force_customer_creation (Boolean, nil)
  • :idempotency_key (String, nil)
  • :validation_code (String, nil)

Returns:



628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
# File 'lib/payabli/money_in/client.rb', line 628

def getpaidv_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[ach_validation force_customer_creation]
  query_params = {}
  query_params["achValidation"] = params[:ach_validation] if params.key?(:ach_validation)
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
  params = params.except(*query_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]
  headers["validationCode"] = params[:validation_code] if params[:validation_code]

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/getpaid",
    headers: headers,
    query: query_params,
    body: Payabli::Types::TransRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#refund(request_options: {}, **params) ⇒ Payabli::Types::RefundResponse

This endpoint is deprecated. Use it only to refund transactions originally created with the legacy endpoints. New integrations should use the [Refund endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction), which only works on transactions created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction).

Refund a transaction that has settled and send money back to the account holder. If a transaction hasn't been settled, void it instead.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :amount (Integer)

Returns:



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/payabli/money_in/client.rb', line 377

def refund(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::RefundResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#refund_with_instructions(request_options: {}, **params) ⇒ Payabli::Types::RefundWithInstructionsResponse

This endpoint is deprecated. Use it only to refund transactions originally created with the legacy endpoints. To refund a split-funded transaction created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction), use the [Refund endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction) with split instructions in the request body.

Refunds a settled transaction with split instructions.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :idempotency_key (String, nil)

Returns:



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/payabli/money_in/client.rb', line 421

def refund_with_instructions(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::MoneyIn::Types::RequestRefund.new(params).to_h
  non_body_param_names = %w[transId idempotencyKey]
  body = request_data.except(*non_body_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::RefundWithInstructionsResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#refundv_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Give a full refund for a transaction that has settled and send money back to the account holder. To perform a partial refund, see Partially refund a transaction.

This is the v2 version of the refund endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

To refund a split-funded transaction, include split instructions in the request body. Omit the body for a standard refund.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# File 'lib/payabli/money_in/client.rb', line 774

def refundv_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    body: Payabli::Types::RefundV2Request.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#refundv_2_amount(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Refund a transaction that has settled and send money back to the account holder. If amount is set to 0, performs a full refund. When a non-zero amount is provided, this endpoint performs a partial refund.

This is the v2 version of the refund endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

To refund a split-funded transaction, include split instructions in the request body. Omit the body for a standard refund.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :amount (Integer)

Returns:



819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
# File 'lib/payabli/money_in/client.rb', line 819

def refundv_2_amount(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
    body: Payabli::Types::RefundV2Request.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#reverse(request_options: {}, **params) ⇒ Payabli::Types::ReverseResponse

This endpoint is deprecated and only works on transactions created with the legacy endpoints. There's no equivalent in the current endpoints. For transactions created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction), check the transaction's settlement status and call [Void](/developers/api-reference/moneyinV2/void-a-transaction) or [Refund](/developers/api-reference/moneyinV2/refund-a-settled-transaction) based on the result.

A reversal either refunds or voids a transaction independent of the transaction's settlement status. Send a reversal request for a transaction, and Payabli automatically determines whether it's a refund or void. You don't need to know whether the transaction is settled or not. This endpoint only works on transactions made with the legacy endpoints. For transactions made with the current endpoints, check the transaction's settlement status and call void or refund based on the result.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :amount (Integer)

Returns:



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/payabli/money_in/client.rb', line 333

def reverse(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/reverse/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::ReverseResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#reverse_credit(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse

Reverse microdeposits that are used to verify customer account ownership and access. The transId value is returned in the success response for the original credit transaction made with api/MoneyIn/makecredit.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/payabli/money_in/client.rb', line 465

def reverse_credit(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/reverseCredit/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliApiResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#send_receipt_2_trans(request_options: {}, **params) ⇒ Payabli::Types::ReceiptResponse

Send a payment receipt for a transaction.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :email (String, nil)

Returns:



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/payabli/money_in/client.rb', line 500

def send_receipt_2_trans(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["email"] = params[:email] if params.key?(:email)

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/sendreceipt/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::ReceiptResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#validate(request_options: {}, **params) ⇒ Payabli::Types::ValidateResponse

Validates a card number without running a transaction or authorizing a charge.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :idempotency_key (String, nil)

Returns:



538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
# File 'lib/payabli/money_in/client.rb', line 538

def validate(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::MoneyIn::Types::RequestPaymentValidate.new(params).to_h
  non_body_param_names = %w[idempotencyKey]
  body = request_data.except(*non_body_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/validate",
    headers: headers,
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::ValidateResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#void(request_options: {}, **params) ⇒ Payabli::Types::VoidResponse

This endpoint is deprecated. Use it only to void transactions originally created with the legacy endpoints. New integrations should use the [Void endpoint](/developers/api-reference/moneyinV2/void-a-transaction), which only works on transactions created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction).

Cancel a transaction that hasn't been settled yet. Voiding non-captured authorizations prevents future captures. If a transaction has been settled, refund it instead.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'lib/payabli/money_in/client.rb', line 589

def void(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/void/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::VoidResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#voidv_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Cancel a transaction that hasn't been settled yet. Voiding non-captured authorizations prevents future captures. This is the v2 version of the api/MoneyIn/void/{transId} endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
# File 'lib/payabli/money_in/client.rb', line 857

def voidv_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/void/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end