class PayPoint::Blue::API
Client class for the API
product.
Constants
- ENDPOINTS
Public Instance Methods
Get details of a customer
@api_url developer.paypoint.com/payments/docs/#customers/request_customer_and_cards
@param [String] customer_id the id of the customer as assigned by PayPoint
@return the API
response
# File lib/paypoint/blue/api.rb, line 195 def customer(customer_id) client.get "customers/#{inst_id}/#{customer_id}" end
Get details of a customer by merchant reference
@api_url developer.paypoint.com/payments/docs/#customers/request_customer_and_cards
@param [String] customer_ref the merchant reference for the customer
@return the API
response
# File lib/paypoint/blue/api.rb, line 206 def customer_by_ref(customer_ref) client.get "customers/#{inst_id}/byRef?merchantRef=#{customer_ref}" end
Get a specific registered payment method of a customer
@api_url developer.paypoint.com/payments/docs/#customers/request_customer_and_cards
@param [String] customer_id the id of the customer as assigned by PayPoint
@param [String] token the token identifying the payment method
@return the API
response
# File lib/paypoint/blue/api.rb, line 229 def customer_payment_method(customer_id, token) client.get "customers/#{inst_id}/#{customer_id}/paymentMethods/#{token}" end
Get the list of the registered payment methods of a customer
@api_url developer.paypoint.com/payments/docs/#customers/request_customer_and_cards
@param [String] customer_id the id of the customer as assigned by PayPoint
@return the API
response
# File lib/paypoint/blue/api.rb, line 217 def customer_payment_methods(customer_id) client.get "customers/#{inst_id}/#{customer_id}/paymentMethods" end
Make a payment
@api_url developer.paypoint.com/payments/docs/#payments/make_a_payment
@applies_defaults
+:currency+, +:commerce_type+, +:pre_auth_callback+, +:post_auth_callback+, +:transaction_notification+, +:expiry_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/api.rb, line 47 def make_payment(**payload) payload = build_payload payload, defaults: %i( currency commerce_type pre_auth_callback post_auth_callback transaction_notification expiry_notification customer_registration ) client.post "transactions/#{inst_id}/payment", payload end
Test connectivity
@return [true,false]
# File lib/paypoint/blue/api.rb, line 27 def ping client.get "transactions/ping" true rescue Faraday::ClientError false end
Refund a payment
@api_url developer.paypoint.com/payments/docs/#payments/refund_a_payment
Without a payload this will refund the full amount. If you only want to refund a smaller amount, you will need to pass either the amount
or a transaction
hash as a keyword argument.
@example Partial refund
blue.refund_payment(txn_id, amount: '3.49') # assumes a default currency
@applies_defaults
only if amount is set: +:currency+, +:commerce_type+
@applies_defaults
+:pre_auth_callback+, +:post_auth_callback+, +:transaction_notification+, +:expiry_notification+
@param (see capture_authorisation
)
@return the API
response
# File lib/paypoint/blue/api.rb, line 154 def refund_payment(transaction_id, **payload) defaults = %i( pre_auth_callback post_auth_callback transaction_notification expiry_notification ) if payload[:amount] || payload[:transaction] && payload[:transaction][:amount] defaults += %i(currency commerce_type) end payload = build_payload(payload, defaults: defaults) client.post "transactions/#{inst_id}/#{transaction_id}/refund", payload end
Remove card
# File lib/paypoint/blue/api.rb, line 234 def remove_card(customer_id, token) client.post "customers/#{inst_id}/#{customer_id}/paymentMethod/#{token}/remove" end
Submit a payout
@api_url developer.paypoint.com/payments/docs/#payments/submit_a_payout
@applies_defaults
+:currency+, +:commerce_type+, +:pre_auth_callback+, +:post_auth_callback+, +:transaction_notification+, +:expiry_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/api.rb, line 180 def submit_payout(**payload) payload = build_payload payload, defaults: %i( currency commerce_type pre_auth_callback post_auth_callback transaction_notification expiry_notification ) client.post "transactions/#{inst_id}/payout", payload end
Get transaction details
@api_url developer.paypoint.com/payments/docs/#payments/request_a_previous_transaction
@param [String] transaction_id the id of the transaction
@return the API
response
# File lib/paypoint/blue/api.rb, line 119 def transaction(transaction_id) client.get "transactions/#{inst_id}/#{transaction_id}" end
Get transaction details by merchant reference
@api_url developer.paypoint.com/payments/docs/#payments/request_a_previous_transaction
@param [String] merchant_ref the merchant reference for the transactions
@return the API
response
# File lib/paypoint/blue/api.rb, line 130 def transactions_by_ref(merchant_ref) client.get "transactions/#{inst_id}/byRef?merchantRef=#{merchant_ref}" end