paysio 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paysio (1.0.3)
4
+ paysio (1.0.4)
5
5
  activemodel
6
6
  activesupport
7
7
  oj (> 2)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
@@ -1,7 +1,7 @@
1
1
  module Paysio
2
2
  module Actions
3
3
  module Destroy
4
- def destroy(attrs = {})
4
+ def delete(attrs = {})
5
5
  response = Paysio::Client.request(:delete, path)
6
6
  refresh_from(response.to_hash)
7
7
  end
@@ -10,5 +10,10 @@ module Paysio
10
10
  response = Paysio::Client.request(:post, action_path(:refund), attrs)
11
11
  refresh_from(response.to_hash)
12
12
  end
13
+
14
+ def invoice
15
+ response = Paysio::Client.request(:get, action_path(:invoice))
16
+ Resource.build_from(response.to_hash)
17
+ end
13
18
  end
14
19
  end
@@ -6,5 +6,10 @@ module Paysio
6
6
  include Paysio::Actions::Destroy
7
7
  include Paysio::Actions::Find
8
8
  resource :coupon
9
+
10
+ def self.check(code)
11
+ response = Paysio::Client.request(:get, "#{self.path}/code/#{code}/check")
12
+ Resource.build_from(response)
13
+ end
9
14
  end
10
15
  end
@@ -1,3 +1,3 @@
1
1
  module Paysio
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
@@ -10,4 +10,22 @@ describe Paysio::Charge do
10
10
  c = Paysio::Charge.create
11
11
  c.should be_a_kind_of(Paysio::Charge)
12
12
  end
13
+
14
+ it "should be refundable" do
15
+ client = authorized_paysio_client
16
+
17
+ client.expects(:get).once.returns(test_response(test_charge))
18
+ client.expects(:post).once.returns(test_response(test_charge))
19
+ c = Paysio::Charge.retrieve('test_id')
20
+ c.refund
21
+ end
22
+
23
+ it "should have an invoice" do
24
+ client = authorized_paysio_client
25
+
26
+ client.expects(:get).twice.returns(test_response(test_charge))
27
+ c = Paysio::Charge.retrieve('test_id')
28
+ invoice = c.invoice
29
+ invoice.should be_a_kind_of(Paysio::Charge)
30
+ end
13
31
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
  describe Paysio::Coupon do
3
3
  it { should be_listable_resource }
4
4
  it { should be_updatable_resource }
5
+ it { should be_deleteable_resource }
5
6
 
6
7
  it "should return coupon on create" do
7
8
  client = authorized_paysio_client
@@ -10,4 +11,12 @@ describe Paysio::Coupon do
10
11
  c = Paysio::Coupon.create
11
12
  c.should be_a_kind_of(Paysio::Coupon)
12
13
  end
14
+
15
+ it "should return coupon while checking code" do
16
+ client = authorized_paysio_client
17
+
18
+ client.expects(:get).once.returns(test_response(test_coupon))
19
+ c = Paysio::Coupon.check('test_code')
20
+ c.should be_a_kind_of(Paysio::Coupon)
21
+ end
13
22
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
  describe Paysio::Customer do
3
3
  it { should be_listable_resource }
4
4
  it { should be_updatable_resource }
5
+ it { should be_deleteable_resource }
5
6
 
6
7
  it "should return charge on create" do
7
8
  client = authorized_paysio_client
@@ -1,4 +1,12 @@
1
1
  require 'spec_helper'
2
2
  describe Paysio::Log do
3
3
  it { should be_listable_resource }
4
+
5
+ it "should have request post params" do
6
+ client = authorized_paysio_client
7
+
8
+ client.expects(:get).once.returns(test_response(test_log))
9
+ c = Paysio::Log.retrieve('someid')
10
+ c.request_post_params.should_not be_blank
11
+ end
4
12
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
  describe Paysio::Reward do
3
3
  it { should be_listable_resource }
4
4
  it { should be_updatable_resource }
5
+ it { should be_deleteable_resource }
5
6
 
6
7
  it "should return reward on create" do
7
8
  client = authorized_paysio_client
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
  describe Paysio::Wallet do
3
3
  it { should be_listable_resource }
4
4
  it { should be_updatable_resource }
5
+ it { should be_deleteable_resource }
5
6
 
6
7
  it "should return wallet on create" do
7
8
  client = authorized_paysio_client
@@ -32,6 +32,7 @@
32
32
  def test_charge(params={})
33
33
  {
34
34
  :object => 'charge',
35
+ :id => "ch_BFyI4KoDVHzsfNoXpi4",
35
36
  :merchant_id => 'm_12345',
36
37
  :amount => 100,
37
38
  :fee => 10,
@@ -88,6 +89,10 @@
88
89
  :object => 'log',
89
90
  :request_url => 'http://example.com',
90
91
  :request_ip => '127.0.0.1',
92
+ :request_post_params => {
93
+ :email => "test@test.ru",
94
+ :description => "Test customer"
95
+ },
91
96
  :livemode => false
92
97
  }.merge(params)
93
98
  end
@@ -24,4 +24,15 @@ RSpec::Matchers.define :be_updatable_resource do |expected|
24
24
  c.save
25
25
  c.name.should == "bar"
26
26
  end
27
+ end
28
+ RSpec::Matchers.define :be_deleteable_resource do |expected|
29
+ match do |actual|
30
+ client = authorized_paysio_client
31
+ subject = actual.class
32
+
33
+ client.expects(:get).once.returns(test_response(test_customer({name: "foo"})))
34
+ client.expects(:delete).once.returns(test_response(test_customer({name: "bar"})))
35
+ c = subject.retrieve("resource_id")
36
+ c.delete
37
+ end
27
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paysio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
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: 2013-03-15 00:00:00.000000000 Z
12
+ date: 2013-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client