pagantis-rails 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc3704efd782fd2edf709bca474f48621b151a71
4
- data.tar.gz: fab5a6e757214a35099267e80ca80f92a26cd547
3
+ metadata.gz: 1198ecab649f610f3903b593915c94f3cd5c47a2
4
+ data.tar.gz: 99a78aaab4f621d7e63d0341afc9d5afdeb96d90
5
5
  SHA512:
6
- metadata.gz: f3a2fa8fab207affdd7389c6e91618091b842d6402df86cf678875e11c46b860763a002d27f5e08f6cd6e5e2bf04352f0db373af391a6c73ef6fd970216c6cce
7
- data.tar.gz: e492cd5836ff38e1c89087231d07374f7c1db7a3cd1825bee270a076401c582b4d320ffefd1dbcb12df2aaaa57a04922f60801f3fe53f7fd59b219f7819e3322
6
+ metadata.gz: 98cc327c7d07e2428a4facc288d257b1cd2a5d6892573aebcff7519a469a53483b57153b75ad7c7f96dcd4dbf50ca5922f0c990ee1c6fa6b5c724546b17658b2
7
+ data.tar.gz: da44119d12a49981eed014162554a37495065a915def0859578f4e28cc9b4afa74fcd5edc5f060c4ccb3e5dba989b05052c917272d190cc12c4e028695b57e8f
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile.lock CHANGED
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- pagantis-rails (0.0.1)
11
+ pagantis-rails (0.0.2)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -18,7 +18,27 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ### Pagantis::Rails::Helper
22
+
23
+ Using this helper you can easily create a form of any flavour in Railsy
24
+ environments.
25
+
26
+ In the example we are using Rails and HAML:
27
+
28
+ - helper = Pagantis::Helper.new(args ...)
29
+
30
+ = form_for helper, as: :helper, url: "https://psp.pagantis.com/2/sale", method: "post" do |f|
31
+ = f.hidden_field :operation
32
+ = f.hidden_field :account_id
33
+ = f.hidden_field :signature
34
+ = f.text_field :order_id
35
+ = f.text_field :auth_method
36
+ = f.text_field :amount
37
+ = f.text_field :currency
38
+ = f.text_field :description
39
+ = f.text_field :ok_url
40
+ = f.text_field :nok_url
41
+ = f.submit 'Pay'
22
42
 
23
43
  ## Contributing
24
44
 
@@ -17,24 +17,28 @@ module Pagantis
17
17
  # = f.text_field :description
18
18
  # = f.text_field :ok_url
19
19
  # = f.text_field :nok_url
20
+ # = f.text_field :plan_id # subscription-only
21
+ # = f.text_field :user_id # subscription-only
20
22
  # = f.submit 'Pay'
23
+ #
21
24
  class Helper
22
25
  attr_reader :operation, :order_id, :auth_method, :amount, :currency, :description,
23
- :ok_url, :nok_url, :account_id, :signature
26
+ :ok_url, :nok_url, :account_id, :signature, :plan_id, :user_id
24
27
 
25
28
  def initialize(args = {})
26
- @operation = args.fetch(:operation) { nil } # empty operation equals single charge
27
- @order_id = args.fetch(:order_id)
28
- @amount = args.fetch(:amount)
29
- @currency = parse_currency args.fetch(:currency)
30
- @description = args.fetch(:description) { "" }
31
- @ok_url = args.fetch(:ok_url)
32
- @nok_url = args.fetch(:nok_url)
33
- @account_id = args.fetch(:account_id)
29
+ @operation = args.fetch(:operation) { nil } # empty operation equals single charge
30
+ @order_id = args.fetch(:order_id)
31
+ @amount = args.fetch(:amount)
32
+ @currency = parse_currency args.fetch(:currency)
33
+ @description = args.fetch(:description) { "" }
34
+ @ok_url = args.fetch(:ok_url)
35
+ @nok_url = args.fetch(:nok_url)
36
+ @account_id = args.fetch(:account_id)
37
+ @secret = args.fetch(:secret)
34
38
 
35
39
  if subscription?
36
- @plan_id = args.fetch(:plan_id)
37
- @user_id = args.fetch(:user_id)
40
+ @plan_id = args.fetch(:plan_id)
41
+ @user_id = args.fetch(:user_id)
38
42
  end
39
43
  end
40
44
 
@@ -47,10 +51,14 @@ module Pagantis
47
51
  end
48
52
 
49
53
  def signature
50
- str = @account_id + @order_id + @amount.to_s + @currency + auth_method + @ok_url + @nok_url
54
+ str = @secret + @account_id.to_s + @order_id + @amount.to_s + @currency + auth_method + @ok_url + @nok_url
51
55
  Digest::SHA1.hexdigest str
52
56
  end
53
57
 
58
+ def gateway_url
59
+ "https://psp.pagantis.com/2/sale"
60
+ end
61
+
54
62
  private
55
63
 
56
64
  def parse_currency(currency)
@@ -1,5 +1,5 @@
1
1
  module Pagantis
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagantis-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-24 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - .gitignore
63
+ - .rspec
63
64
  - Gemfile
64
65
  - Gemfile.lock
65
66
  - LICENSE
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.1.8
95
+ rubygems_version: 2.2.2
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Pagantis API On Rails