Module: CcbConnectClient::Service

Defined in:
lib/ccb_connect_client/service.rb

Class Method Summary collapse

Class Method Details

.http_post_form(url, xml) ⇒ Object



49
50
51
# File 'lib/ccb_connect_client/service.rb', line 49

def self.http_post_form(url, xml)
  response = Net::HTTP.post_form URI(url), requestXml: xml
end

.payment_details_query(payment_details_query_request) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ccb_connect_client/service.rb', line 28

def self.payment_details_query payment_details_query_request
  res = http_post_form CcbConnectClient.server, payment_details_query_request.to_xml
  doc = Document.new(res.body)

  if doc.elements["TX/RETURN_CODE"].text != "000000"
    response = BaseResponse.from_xml res.body
    response.successful = false
    response
  else
    response = PaymentDetailsQueryResponse.from_xml res.body
    response.successful = true

    if CcbConnectClient.debug_mode
      puts "PaymentDetailsQueryResponse response : #{response.inspect}"
    end

    response
  end

end

.refund(refund_request) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ccb_connect_client/service.rb', line 7

def self.refund refund_request
  res = http_post_form CcbConnectClient.server, refund_request.to_xml
  doc = Document.new(res.body)

  if doc.elements["TX/RETURN_CODE"].text != "000000"
    response = BaseResponse.from_xml res.body
    response.successful = false
    response
  else
    response = RefundResponse.from_xml res.body
    response.successful = true

    if CcbConnectClient.debug_mode
      puts "RefundResponse response : #{response.inspect}"
    end

    response
  end

end