lib/adyen/services/payment.rb in adyen-ruby-api-library-7.0.1 vs lib/adyen/services/payment.rb in adyen-ruby-api-library-7.0.2

- old
+ new

@@ -1,172 +1,24 @@ -require_relative './service' -module Adyen +require_relative 'payment/general_api' +require_relative 'payment/modifications_api' - - class Payment < Service +module Adyen + class Payment attr_accessor :service, :version - DEFAULT_VERSION = 68 + DEFAULT_VERSION = 68 def initialize(client, version = DEFAULT_VERSION) - @service = "Payment" + @service = 'Payment' @client = client @version = version end - def adjust_authorisation(request, headers: {} ) - """ - Change the authorised amount - """ - endpoint = "/adjustAuthorisation".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) + def general_api + @general_api ||= Adyen::GeneralApi.new(@client, @version) end - def authorise(request, headers: {} ) - """ - Create an authorisation - """ - endpoint = "/authorise".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def authorise3d(request, headers: {} ) - """ - Complete a 3DS authorisation - """ - endpoint = "/authorise3d".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def authorise3ds2(request, headers: {} ) - """ - Complete a 3DS2 authorisation - """ - endpoint = "/authorise3ds2".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def cancel(request, headers: {} ) - """ - Cancel an authorisation - """ - endpoint = "/cancel".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def cancel_or_refund(request, headers: {} ) - """ - Cancel or refund a payment - """ - endpoint = "/cancelOrRefund".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def capture(request, headers: {} ) - """ - Capture an authorisation - """ - endpoint = "/capture".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def donate(request, headers: {} ) - """ - Create a donation - """ - endpoint = "/donate".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def get_authentication_result(request, headers: {} ) - """ - Get the 3DS authentication result - """ - endpoint = "/getAuthenticationResult".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def refund(request, headers: {} ) - """ - Refund a captured payment - """ - endpoint = "/refund".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def retrieve3ds2_result(request, headers: {} ) - """ - Get the 3DS2 authentication result - """ - endpoint = "/retrieve3ds2Result".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def technical_cancel(request, headers: {} ) - """ - Cancel an authorisation using your reference - """ - endpoint = "/technicalCancel".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) - end - - def void_pending_refund(request, headers: {} ) - """ - Cancel an in-person refund - """ - endpoint = "/voidPendingRefund".gsub(/{.+?}/, '%s') - endpoint = endpoint.gsub(/^\//, "") - endpoint = endpoint % [] - - action = { method: "post", url: endpoint} - @client.call_adyen_api(@service, action, request, headers, @version) + def modifications_api + @modifications_api ||= Adyen::ModificationsApi.new(@client, @version) end end end