Class: Payabli::HostedPaymentPages::Client
- Inherits:
-
Object
- Object
- Payabli::HostedPaymentPages::Client
- Defined in:
- lib/payabli/hosted_payment_pages/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#load_page(request_options: {}, **params) ⇒ Payabli::Types::PayabliPages
Loads all of a payment page's details including
pageIdentifierandvalidationCode. -
#new_page(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse00Responsedatanonobject
Creates a new payment page for a paypoint.
-
#save_page(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse00Responsedatanonobject
Updates a payment page in a paypoint.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/hosted_payment_pages/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#load_page(request_options: {}, **params) ⇒ Payabli::Types::PayabliPages
Loads all of a payment page's details including pageIdentifier and validationCode. This endpoint requires an
application API token.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/payabli/hosted_payment_pages/client.rb', line 33 def load_page(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: "Paypoint/load/#{URI.encode_uri_component(params[:entry].to_s)}/#{URI.encode_uri_component(params[:subdomain].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::PayabliPages.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#new_page(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse00Responsedatanonobject
Creates a new payment page for a paypoint. Note: this operation doesn't create a new paypoint, just a payment page for an existing paypoint. Paypoints are created by the Payabli team when a boarding application is approved.
78 79 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 |
# File 'lib/payabli/hosted_payment_pages/client.rb', line 78 def new_page(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) path_param_names = %i[entry] body_params = params.except(*path_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: "Paypoint/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, body: Payabli::Types::PayabliPages.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::PayabliApiResponse00Responsedatanonobject.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#save_page(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse00Responsedatanonobject
Updates a payment page in a paypoint.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/payabli/hosted_payment_pages/client.rb', line 128 def save_page(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: "PUT", path: "Paypoint/#{URI.encode_uri_component(params[:entry].to_s)}/#{URI.encode_uri_component(params[:subdomain].to_s)}", headers: headers, body: Payabli::Types::PayabliPages.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::PayabliApiResponse00Responsedatanonobject.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |