Class: Payabli::PaymentLink::Client
- Inherits:
-
Object
- Object
- Payabli::PaymentLink::Client
- Defined in:
- lib/payabli/payment_link/client.rb
Instance Method Summary collapse
-
#add_pay_link_from_bill(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Generates a payment link for a bill from the bill ID.
-
#add_pay_link_from_bill_lot_number(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Generates a vendor payment link for a specific bill lot number.
-
#add_pay_link_from_invoice(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Generates a payment link for an invoice from the invoice ID.
-
#delete_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Deletes a payment link by ID.
-
#get_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::GetPayLinkFromIdResponse
Retrieves a payment link by ID.
- #initialize(client:) ⇒ void constructor
-
#patch_out_payment_link(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Partially updates a Pay Out payment link's content, expiration date, and/or status.
-
#push_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Send a payment link to the specified email addresses or phone numbers.
-
#refresh_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Refresh a payment link's content after an update.
-
#send_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Sends a payment link to the specified email addresses.
-
#update_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Updates a payment link's details.
-
#update_pay_link_out_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Updates the payment page content for a Pay Out payment link.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/payment_link/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_pay_link_from_bill(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
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.
263 264 265 266 267 268 269 270 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 |
# File 'lib/payabli/payment_link/client.rb', line 263 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] headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers) request = Payabli::Internal::JSON::Request.new( base_url: [: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: ) 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 |
#add_pay_link_from_bill_lot_number(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
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.
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
# File 'lib/payabli/payment_link/client.rb', line 654 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) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "PaymentLink/bill/lotNumber/#{URI.encode_uri_component(params[:lot_number].to_s)}", headers: headers, query: query_params, body: Payabli::Types::PaymentPageRequestBodyOut.new(body_params).to_h, 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 |
#add_pay_link_from_invoice(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Generates a payment link for an invoice from the invoice ID.
The payment page configuration blocks (logo, page, paymentMethods, review, messageBeforePaying,
paymentButton, notes, contactUs, and settings) are optional. When you omit a block, Payabli applies a
default rather than hiding it. The block is enabled at a fixed display order, so the generated page stays
complete and branded. To hide a section, send the block explicitly with enabled set to false. An explicit
value is always honored and is never replaced by a default. For each block's default, see its description in the
request body.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/payabli/payment_link/client.rb', line 146 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] headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "PaymentLink/#{URI.encode_uri_component(params[:id_invoice].to_s)}", headers: headers, query: query_params, body: body, 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 |
#delete_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Deletes a payment link by ID.
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/payabli/payment_link/client.rb', line 316 def delete_pay_link_from_id(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "PaymentLink/#{URI.encode_uri_component(params[:pay_link_id].to_s)}", headers: headers, 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 |
#get_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::GetPayLinkFromIdResponse
Retrieves a payment link by ID.
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/payabli/payment_link/client.rb', line 355 def get_pay_link_from_id(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "PaymentLink/load/#{URI.encode_uri_component(params[:paylink_id].to_s)}", headers: headers, 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 |
#patch_out_payment_link(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
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.
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
# File 'lib/payabli/payment_link/client.rb', line 712 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) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "PaymentLink/out/#{URI.encode_uri_component(params[:paylink_id].to_s)}", headers: headers, body: body, 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 |
#push_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Send a payment link to the specified email addresses or phone numbers.
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/payabli/payment_link/client.rb', line 394 def push_pay_link_from_id(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "PaymentLink/push/#{URI.encode_uri_component(params[:pay_link_id].to_s)}", headers: headers, body: Payabli::Types::PushPayLinkRequest.new(params).to_h, 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_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Refresh a payment link's content after an update.
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/payabli/payment_link/client.rb', line 435 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) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "PaymentLink/refresh/#{URI.encode_uri_component(params[:pay_link_id].to_s)}", headers: headers, query: query_params, 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_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Sends a payment link to the specified email addresses.
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
# File 'lib/payabli/payment_link/client.rb', line 483 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) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "PaymentLink/send/#{URI.encode_uri_component(params[:pay_link_id].to_s)}", headers: headers, query: query_params, 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 |
#update_pay_link_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
Updates a payment link's details.
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 568 |
# File 'lib/payabli/payment_link/client.rb', line 541 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) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "PaymentLink/update/#{URI.encode_uri_component(params[:pay_link_id].to_s)}", headers: headers, body: body, 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 |
#update_pay_link_out_from_id(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponsePaymentLinks
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.
817 818 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/payment_link/client.rb', line 817 def update_pay_link_out_from_id(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "PaymentLink/updateOut/#{URI.encode_uri_component(params[:paylink_id].to_s)}", headers: headers, body: Payabli::Types::PaymentPageRequestBodyOut.new(params).to_h, 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 |