khipu-rails 0.0.1 → 1.3.0
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.
- checksums.yaml +7 -0
- data/README.md +57 -11
- data/app/controllers/khipu_rails/application_controller.rb +5 -0
- data/app/controllers/khipu_rails/khipu_controller.rb +23 -0
- data/app/views/khipu_rails/khipu/notification.html +2 -0
- data/app/views/layouts/khipu_rails/application.html.erb +10 -0
- data/config/khipu.pem.cer +81 -0
- data/config/khipu_dev.pem.cer +22 -0
- data/config/routes.rb +3 -0
- data/khipu-rails.gemspec +6 -4
- data/lib/khipu-rails.rb +2 -0
- data/lib/khipu_rails.rb +60 -1
- data/lib/khipu_rails/button_helper.rb +45 -34
- data/lib/khipu_rails/config.rb +25 -17
- data/lib/khipu_rails/notification_validator.rb +47 -0
- data/lib/khipu_rails/receiver.rb +17 -0
- data/lib/khipu_rails/version.rb +1 -1
- data/spec/khipu_rails/button_helper_spec.rb +200 -0
- data/spec/khipu_rails/config_spec.rb +65 -0
- data/spec/khipu_rails/notification_validator_spec.rb +64 -0
- data/spec/khipu_rails/receiver_spec.rb +26 -0
- data/spec/khipu_rails_spec.rb +52 -0
- data/spec/spec_helper.rb +1 -4
- data/vendor/assets/javascripts/atmosphere.js +3081 -0
- data/vendor/assets/javascripts/khipu.js +373 -0
- metadata +71 -35
- data/spec/khipu_rails/khipu_helpers_spec.rb +0 -104
@@ -1,104 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe KhipuRails::ButtonHelper do
|
5
|
-
before :all do
|
6
|
-
@view = ActionView::Base.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "generates a form with the action provided by khipu" do
|
10
|
-
button = Nokogiri::HTML.parse(@view.khipu_button "minimal", 2000)
|
11
|
-
form = button.css('form')
|
12
|
-
form.attribute('action').value.should == 'https://khipu.com/payment/api/createPaymentPage'
|
13
|
-
end
|
14
|
-
|
15
|
-
it "generates a form with the method post" do
|
16
|
-
button = Nokogiri::HTML.parse(@view.khipu_button "minimal", 2000)
|
17
|
-
form = button.css('form')
|
18
|
-
form.attribute('method').value.should == 'post'
|
19
|
-
end
|
20
|
-
|
21
|
-
context "given a form with minimal data was correctly generated, it" do
|
22
|
-
before :all do
|
23
|
-
@receiver_id = KhipuRails::Config.user_id
|
24
|
-
@secret = KhipuRails::Config.api_key
|
25
|
-
@button = Nokogiri::HTML.parse(@view.khipu_button "minimal", 2000)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "has an input called reciever_id" do
|
29
|
-
input = @button.css('form input[name=receiver_id]')
|
30
|
-
input.attribute('value').value.to_i.should == @receiver_id
|
31
|
-
end
|
32
|
-
|
33
|
-
it "has an input called subject" do
|
34
|
-
input = @button.css('form input[name=subject]')
|
35
|
-
input.attribute('value').value.should == 'minimal'
|
36
|
-
end
|
37
|
-
|
38
|
-
it "has an input called body" do
|
39
|
-
input = @button.css('form input[name=body]')
|
40
|
-
input.attribute('value').value.should == ''
|
41
|
-
end
|
42
|
-
|
43
|
-
it "has an input called amount" do
|
44
|
-
input = @button.css('form input[name=amount]')
|
45
|
-
input.attribute('value').value.should == '2000'
|
46
|
-
end
|
47
|
-
|
48
|
-
it "has an input called return_url" do
|
49
|
-
input = @button.css('form input[name=return_url]')
|
50
|
-
input.attribute('value').value.should == ''
|
51
|
-
end
|
52
|
-
|
53
|
-
it "has an input called cancel_url" do
|
54
|
-
input = @button.css('form input[name=cancel_url]')
|
55
|
-
input.attribute('value').value.should == ''
|
56
|
-
end
|
57
|
-
|
58
|
-
it "has an input called transaction_id" do
|
59
|
-
input = @button.css('form input[name=transaction_id]')
|
60
|
-
input.attribute('value').value.should == ''
|
61
|
-
end
|
62
|
-
|
63
|
-
it "has an input called custom" do
|
64
|
-
input = @button.css('form input[name=custom]')
|
65
|
-
input.attribute('value').value.should == ''
|
66
|
-
end
|
67
|
-
|
68
|
-
it "has an input called payer_email" do
|
69
|
-
input = @button.css('form input[name=payer_email]')
|
70
|
-
input.attribute('value').value.should == ''
|
71
|
-
end
|
72
|
-
|
73
|
-
it "has an input called picture_url" do
|
74
|
-
input = @button.css('form input[name=picture_url]')
|
75
|
-
input.attribute('value').value.should == ''
|
76
|
-
end
|
77
|
-
|
78
|
-
it "has an input called hash" do
|
79
|
-
input = @button.css('form input[name=hash]')
|
80
|
-
input.attribute('type').value.should == 'hidden'
|
81
|
-
def get_value attribute
|
82
|
-
@button.css("form input[name=#{attribute}]").attribute('value').value
|
83
|
-
end
|
84
|
-
raw = "receiver_id=#{get_value :receiver_id}&"
|
85
|
-
raw += "subject=#{get_value :subject}&"
|
86
|
-
raw += "body=#{get_value :body}&"
|
87
|
-
raw += "amount=#{get_value :amount}&"
|
88
|
-
raw += "return_url=#{get_value :return_url}&"
|
89
|
-
raw += "cancel_url=#{get_value :cancel_url}&"
|
90
|
-
raw += "custom=#{get_value :custom}&"
|
91
|
-
raw += "transaction_id=#{get_value :transaction_id}&"
|
92
|
-
raw += "picture_url=#{get_value :picture_url}&"
|
93
|
-
raw += "payer_email=#{get_value :payer_email}&"
|
94
|
-
raw += "secret=#{@secret}"
|
95
|
-
input.attribute('value').value.should == Digest::SHA1.hexdigest(raw)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "has an image submit" do
|
99
|
-
input = @button.css('form input[name=submit]')
|
100
|
-
input.attribute('type').value.should == 'image'
|
101
|
-
input.attribute('src').value.should == 'https://s3.amazonaws.com/static.khipu.com/buttons/50x25.png'
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|