twocheckout 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16ad57a7fd3ce73cbaabd0986752cdb9c3b2d09c
4
- data.tar.gz: e06eee45323d2f72e20cf0a6766c44359b174db6
3
+ metadata.gz: c2c35dc95ae9cdba6bff621701724ca93c71c21a
4
+ data.tar.gz: 838bdbed8f8e1dcb5eeff2c33408492460f8b9b6
5
5
  SHA512:
6
- metadata.gz: 6347defc9ccd992b6223fc28d08b21827986db1b9de5562630d54ecc83efa0a938363716163331bbbbe67eaab62c29a6976a8fed71f223a3972c8d1a84fe6ca5
7
- data.tar.gz: 4ae23fcb28ff68f633bc0e37b6af9df9ac6ade4a9686e328c0be0a96ed0b499b0566f47e8dc71b42e9979b5828c787a32810a33dd8e5d6bfc7a90cc0e9a34c20
6
+ metadata.gz: 55449a02efd9c154bd807bebc35d882b1c57f9f2b6ed5ff51ab7f2c4ee18ba436ca9510b58128618e27edd42d3671363b7656ada1f222ada1fd5632783754c37
7
+ data.tar.gz: 1f2ecbf090ee57623cf93d2b1d6130bbccb41aa6ccfd05222524e623400bc9a9a53f7500bde362c5fb09343ff7a266291e47f32a86ffe5b56f602e1757154592
data/README.md CHANGED
@@ -15,7 +15,7 @@ Or import into your Gemfile.
15
15
  gem "twocheckout"
16
16
  ```
17
17
 
18
- Full documentation for each binding is provided in the **[2Checkout Documentation](https://www.2checkout.com/documentation/libraries/ruby)**.
18
+ Full documentation for each binding is provided in the **[wiki](https://github.com/2Checkout/2checkout-ruby/wiki)**.
19
19
 
20
20
 
21
21
  Example Purchase API Usage
@@ -284,4 +284,4 @@ end
284
284
  "Lineitem is not scheduled to recur."
285
285
  ```
286
286
 
287
- Full documentation for each binding is provided in the **[2Checkout Documentation](https://www.2checkout.com/documentation/libraries/ruby)**.
287
+ Full documentation for each binding is provided in the **[wiki](https://github.com/2Checkout/2checkout-ruby/wiki)**.
@@ -23,7 +23,7 @@ module Twocheckout
23
23
  rescue => e
24
24
  error_hash = JSON.parse(e.response)
25
25
  if error_hash['exception']
26
- raise TwocheckoutError.new(error_hash['exception']['errorMsg'])
26
+ raise TwocheckoutError.new(error_hash['exception']['errorMsg'], error_hash['exception']['errorCode'])
27
27
  else
28
28
  raise TwocheckoutError.new(error_hash['errors'][0]['message'])
29
29
  end
@@ -1,9 +1,11 @@
1
1
  module Twocheckout
2
2
  class TwocheckoutError < StandardError
3
3
  attr_reader :message
4
+ attr_reader :code
4
5
 
5
- def initialize(message)
6
+ def initialize(message, code = nil)
6
7
  @message = message
8
+ @code = code
7
9
  end
8
10
  end
9
- end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Twocheckout
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -24,57 +24,57 @@ describe Twocheckout::Sale do
24
24
  end
25
25
 
26
26
  #refund sale
27
- it "Refunding a refunded sale returns exception" do
27
+ it "Refunding a refunded sale returns Twocheckout::TwocheckoutError" do
28
28
  begin
29
29
  sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
30
30
  sale.refund!({:comment => "test refund", :category => 1})
31
- rescue Exception => e
31
+ rescue Twocheckout::TwocheckoutError => e
32
32
  assert_equal("Invoice was already refunded.", e.message)
33
33
  end
34
34
  end
35
35
 
36
36
  #refund invoice
37
- it "Refunding a refunded invoice returns exception" do
37
+ it "Refunding a refunded invoice returns Twocheckout::TwocheckoutError" do
38
38
  begin
39
39
  sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
40
40
  invoice = sale.invoices.first
41
41
  invoice.refund!({:comment => "test refund", :category => 1})
42
- rescue Exception => e
42
+ rescue Twocheckout::TwocheckoutError => e
43
43
  assert_equal("Invoice was already refunded.", e.message)
44
44
  end
45
45
  end
46
46
 
47
47
  #refund lineitem
48
- it "Refunding a refunded lineitem returns exception" do
48
+ it "Refunding a refunded lineitem returns Twocheckout::TwocheckoutError" do
49
49
  begin
50
50
  sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
51
51
  first_invoice = sale.invoices.first
52
52
  last_lineitem = first_invoice.lineitems.last
53
53
  last_lineitem.refund!({:comment => "test refund", :category => 1})
54
- rescue Exception => e
54
+ rescue Twocheckout::TwocheckoutError => e
55
55
  assert_equal("This lineitem cannot be refunded.", e.message)
56
56
  end
57
57
  end
58
58
 
59
59
  #stop recurring lineitem
60
- it "Stopping a stopped recurring lineitem returns exception" do
60
+ it "Stopping a stopped recurring lineitem returns Twocheckout::TwocheckoutError" do
61
61
  begin
62
62
  sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
63
63
  result = sale.stop_recurring!
64
64
  assert_equal(result, [])
65
- rescue Exception => e
65
+ rescue Twocheckout::TwocheckoutError => e
66
66
  assert_equal("Lineitem is not scheduled to recur.", e.message)
67
67
  end
68
68
  end
69
69
 
70
70
  #stop recurring sale
71
- it "Stopping a stopped recurring sale returns exception" do
71
+ it "Stopping a stopped recurring sale returns Twocheckout::TwocheckoutError" do
72
72
  begin
73
73
  sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
74
74
  last_invoice = sale.invoices.last
75
75
  last_lineitem = last_invoice.lineitems.last
76
76
  last_lineitem.stop_recurring!
77
- rescue Exception => e
77
+ rescue Twocheckout::TwocheckoutError => e
78
78
  assert_equal("Lineitem is not scheduled to recur.", e.message)
79
79
  end
80
80
  end
@@ -87,21 +87,21 @@ describe Twocheckout::Sale do
87
87
  end
88
88
 
89
89
  #mark shipped
90
- it "Shipping an intangible sale returns exception" do
90
+ it "Shipping an intangible sale returns Twocheckout::TwocheckoutError" do
91
91
  begin
92
92
  sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
93
93
  sale.ship({:tracking_number => "123"})
94
- rescue Exception => e
94
+ rescue Twocheckout::TwocheckoutError => e
95
95
  assert_equal("Sale already marked shipped.", e.message)
96
96
  end
97
97
  end
98
98
 
99
99
  #reauth
100
- it "Reauthorizing a pending sale returns exception" do
100
+ it "Reauthorizing a pending sale returns Twocheckout::TwocheckoutError" do
101
101
  begin
102
102
  sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
103
103
  sale.reauth
104
- rescue Exception => e
104
+ rescue Twocheckout::TwocheckoutError => e
105
105
  assert_equal("Payment is already pending or deposited and cannot be reauthorized.", e.message)
106
106
  end
107
107
  end
data/twocheckout.gemspec CHANGED
@@ -4,9 +4,9 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
4
4
  Gem::Specification.new do |s|
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.name = 'twocheckout'
7
- s.version = '0.3.1'
7
+ s.version = '0.4.0'
8
8
  s.summary = '2Checkout Ruby Library'
9
- s.description = '0.3.0'
9
+ s.description = '0.4.0'
10
10
  s.summary = '2Checkout Ruby Library'
11
11
  s.author = "Craig Christenson", "Ernesto Garcia"
12
12
  s.email = 'christensoncraig@gmail.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twocheckout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Christenson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-02 00:00:00.000000000 Z
12
+ date: 2015-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -25,7 +25,7 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.4'
28
- description: 0.3.0
28
+ description: 0.4.0
29
29
  email: christensoncraig@gmail.com
30
30
  executables: []
31
31
  extensions: []
@@ -72,10 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - none
74
74
  rubyforge_project:
75
- rubygems_version: 2.2.2
75
+ rubygems_version: 2.4.3
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: 2Checkout Ruby Library
79
- test_files:
80
- - test/minitest_helper.rb
81
- - test/twocheckout_test.rb
79
+ test_files: []