Class: Payabli::PaymentLink::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



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

def initialize(client:)
  @client = client
end

Instance Method Details

Generates a payment link for a bill from the bill ID. The vendor receives a secure page where they can select their preferred payment method (ACH, virtual card, or check) and complete the payment.

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

  • :bill_id (Integer)
  • :amount_fixed (Boolean, nil)
  • :mail_2 (String, nil)
  • :idempotency_key (String, nil)

Returns:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/payabli/payment_link/client.rb', line 80

def add_pay_link_from_bill(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[bill_id]
  body_params = params.except(*path_param_names)

  query_param_names = %i[amount_fixed mail_2]
  query_params = {}
  query_params["amountFixed"] = params[:amount_fixed] if params.key?(:amount_fixed)
  query_params["mail2"] = params[:mail_2] if params.key?(:mail_2)
  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: "PaymentLink/bill/#{URI.encode_uri_component(params[:bill_id].to_s)}",
    headers: headers,
    query: query_params,
    body: Payabli::Types::PaymentPageRequestBodyOut.new(body_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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Generates a vendor payment link for a specific bill lot number. This allows you to pay all bills with the same lot number for a vendor with a single payment link.

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

  • :lot_number (String)
  • :entry_point (Payabli::Types::Entry)
  • :vendor_number (String)
  • :mail_2 (String, nil)
  • :amount_fixed (String, nil)

Returns:



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/payabli/payment_link/client.rb', line 356

def add_pay_link_from_bill_lot_number(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[lot_number]
  body_params = params.except(*path_param_names)

  query_param_names = %i[entry_point vendor_number mail_2 amount_fixed]
  query_params = {}
  query_params["entryPoint"] = params[:entry_point] if params.key?(:entry_point)
  query_params["vendorNumber"] = params[:vendor_number] if params.key?(:vendor_number)
  query_params["mail2"] = params[:mail_2] if params.key?(:mail_2)
  query_params["amountFixed"] = params[:amount_fixed] if params.key?(:amount_fixed)
  params = params.except(*query_param_names)

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "PaymentLink/bill/lotNumber/#{URI.encode_uri_component(params[:lot_number].to_s)}",
    query: query_params,
    body: Payabli::Types::PaymentPageRequestBodyOut.new(body_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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Generates a payment link for an invoice from the invoice ID.

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

  • :id_invoice (Integer)
  • :amount_fixed (Boolean, nil)
  • :mail_2 (String, nil)
  • :idempotency_key (String, nil)

Returns:



28
29
30
31
32
33
34
35
36
37
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
# File 'lib/payabli/payment_link/client.rb', line 28

def add_pay_link_from_invoice(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::PaymentLink::Types::PayLinkDataInvoice.new(params).to_h
  non_body_param_names = %w[idInvoice amountFixed mail2 idempotencyKey]
  body = request_data.except(*non_body_param_names)

  query_params = {}
  query_params["amountFixed"] = params[:amount_fixed] if params.key?(:amount_fixed)
  query_params["mail2"] = params[:mail_2] if params.key?(:mail_2)

  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: "PaymentLink/#{URI.encode_uri_component(params[:id_invoice].to_s)}",
    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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Deletes a payment link by ID.

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

  • :pay_link_id (String)

Returns:



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/payabli/payment_link/client.rb', line 129

def delete_pay_link_from_id(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "PaymentLink/#{URI.encode_uri_component(params[:pay_link_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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Retrieves a payment link by ID.

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

  • :paylink_id (String)

Returns:



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/payabli/payment_link/client.rb', line 163

def get_pay_link_from_id(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: "PaymentLink/load/#{URI.encode_uri_component(params[:paylink_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::GetPayLinkFromIdResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Partially updates a Pay Out payment link’s content, expiration date, and/or status. Use this to modify the payment page configuration, extend or change the expiration, or cancel a link. Updating the expiration date of an expired link reactivates it to Active status.

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

  • :paylink_id (String)

Returns:



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/payabli/payment_link/client.rb', line 405

def patch_out_payment_link(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::PaymentLink::Types::PatchOutPaymentLinkRequest.new(params).to_h
  non_body_param_names = %w[paylinkId]
  body = request_data.except(*non_body_param_names)

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PATCH",
    path: "PaymentLink/out/#{URI.encode_uri_component(params[:paylink_id].to_s)}",
    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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Send a payment link to the specified email addresses or phone numbers.

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

  • :pay_link_id (String)

Returns:



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/payabli/payment_link/client.rb', line 197

def push_pay_link_from_id(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: "PaymentLink/push/#{URI.encode_uri_component(params[:pay_link_id].to_s)}",
    body: Payabli::Types::PushPayLinkRequest.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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Refresh a payment link’s content after an update.

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

  • :pay_link_id (String)
  • :amount_fixed (Boolean, nil)

Returns:



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/payabli/payment_link/client.rb', line 233

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

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "PaymentLink/refresh/#{URI.encode_uri_component(params[:pay_link_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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Sends a payment link to the specified email addresses.

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

  • :pay_link_id (String)
  • :attachfile (Boolean, nil)
  • :mail_2 (String, nil)

Returns:



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
# File 'lib/payabli/payment_link/client.rb', line 273

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

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "PaymentLink/send/#{URI.encode_uri_component(params[:pay_link_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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Updates a payment link’s details.

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

  • :pay_link_id (String)

Returns:



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/payabli/payment_link/client.rb', line 312

def update_pay_link_from_id(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::PaymentLink::Types::PayLinkUpdateData.new(params).to_h
  non_body_param_names = %w[payLinkId]
  body = request_data.except(*non_body_param_names)

  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "PaymentLink/update/#{URI.encode_uri_component(params[:pay_link_id].to_s)}",
    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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Updates the payment page content for a Pay Out payment link. Use this to change the branding, messaging, payment methods offered, or other page configuration.

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

  • :paylink_id (String)

Returns:



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/payabli/payment_link/client.rb', line 445

def update_pay_link_out_from_id(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PATCH",
    path: "PaymentLink/updateOut/#{URI.encode_uri_component(params[:paylink_id].to_s)}",
    body: Payabli::Types::PaymentPageRequestBodyOut.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::PayabliApiResponsePaymentLinks.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end