class PayPoint::Blue::Hosted
Client class for the Hosted
product.
Constants
- ENDPOINTS
Public Class Methods
The Hosted
product has only a few endpoints. However, users most likey will want to access the endpoints of the API product as well. Therefore, this class also delegates to an API client which is initialized using the same options that this object receives.
PayPoint::Blue::Base::new
# File lib/paypoint/blue/hosted.rb, line 47 def initialize(**options) @api_client = PayPoint::Blue::API.new(**options) super end
Public Instance Methods
Download a skin
@api_url paymentdeveloperdocs.com/customise-_look_and_feel/manage-hosted-cashier-skins/
@param [String] skin_id the id of the skin @param [String] path the path to download the skin (optional)
@return a zip file
# File lib/paypoint/blue/hosted.rb, line 154 def download_skin(skin_id, path = nil) path ||= "." response = client.get "skins/#{skin_id}" File.open("#{File.expand_path(path)}/#{skin_id}.zip", "wb") do |file| file.write(Base64.decode64(response)) end end
Make a payment
@api_url developer.paypoint.com/payments/docs/#payments/make_a_payment
@applies_defaults
+:currency+, +:commerce_type+, +:return_url+, +:cancel_url+, +:restore_url+, +:skin+, +:pre_auth_callback+, +:post_auth_callback+, +:transaction_notification+
@param [Hash] payload the payload is made up of the keyword
arguments passed to the method
@return the API response
# File lib/paypoint/blue/hosted.rb, line 75 def make_payment(**payload) payload = build_payload payload, defaults: %i( currency commerce_type return_url cancel_url restore_url skin pre_auth_callback post_auth_callback transaction_notification customer_registration ) client.post "sessions/#{inst_id}/payments", build_payload(payload) end
Manage Cards
@api_url developer.paypoint.com/payments/docs/#customers/update_customer_cards
@applies_defaults :skin
@param [Hash] payload the payload is made up of the keyword
arguments passed to the method
@return the API response
# File lib/paypoint/blue/hosted.rb, line 132 def manage_cards(**payload) payload = build_payload payload, defaults: %i(skin) client.post "sessions/#{inst_id}/cards", build_payload(payload) end
Test connectivity
@return [true,false]
# File lib/paypoint/blue/hosted.rb, line 55 def ping client.get "sessions/ping" true rescue Faraday::ClientError false end
Replace a skin
Update the skin by uploading a new zip file. The method may also be used to update only the name and description of an existing skin.
@api_url paymentdeveloperdocs.com/customise-_look_and_feel/manage-hosted-cashier-skins/
@param [String] skin_id the id of the skin @param [Hash] arguments of the skin to update
file: the zip file with path (optional) name: new name for the skin (optional) description: description for the skin (optional)
@return the API response
# File lib/paypoint/blue/hosted.rb, line 195 def replace_skin(skin_id, file: nil, **params) client.put do |request| request.url "skins/#{skin_id}", params if file request.headers["Content-Type"] = "application/zip" request.body = File.read(file) end end end
Retrieve list of available skins
@api_url paymentdeveloperdocs.com/customise-_look_and_feel/manage-hosted-cashier-skins/
@return the API response
# File lib/paypoint/blue/hosted.rb, line 142 def skins client.get "skins/#{inst_id}/list" end
Submit a payout
@api_url developer.paypoint.com/payments/docs/#payments/submit_a_payout
@applies_defaults
+:currency+, +:commerce_type+, +:return_url+, +:cancel_url+, +:restore_url+, +:skin+, +:pre_auth_callback+, +:post_auth_callback+, +:transaction_notification+
@param [Hash] payload the payload is made up of the keyword
arguments passed to the method
@return the API response
# File lib/paypoint/blue/hosted.rb, line 114 def submit_payout(**payload) payload = build_payload payload, defaults: %i( currency commerce_type return_url cancel_url restore_url skin pre_auth_callback post_auth_callback transaction_notification ) client.post "sessions/#{inst_id}/payouts", build_payload(payload) end
Upload a new skin
@api_url paymentdeveloperdocs.com/customise-_look_and_feel/manage-hosted-cashier-skins/
@param [String] file the zip file with path @param [Hash] params request parameters placed in the url,
name: the name of the skin (required) description: description for the skin (optional)
@return the API response
# File lib/paypoint/blue/hosted.rb, line 172 def upload_skin(file, name:, **params) client.post do |request| request.url "skins/#{inst_id}/create", params.merge(name: name) request.headers["Content-Type"] = "application/zip" request.body = File.read(file) end end