payeezy 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 TODO: Write your name
1
+ Copyright (c) 2014 Sachin Shetty
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -18,7 +18,9 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Test cases can be run with 'bundle exec rake spec'
21
+ Run the specs using 'bundle exec rake spec'
22
+
23
+ Test cases can be run with 'bundle exec rake test'
22
24
 
23
25
  ## Contributing
24
26
 
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rspec/core/rake_task'
2
+ require 'rake/testtask'
2
3
 
3
4
  RSpec::Core::RakeTask.new do |t|
4
5
  t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
@@ -6,3 +7,12 @@ RSpec::Core::RakeTask.new do |t|
6
7
  end
7
8
 
8
9
  task :default => :spec
10
+
11
+ Rake::TestTask.new(:test) do |test|
12
+ test.libs << 'test'
13
+ test.test_files = FileList['test/*_test.rb']
14
+ test.verbose = true
15
+ end
16
+
17
+ desc "Run Tests"
18
+ task :default => :test
@@ -21,7 +21,8 @@ module Payeezy
21
21
 
22
22
  def generate_hmac(nonce, current_timestamp, payload)
23
23
  message = @apikey + nonce.to_s + current_timestamp.to_s + @token + payload
24
- hash = Base64.encode64(bin_to_hex(OpenSSL::HMAC.digest('sha256', @apisecret, message)))
24
+ hash = Base64.strict_encode64(bin_to_hex(OpenSSL::HMAC.digest('sha256', @apisecret, message)))
25
+ hash
25
26
  end
26
27
 
27
28
  def bin_to_hex(s)
@@ -43,7 +44,7 @@ module Payeezy
43
44
 
44
45
  def commit(action, params)
45
46
  url = @url
46
- if action == :capture || action == :void || action == :refund
47
+ if action == :capture || action == :void || action == :refund || action == :split
47
48
  url = url + '/' + params[:transaction_id]
48
49
  params.delete(:transaction_id)
49
50
  end
@@ -54,11 +55,9 @@ module Payeezy
54
55
  def call_rest(url, data, headers)
55
56
  rest_resource = RestClient::Resource.new(url)
56
57
  raw_response = response = {}
57
- success = false
58
58
  begin
59
59
  raw_response = rest_resource.post data, headers
60
60
  response = parse(raw_response)
61
- success = !response.key?('Error')
62
61
  rescue => e
63
62
  raw_response = e.response
64
63
  response = response_error(raw_response)
@@ -72,7 +71,7 @@ module Payeezy
72
71
  def handle_message(response, success)
73
72
  if success
74
73
  response['transaction_status']
75
- elsif (response.key?('Error'))
74
+ elsif response.key?('Error')
76
75
  response['Error'].map { |_, messages| messages }.join('. ')
77
76
  else
78
77
  response.inspect
@@ -1,3 +1,3 @@
1
1
  module Payeezy
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -21,10 +21,12 @@
21
21
  <orderEntry type="sourceFolder" forTests="false" />
22
22
  <orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.2, ruby-1.9.3-p484) [gem]" level="application" />
23
23
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, ruby-1.9.3-p484) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.9.6, ruby-1.9.3-p484) [gem]" level="application" />
24
25
  <orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, ruby-1.9.3-p484) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="mime-types (v1.25.1, ruby-1.9.3-p484) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v2.4.3, ruby-1.9.3-p484) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="netrc (v0.8.0, ruby-1.9.3-p484) [gem]" level="application" />
26
28
  <orderEntry type="library" scope="PROVIDED" name="rake (v10.3.2, ruby-1.9.3-p484) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="rest-client (v1.6.7, ruby-1.9.3-p484) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="rest-client (v1.7.2, ruby-1.9.3-p484) [gem]" level="application" />
28
30
  <orderEntry type="library" scope="PROVIDED" name="rspec (v2.14.1, ruby-1.9.3-p484) [gem]" level="application" />
29
31
  <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.14.8, ruby-1.9.3-p484) [gem]" level="application" />
30
32
  <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.14.5, ruby-1.9.3-p484) [gem]" level="application" />
@@ -4,10 +4,10 @@ describe "Sample calls to Payeezy" do
4
4
 
5
5
  before :each do
6
6
  options = {}
7
- options[:url] = 'https://api-cert.payeezy.com/v1/transactions'
8
- options[:apikey] = 'y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a'
9
- options[:apisecret] = '09730a91f4f055dd5d3878099644f2f60bf0a4421485f20af72076bbb0b41e96'
10
- options[:token] = 'fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6'
7
+ options[:url] = 'https://api-cert.payeezy.com/v1/transactions'
8
+ options[:apikey] = 'y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a'
9
+ options[:apisecret] = '86fbae7030253af3cd15faef2a1f4b67353e41fb6799f576b5093ae52901e6f7'
10
+ options[:token] = 'fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6'
11
11
 
12
12
  @payeezy = Payeezy::Transactions.new options
13
13
  end
@@ -52,6 +52,18 @@ describe "Sample calls to Payeezy" do
52
52
  @secondary_response['transaction_status'].should == "approved"
53
53
  end
54
54
 
55
+ it 'Split Shipment Transaction' do
56
+ @primary_response = @payeezy.transact(:authorize,primary_tx_payload)
57
+ @primary_response['transaction_status'].should == "approved"
58
+
59
+ @split_amount = @primary_response['amount'].to_i/2
60
+ @secondary_response = @payeezy.transact(:split,secondary_tx_payload_split(@primary_response,"01/99",@split_amount))
61
+ @secondary_response['transaction_status'].should == "approved"
62
+
63
+ @secondary_response = @payeezy.transact(:split,secondary_tx_payload_split(@primary_response,"02/02",@split_amount))
64
+ @secondary_response['transaction_status'].should == "approved"
65
+ end
66
+
55
67
 
56
68
  end
57
69
 
@@ -59,14 +71,14 @@ describe "Sample calls to Payeezy" do
59
71
  credit_card = {}
60
72
  payload = {}
61
73
  payload[:merchant_ref] = 'Astonishing-Sale'
62
- payload[:amount]='1299'
74
+ payload[:amount]='1200'
63
75
  payload[:currency_code]='USD'
64
76
  payload[:method]='credit_card'
65
77
 
66
78
  credit_card[:type] = 'visa'
67
79
  credit_card[:cardholder_name] = 'John Smith'
68
80
  credit_card[:card_number] = '4788250000028291'
69
- credit_card[:exp_date] = '1014'
81
+ credit_card[:exp_date] = '1020'
70
82
  credit_card[:cvv] = '123'
71
83
  payload[:credit_card] = credit_card
72
84
 
@@ -85,4 +97,17 @@ describe "Sample calls to Payeezy" do
85
97
  payload
86
98
  end
87
99
 
100
+ def secondary_tx_payload_split(response, split_shipment, split_amount)
101
+ payload = {}
102
+ payload[:merchant_ref] = 'Astonishing-Sale'
103
+ payload[:transaction_tag] = response['transaction_tag']
104
+ payload[:method]=response['method']
105
+ payload[:amount]=split_amount
106
+ payload[:split_shipment]=split_shipment
107
+ payload[:currency_code]=response['currency']
108
+ payload[:transaction_id] = response['transaction_id']
109
+
110
+ payload
111
+ end
112
+
88
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payeezy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-05 00:00:00.000000000 Z
12
+ date: 2014-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -116,7 +116,6 @@ files:
116
116
  - Rakefile
117
117
  - lib/payeezy.rb
118
118
  - lib/payeezy/version.rb
119
- - payeezy.gemspec
120
119
  - payeezy.iml
121
120
  - spec/payeezy_spec.rb
122
121
  - spec/spec_helper.rb
@@ -1,28 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'payeezy/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "payeezy"
8
- spec.version = Payeezy::VERSION
9
- spec.authors = ["Sachin Shetty"]
10
- spec.email = ["sachin.shetty@firstdata.com"]
11
- spec.summary = %q{Transact with Payeezy}
12
- spec.description = %q{See how easy it is to integrate with Payeezy using this gem}
13
- spec.homepage = "https://developer.payeezy.com"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency 'rspec'
24
-
25
- spec.add_dependency('rest-client', '~> 1.4')
26
- spec.add_dependency('json', '~> 1.8.1')
27
-
28
- end