Class: OrbipayPaymentsapiClient::OrbipayPaymentsapiClientHandlers::CancelPaymentAuthorizationHandler

Inherits:
Base
  • Object
show all
Defined in:
lib/orbipay_paymentsapi_client/handlers/cancel_payment_authorization_handler.rb

Overview

.

############################################################################################
## This class subject to change without prior notice, Please dont use this class directly.##
############################################################################################

Instance Attribute Summary

Attributes inherited from Base

#api_end_point, #http_status_code, #invocation_context, #live_mode

Instance Method Summary collapse

Methods inherited from Base

attribute_map, #for_client, #initialize, #requested_by, #set_api_end_point, #set_values, swagger_types, #vide_channel, #with_context

Constructor Details

This class inherits a constructor from OrbipayPaymentsapiClient::Base

Instance Method Details

#populate_request_body(payment_authorization) ⇒ Object



60
61
62
63
64
# File 'lib/orbipay_paymentsapi_client/handlers/cancel_payment_authorization_handler.rb', line 60

def populate_request_body(payment_authorization)
	payment_authorization_json_object = CommonUtil::CommonUtil.object_to_http_body(payment_authorization)
   	cancel_payment_authorization_request = CommonUtil::CommonUtil.deserialize(payment_authorization_json_object,"CancelPaymentAuthorizationRequest")
	cancel_payment_authorization_request
end

#process(payment_authorization) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/orbipay_paymentsapi_client/handlers/cancel_payment_authorization_handler.rb', line 13

def process(payment_authorization)

	configuration = Configuration::Configuration.new
	if payment_authorization.invocation_context.secret != nil
		configuration.set_values(secret: payment_authorization.invocation_context.secret)
	end
	if payment_authorization.invocation_context.api_key != nil
		configuration.set_values(client_api_key: payment_authorization.invocation_context.api_key)
	end
	if payment_authorization.invocation_context.auth_scheme != nil
		configuration.set_values(algorithm: payment_authorization.invocation_context.auth_scheme)
	end
	configuration.set_values(api_end_point: payment_authorization.api_end_point)
	if payment_authorization.invocation_context.idempotent_request_key != nil 
		configuration.logger.info "Idempotent Request Key: #{ payment_authorization.invocation_context.idempotent_request_key}"
	end
		api_client = ApiClient::ApiClient.new(configuration)
		api_instance = OrbipayPaymentsapiClientApis::PaymentAuthorizationApi.new(api_client)
		channel = payment_authorization.invocation_context.channel
		client_key = payment_authorization.invocation_context.client_key
		product = payment_authorization.invocation_context.product
		if payment_authorization.invocation_context.timestamp != nil 
			timestamp = payment_authorization.invocation_context.timestamp
		else
			timestamp = CommonUtil::CommonUtil.time_stamp
		end
		idempotent_request_key = payment_authorization.invocation_context.idempotent_request_key
		requestor_type = payment_authorization.invocation_context.requestor_type
		id_customer = payment_authorization.id_customer
		id_authorization = payment_authorization.id_authorization
		cancel_payment_authorization_request = self.populate_request_body(payment_authorization)
		requestor = payment_authorization.invocation_context.requestor
		x_opay_headers = payment_authorization.invocation_context.x_opay_headers
		trace_id = payment_authorization.invocation_context.trace_id
		opts = {
		requestor: requestor,
		x_opay_headers: x_opay_headers,
		trace_id: trace_id,
		}
		http_status_code, headers = api_instance.cancel_payment_authorization(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_customer, id_authorization, cancel_payment_authorization_request,  opts)
		response = PaymentAuthorization.new
		response.set_values(invocation_context: wrap_response_headers(headers))
		response.set_values(http_status_code: http_status_code)
	response

end

#wrap_response_headers(headers) ⇒ Object



66
67
68
69
# File 'lib/orbipay_paymentsapi_client/handlers/cancel_payment_authorization_handler.rb', line 66

def wrap_response_headers(headers)
	headers_json_object = CommonUtil::CommonUtil.object_to_http_body(headers)
	CommonUtil::CommonUtil.deserialize(headers_json_object,"InvocationContext")
end