paysio 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.rdoc +4 -1
- data/VERSION +1 -1
- data/lib/paysio/form.rb +43 -0
- data/lib/paysio/version.rb +1 -1
- data/lib/paysio.rb +8 -2
- metadata +3 -2
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.8
|
data/lib/paysio/form.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Paysio
|
2
|
+
class Form
|
3
|
+
attr_accessor :params, :values, :errors, :html_options
|
4
|
+
|
5
|
+
def initialize(params = {})
|
6
|
+
@params = options[:params]
|
7
|
+
@values = {}
|
8
|
+
@errors = {}
|
9
|
+
@html_options = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_params(params = {})
|
13
|
+
self.params.merge!(params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def render
|
17
|
+
"#{render_html} #{render_javascript}".html_safe
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_javascript
|
21
|
+
html = <<-TEXT
|
22
|
+
<script type="text/javascript">
|
23
|
+
Paysio.setEndpoint('#{Paysio.api_url}');
|
24
|
+
Paysio.setPublishableKey("#{Paysio.publishable_key}");
|
25
|
+
Paysio.form.build(#{javascript_form_params});
|
26
|
+
</script>
|
27
|
+
TEXT
|
28
|
+
end
|
29
|
+
|
30
|
+
def render_html
|
31
|
+
html = <<-TEXT
|
32
|
+
<form id="#{@html_options[:id] || 'paysio'}" class="#{@html_options[:class]}"></form>
|
33
|
+
TEXT
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def javascript_form_params
|
38
|
+
params_html = "$('##{@html_options[:id]}'), #{@params.to_json}, #{@values.to_json}"
|
39
|
+
params_html << ", #{@errors.to_json}" if @errors.present?
|
40
|
+
params_html
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/paysio/version.rb
CHANGED
data/lib/paysio.rb
CHANGED
@@ -10,6 +10,7 @@ require 'paysio/client'
|
|
10
10
|
require 'paysio/json'
|
11
11
|
require 'paysio/resource'
|
12
12
|
require 'paysio/version'
|
13
|
+
require 'paysio/form'
|
13
14
|
|
14
15
|
# actions
|
15
16
|
require 'paysio/actions/list'
|
@@ -36,9 +37,14 @@ module Paysio
|
|
36
37
|
@@api_key = nil
|
37
38
|
@@api_base = 'api.paysio.com'
|
38
39
|
@@api_version = 'v1'
|
39
|
-
|
40
|
+
@@publishable_key = nil
|
41
|
+
mattr_accessor :api_key, :api_base, :api_version, :publishable_key
|
40
42
|
|
41
43
|
def self.api_url(path = '')
|
42
44
|
"https://#{api_key}@#{api_base}/#{api_version}#{path}"
|
43
45
|
end
|
44
|
-
|
46
|
+
|
47
|
+
def self.static_url(path = '')
|
48
|
+
"https://#{api_base}/static/#{api_version}#{path}"
|
49
|
+
end
|
50
|
+
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
|
+
version: 1.0.8
|
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-
|
12
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/paysio/actions/update.rb
|
151
151
|
- lib/paysio/client.rb
|
152
152
|
- lib/paysio/errors.rb
|
153
|
+
- lib/paysio/form.rb
|
153
154
|
- lib/paysio/json.rb
|
154
155
|
- lib/paysio/resource.rb
|
155
156
|
- lib/paysio/resources/charge.rb
|