diff --git a/lib/cardknox/agent.rb b/lib/cardknox/agent.rb index d16c03c..63be6cb 100644 --- a/lib/cardknox/agent.rb +++ b/lib/cardknox/agent.rb @@ -21,7 +21,7 @@ def post(path, body = {}) def parse(response) JSON.parse(response.body, symbolize_names: true).tap do |payload| - if payload[:xStatus] != "Approved" + unless ["Approved", "Success"].include?(payload[:xStatus]) raise Error::TransactionFailure.new(payload[:xError], response) end end diff --git a/lib/cardknox/api.rb b/lib/cardknox/api.rb index f1713de..99141a3 100644 --- a/lib/cardknox/api.rb +++ b/lib/cardknox/api.rb @@ -24,6 +24,16 @@ def transaction(command, params = {}) })) end + def report(command, params = {}) + @agent.post("/reportjson", params.merge({ + xKey: config.api_key, + xVersion: config.gateway_version, + xSoftwareName: config.software_name, + xSoftwareVersion: config.software_version, + xCommand: command, + })) + end + def status @agent.get("/status") end diff --git a/spec/lib/cardknox/api/client_spec.rb b/spec/lib/cardknox/api/client_spec.rb index a0bae04..f3d1992 100644 --- a/spec/lib/cardknox/api/client_spec.rb +++ b/spec/lib/cardknox/api/client_spec.rb @@ -6,5 +6,6 @@ describe "Respond to" do it { is_expected.to(respond_to(:status)) } it { is_expected.to(respond_to(:transaction)) } + it { is_expected.to(respond_to(:report)) } end end