przelewy24_payment 0.1.2 → 0.1.3

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.
data/README.md CHANGED
@@ -26,9 +26,14 @@ And you can there "config/initializers/przelewy24_payment.rb" setup your setting
26
26
  Przelewy24Payment.setup do |config|
27
27
  config.seller_id = 'your_seller_id'
28
28
  config.language = 'pl'
29
- config.mode = :development
30
- config.error_url = 'http://localhost:3000/your_payment/comeback'
31
- config.comeback_url = 'http://localhost:3000/your_payment/comeback'
29
+ config.mode = Rails.env.to_sym # or just put :development or :production symbol
30
+ config.error_url = '/your_controller/comeback'
31
+ config.comeback_url = '/your_controller/comeback'
32
+ config.hostname = {
33
+ :development => "http://localhost:3000",
34
+ :production => "your.domain",
35
+ :staging => "staging.domain"
36
+ }
32
37
  end
33
38
  ```
34
39
 
@@ -50,6 +55,7 @@ class YourPaymentController < ApplicationController
50
55
  ...
51
56
 
52
57
  # after success payemnt this method will be trigger
58
+ # so you can do whatever you want
53
59
  def payment_success(payment_params)
54
60
  # payment_params returns hash with:
55
61
  # p24_session_id
@@ -63,7 +69,8 @@ class YourPaymentController < ApplicationController
63
69
  # payment = Payment.find_by_session_id(payment_params[:p24_session_id])
64
70
  end
65
71
 
66
- # after error payemnt this method will be trigger
72
+ # after error payment this method will be trigger
73
+ # so you can do whatever you want
67
74
  def payment_error(payment_params, code, description)
68
75
  # payment_params returns hash with:
69
76
  # p24_session_id
@@ -77,6 +84,8 @@ class YourPaymentController < ApplicationController
77
84
  # description return error description
78
85
  end
79
86
 
87
+ # method to setup params to verify it final verifyciation
88
+ # so you can do whatever you want
80
89
  def payment_verify(response_params)
81
90
  # e.g:
82
91
  # payment = Payment.find_by_session_id(response_params[:p24_session_id])
@@ -108,13 +117,13 @@ class YourPaymentController < ApplicationController
108
117
  session_id = Przelewy24Payment.friendly_token[0,20]
109
118
  value = give_your_amount
110
119
  @data = { :session_id => session_id,
111
- :description => "opis",
120
+ :description => "opis", # optional param
112
121
  :value => value,
113
- :client => 'Adam Nowak',
114
- :address => 'Powstancow 22/2',
115
- :zipcode => '53-456',
116
- :city => 'Wroclaw',
117
- :country => 'Polska',
122
+ :client => 'Adam Nowak', # optional param
123
+ :address => 'Powstancow 22/2', # optional param
124
+ :zipcode => '53-456', # optional param
125
+ :city => 'Wroclaw', # optional param
126
+ :country => 'Polska', # optional param
118
127
  :email => 'payment@example.com',
119
128
  # adding this params, you overwrite your config settings so this param is optional
120
129
  # :language => 'pl',
@@ -8,8 +8,8 @@
8
8
  = hidden_field_tag 'p24_miasto', @data[:city]
9
9
  = hidden_field_tag 'p24_kraj', @data[:country]
10
10
  = hidden_field_tag 'p24_email', @data[:email]
11
- = hidden_field_tag 'p24_return_url_ok', @data.has_key?(:comeback_url) ? @data[:comeback_url] : Przelewy24Payment.comeback_url
12
- = hidden_field_tag 'p24_return_url_error', @data.has_key?(:error_url) ? @data[:error_url] : Przelewy24Payment.error_url
11
+ = hidden_field_tag 'p24_return_url_ok', @data.has_key?(:comeback_url) ? @data[:comeback_url] : Przelewy24Payment.get_comeback_url
12
+ = hidden_field_tag 'p24_return_url_error', @data.has_key?(:error_url) ? @data[:error_url] : Przelewy24Payment.get_error_url
13
13
  = hidden_field_tag 'p24_opis', @data[:description]
14
14
  = hidden_field_tag 'p24_language', @data.has_key?(:language) ? @data[:language] : Przelewy24Payment.language
15
15
  = hidden_field_tag 'p24_crc', @data[:crc]
@@ -2,6 +2,11 @@ Przelewy24Payment.setup do |config|
2
2
  config.seller_id = 'your_seller_id'
3
3
  config.language = 'pl'
4
4
  config.mode = :development
5
- config.error_url = 'http://localhost:3000/owner_advert/comeback'
6
- config.comeback_url = 'http://localhost:3000/owner_advert/comeback'
5
+ config.error_url = '/your_controller/comeback'
6
+ config.comeback_url = '/your_controller/comeback'
7
+ config.hostname = {
8
+ :development => "http://localhost:3000",
9
+ :production => "your.domain",
10
+ :staging => "staging.domain"
11
+ }
7
12
  end
@@ -1,3 +1,3 @@
1
1
  module Przelewy24Payment
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -5,7 +5,7 @@ require "przelewy24_payment/przelewy24_payment_controller"
5
5
  module Przelewy24Payment
6
6
 
7
7
  mattr_accessor :seller_id
8
- @@seller_id = '17329'
8
+ @@seller_id = ''
9
9
 
10
10
  mattr_accessor :language
11
11
  @@language = 'pl'
@@ -22,6 +22,9 @@ module Przelewy24Payment
22
22
  mattr_accessor :crc_key
23
23
  @@crc_key = ''
24
24
 
25
+ mattr_accessor :hostname
26
+ @@hostname = { :development => "http://localhost:3000" }
27
+
25
28
  def self.setup
26
29
  yield self
27
30
  end
@@ -59,4 +62,16 @@ module Przelewy24Payment
59
62
  return calc_md5
60
63
  end
61
64
 
65
+ def self.get_hostname
66
+ @@hostname[@@mode]
67
+ end
68
+
69
+ def self.get_comeback_url
70
+ get_hostname + @@comeback_url
71
+ end
72
+
73
+ def self.get_error_url
74
+ get_hostname + @@error_url
75
+ end
76
+
62
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: przelewy24_payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
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: 2012-10-09 00:00:00.000000000 Z
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Integration with polish payment method: Przelewy24'
15
15
  email: