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:



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

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



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
390
391
392
393
394
# File 'lib/payabli/payment_link/client.rb', line 361

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::PaymentLink::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::PaymentLink::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
63
# 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)
  path_param_names = %i[id_invoice]
  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/#{URI.encode_uri_component(params[:id_invoice].to_s)}",
    headers: headers,
    query: query_params,
    body: Payabli::PaymentLink::Types::PaymentPageRequestBody.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::PaymentLink::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:



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

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



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

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



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

def patch_out_payment_link(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/out/#{URI.encode_uri_component(params[:paylink_id].to_s)}",
    body: Payabli::PaymentLink::Types::PatchOutPaymentLinkRequest.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::PaymentLink::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:



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

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



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

def refresh_pay_link_from_id(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[amount_fixed]
  query_params = {}
  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: "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::PaymentLink::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:



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

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

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



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/payabli/payment_link/client.rb', line 317

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 = ["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::PaymentLink::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:



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

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