poundpay 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -8
- data/lib/poundpay/version.rb +1 -1
- data/lib/poundpay.rb +10 -0
- data/spec/poundpay_spec.rb +21 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -18,12 +18,14 @@ Poundpay is a payments platform for marketplaces
|
|
18
18
|
development:
|
19
19
|
developer_sid: DV0383d447360511e0bbac00264a09ff3c
|
20
20
|
auth_token: c31155b9f944d7aed204bdb2a253fef13b4fdcc6ae1540200449cc4526b2381a
|
21
|
+
callback_url: http://staging.awesomemarketplace.com/payments/callback
|
21
22
|
www_url: https://www-sandbox.poundpay.com
|
22
23
|
api_url: https://api-sandbox.poundpay.com
|
23
24
|
|
24
25
|
production:
|
25
26
|
developer_sid: DV8dd93f0f3c6411e0863f00264a09ff3c
|
26
27
|
auth_token: d8c4ea1bafd3fcac8c1062a72c22bcdb09321deb1041df257165cd6449def0de
|
28
|
+
callback_url: http://www.awesomemarketplace.com/payments/callback
|
27
29
|
|
28
30
|
4. Create the file config/initializers/poundpay.rb and add the following
|
29
31
|
|
@@ -75,11 +77,4 @@ Poundpay is a payments platform for marketplaces
|
|
75
77
|
payment = Poundpay::Payment.find(payment_sid)
|
76
78
|
payment.escrow # AUTHORIZED -> ESCROWED. Credit card is charged
|
77
79
|
payment.release # ESCROWED -> RELEASED. Recipient receives money
|
78
|
-
payment.cancel # ESCROWED -> CANCELED. Payer receives refund
|
79
|
-
|
80
|
-
|
81
|
-
== Setting callback url
|
82
|
-
|
83
|
-
me = Poundpay::Developer.me
|
84
|
-
me.callback_url = "http://awesomemarketplace.com/poundpay/callback"
|
85
|
-
me.save!
|
80
|
+
payment.cancel # ESCROWED -> CANCELED. Payer receives refund
|
data/lib/poundpay/version.rb
CHANGED
data/lib/poundpay.rb
CHANGED
@@ -11,6 +11,7 @@ module Poundpay
|
|
11
11
|
|
12
12
|
class << self
|
13
13
|
attr_writer :api_version
|
14
|
+
attr_accessor :callback_url
|
14
15
|
|
15
16
|
def configure(developer_sid, auth_token)
|
16
17
|
warn "warning: Poundpay is already configured" if configured?
|
@@ -30,6 +31,13 @@ module Poundpay
|
|
30
31
|
Resource.user = developer_sid
|
31
32
|
Resource.password = auth_token
|
32
33
|
@configured = true
|
34
|
+
|
35
|
+
# Set callback_url if defined in configuration
|
36
|
+
if callback_url
|
37
|
+
@me = Developer.me
|
38
|
+
@me.callback_url = callback_url
|
39
|
+
@me.save!
|
40
|
+
end
|
33
41
|
end
|
34
42
|
|
35
43
|
def configure_from_hash(config)
|
@@ -37,6 +45,7 @@ module Poundpay
|
|
37
45
|
c.www_url = config["www_url"] || WWW_URL
|
38
46
|
c.api_url = config["api_url"] || API_URL
|
39
47
|
c.api_version = config["api_version"] || API_VERSION
|
48
|
+
c.callback_url = config["callback_url"] || nil
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
@@ -44,6 +53,7 @@ module Poundpay
|
|
44
53
|
@www_url = nil
|
45
54
|
@api_url = nil
|
46
55
|
@api_version = nil
|
56
|
+
@callback_url = nil
|
47
57
|
Resource.site = nil
|
48
58
|
Resource.user = nil
|
49
59
|
Resource.password = nil
|
data/spec/poundpay_spec.rb
CHANGED
@@ -56,6 +56,17 @@ describe Poundpay do
|
|
56
56
|
Poundpay.api_url.should == "https://api-sandbox.poundpay.com"
|
57
57
|
Poundpay.api_version.should == "gold"
|
58
58
|
end
|
59
|
+
|
60
|
+
it "should configure callback_url" do
|
61
|
+
callback_url = "http://awesomemarketplace.com/payments/callback"
|
62
|
+
@developer = Poundpay::Developer.new
|
63
|
+
@developer.should_receive(:save!)
|
64
|
+
Poundpay::Developer.should_receive(:me).and_return(@developer)
|
65
|
+
Poundpay.configure("DV0383d447360511e0bbac00264a09ff3c", "c31155b9f944d7aed204bdb2a253fef13b4fdcc6ae1540200449cc4526b2381a") do |c|
|
66
|
+
c.callback_url = callback_url
|
67
|
+
end
|
68
|
+
@developer.callback_url.should == callback_url
|
69
|
+
end
|
59
70
|
end
|
60
71
|
|
61
72
|
describe ".configure_from_hash" do
|
@@ -104,6 +115,16 @@ describe Poundpay do
|
|
104
115
|
it "should not accept an invalid configuration" do
|
105
116
|
expect { Poundpay.configure_from_hash @config["invalid"] }.to raise_error(ArgumentError)
|
106
117
|
end
|
118
|
+
|
119
|
+
it "should configure callback_url" do
|
120
|
+
config = @config["production"]
|
121
|
+
config["callback_url"] = "http://awesomemarketplace.com/payments/callback"
|
122
|
+
@developer = Poundpay::Developer.new
|
123
|
+
@developer.should_receive(:save!)
|
124
|
+
Poundpay::Developer.should_receive(:me).and_return(@developer)
|
125
|
+
Poundpay.configure_from_hash config
|
126
|
+
@developer.callback_url.should == config["callback_url"]
|
127
|
+
end
|
107
128
|
end
|
108
129
|
|
109
130
|
describe ".clear_config!" do
|