poundpay 0.2.5 → 0.2.6

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.
@@ -2,10 +2,16 @@ require 'uri'
2
2
 
3
3
  require 'poundpay/resource'
4
4
 
5
- class PaymentReleaseException < Exception
5
+ class PaymentException < Exception
6
6
  end
7
7
 
8
- class PaymentCancelException < Exception
8
+ class PaymentEscrowException < PaymentException
9
+ end
10
+
11
+ class PaymentReleaseException < PaymentException
12
+ end
13
+
14
+ class PaymentCancelException < PaymentException
9
15
  end
10
16
 
11
17
  module Poundpay
@@ -35,6 +41,14 @@ module Poundpay
35
41
  end
36
42
 
37
43
  class Payment < Resource
44
+ def escrow
45
+ unless status == 'AUTHORIZED'
46
+ raise PaymentEscrowException.new "Payment status is #{status}. Only AUTHORIZED payments may be released"
47
+ end
48
+ attributes['status'] = 'ESCROWED'
49
+ save
50
+ end
51
+
38
52
  def release
39
53
  unless status == 'ESCROWED'
40
54
  raise PaymentReleaseException.new "Payment status is #{status}. Only ESCROWED payments may be released"
@@ -1,3 +1,3 @@
1
1
  module Poundpay
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -22,6 +22,12 @@ module Poundpay
22
22
  }
23
23
  end
24
24
 
25
+ def authorized_payment_attributes
26
+ @attributes = staged_payment_attributes
27
+ @attributes["status"] = "AUTHORIZED"
28
+ @attributes
29
+ end
30
+
25
31
  def escrowed_payment_attributes
26
32
  @attributes = staged_payment_attributes
27
33
  @attributes["status"] = "ESCROWED"
@@ -66,6 +66,21 @@ describe Payment do
66
66
  Poundpay.clear_config!
67
67
  end
68
68
 
69
+ describe "#escrow" do
70
+ it "should not be able to escrow a STAGED payment" do
71
+ @staged_payment = Payment.new staged_payment_attributes
72
+ expect {@staged_payment.escrow}.to raise_error(PaymentEscrowException)
73
+ end
74
+
75
+ it "should escrow an AUTHORIZED payment" do
76
+ @authorized_payment = Payment.new authorized_payment_attributes
77
+ @authorized_payment.should_receive(:save).and_return(Payment.new escrowed_payment_attributes)
78
+
79
+ @authorized_payment.escrow
80
+ @authorized_payment.status.should == 'ESCROWED'
81
+ end
82
+ end
83
+
69
84
  describe "#release" do
70
85
  it "should not be able to release a STAGED payment" do
71
86
  @staged_payment = Payment.new staged_payment_attributes
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 5
9
- version: 0.2.5
8
+ - 6
9
+ version: 0.2.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matin Tamizi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-01 00:00:00 -07:00
17
+ date: 2011-04-20 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency