poundpay 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,16 +7,13 @@ Poundpay is a payments platform for marketplaces
7
7
 
8
8
  1. Add the following to your Gemfile
9
9
 
10
- gem 'poundpay', '~> 0.2.1'
10
+ gem 'poundpay', '~> 0.2.3'
11
11
 
12
12
  2. At the command prompt, install the gem with bundler
13
13
 
14
14
  bundle install
15
15
 
16
- 3. Create the file config/poundpay.yml and add your configurations
17
-
18
- Note: Make sure your YAML file ends with a blank line; otherwise, Ruby
19
- will give you a completely unintelligible error message
16
+ 3. Create the file config/poundpay.yml and add your configurations. Note: Make sure your YAML file ends with a blank line; otherwise, Ruby will give you a completely unintelligible error message
20
17
 
21
18
  development:
22
19
  developer_sid: DV0383d447360511e0bbac00264a09ff3c
@@ -38,47 +35,55 @@ will give you a completely unintelligible error message
38
35
 
39
36
 
40
37
  == Creating a payment
41
- Adding the payer_sid (from a previous payment), will cause the payer to see
42
- the repeat flow when they are not prompted to reenter their credit card information
43
38
 
44
- @payment = Poundpay::Payment.create(
45
- :amount => 20000,
46
- :payer_fee_amount => 0,
47
- :payer_email_address => "fred@example.com",
48
- :payer_sid => "97f51e5c38e211e08625e7af17bae06a", # Optional
49
- :recipient_fee_amount => 500,
50
- :recipient_email_address => "david@example.com",
51
- :description => "Beats by Dr. Dre",
52
- )
39
+ @payment = Poundpay::Payment.create(
40
+ :amount => 20000,
41
+ :payer_fee_amount => 0,
42
+ :payer_email_address => "fred@example.com",
43
+ :recipient_fee_amount => 500,
44
+ :recipient_email_address => "david@example.com",
45
+ :description => "Beats by Dr. Dre")
53
46
 
54
47
 
55
48
  == Serving IFRAME
56
49
 
57
- <script src="https://www.poundpay.com/js/poundpay.js"></script>
50
+ <script src="https://www.poundpay.com/js/poundpay.js"></script>
58
51
 
59
- <div id="pound-root"></div>
52
+ <div id="pound-root"></div>
60
53
 
61
- <script>
62
- function handlePaymentSuccess() {
63
- // do something
64
- }
54
+ <script>
55
+ function handlePaymentSuccess() {
56
+ // do something
57
+ }
65
58
 
66
- function handlePaymentError() {
67
- // handle error
68
- }
59
+ function handlePaymentError() {
60
+ // handle error
61
+ }
69
62
 
70
- PoundPay.init({
71
- payment_sid: <%= @payment.sid %>,
72
- success: handlePaymentSuccess,
73
- error: handlePaymentError,
74
- cardholder_name: "Fred Nietzsche", // Optional
75
- phone_number: "4085551234", // Optional
76
- server: "#{Poundpay.www_url}"
77
- });
78
- </script>
63
+ PoundPay.init({
64
+ payment_sid: "<%= @payment.sid %>",
65
+ success: handlePaymentSuccess,
66
+ error: handlePaymentError,
67
+ cardholder_name: "Fred Nietzsche", // Optional
68
+ server: "<%= Poundpay.www_url %>"
69
+ });
70
+ </script>
79
71
 
80
72
 
81
73
  == Releasing a payment
82
74
 
83
- payment = Payment.find(payment_sid)
84
- payment.release
75
+ payment = Poundpay::Payment.find(payment_sid)
76
+ payment.release
77
+
78
+
79
+ == Cancel a payment
80
+
81
+ payment = Poundpay::Payment.find(payment_sid)
82
+ payment.cancel
83
+
84
+
85
+ == Setting callback url
86
+
87
+ me = Poundpay::Developer.me
88
+ me.callback_url = "http://awesomemarketplace.com/poundpay/callback"
89
+ me.save!
@@ -5,6 +5,9 @@ require 'poundpay/resource'
5
5
  class PaymentReleaseException < Exception
6
6
  end
7
7
 
8
+ class PaymentCancelException < Exception
9
+ end
10
+
8
11
  module Poundpay
9
12
  class Developer < Resource
10
13
  def self.me
@@ -41,5 +44,14 @@ module Poundpay
41
44
  attributes['status'] = 'RELEASED'
42
45
  save
43
46
  end
47
+
48
+ def cancel
49
+ unless status == 'ESCROWED'
50
+ raise PaymentCancelException.new "Payment status is #{status}. Only ESCROWED payments may be canceled"
51
+ end
52
+
53
+ attributes['status'] = 'CANCELED'
54
+ save
55
+ end
44
56
  end
45
57
  end
@@ -1,3 +1,3 @@
1
1
  module Poundpay
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -33,5 +33,11 @@ module Poundpay
33
33
  @attributes["status"] = "RELEASED"
34
34
  @attributes
35
35
  end
36
+
37
+ def canceled_payment_attributes
38
+ @attributes = staged_payment_attributes
39
+ @attributes["status"] = "CANCELED"
40
+ @attributes
41
+ end
36
42
  end
37
43
  end
@@ -80,4 +80,19 @@ describe Payment do
80
80
  @escrowed_payment.status.should == 'RELEASED'
81
81
  end
82
82
  end
83
+
84
+ describe "#cancel" do
85
+ it "should not be able to cancel a STAGED payment" do
86
+ @staged_payment = Payment.new staged_payment_attributes
87
+ expect {@staged_payment.cancel}.to raise_error(PaymentCancelException)
88
+ end
89
+
90
+ it "should release an ESCROWED payment" do
91
+ @escrowed_payment = Payment.new escrowed_payment_attributes
92
+ @escrowed_payment.should_receive(:save).and_return(Payment.new canceled_payment_attributes)
93
+
94
+ @escrowed_payment.cancel
95
+ @escrowed_payment.status.should == 'CANCELED'
96
+ end
97
+ end
83
98
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ version: 0.2.3
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-02-20 00:00:00 -08:00
17
+ date: 2011-03-31 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency