payr 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,17 +2,12 @@ class Payr::BillsController < ApplicationController
2
2
  before_filter :check_response, except: [:pay, :failure, :ipn]
3
3
  before_filter :check_ipn_response, only: [:ipn]
4
4
 
5
- UNPROCESSED = "unprocessed"
6
- PAID = "paid"
7
- REFUSED = "refused"
8
- CANCELLED = "cancelled"
9
- SIGN_ERROR = "bad_signature"
10
- NO_ERROR = "00000"
5
+
11
6
  def pay
12
7
  @bill = Payr::Bill.new(buyer_id: params[:buyer][:id],
13
8
  amount: params[:total_price],
14
9
  article_id: params[:article_id],
15
- state: UNPROCESSED,
10
+ state: Payr::Bill::UNPROCESSED,
16
11
  bill_reference: params[:bill_reference])
17
12
  @payr = Payr::Client.new
18
13
  if @bill.save
@@ -29,20 +24,20 @@ class Payr::BillsController < ApplicationController
29
24
  end
30
25
 
31
26
  def paid
32
- change_status params[:ref], PAID
27
+ change_status params[:ref], Payr::Bill::PAID
33
28
  end
34
29
 
35
30
  def refused
36
- change_status params[:ref], REFUSED, params[:error]
31
+ change_status params[:ref], Payr::Bill::REFUSED, params[:error]
37
32
  end
38
33
 
39
34
  def cancelled
40
- change_status params[:ref], CANCELLED, params[:error]
35
+ change_status params[:ref], Payr::Bill::CANCELLED, params[:error]
41
36
  end
42
37
 
43
38
  def ipn
44
- if params[:error] == NO_ERROR
45
- change_status params[:ref], PAID
39
+ if params[:error] == Payr::Bill::NO_ERROR
40
+ change_status params[:ref], Payr::Bill::PAID
46
41
  else
47
42
  @bill = Payr::Bill.find(params[:ref])
48
43
  @bill.update_attribute(:error_code, params[:error])
@@ -51,7 +46,7 @@ class Payr::BillsController < ApplicationController
51
46
  end
52
47
 
53
48
  def failure
54
- change_status params[:ref], SIGN_ERROR, params[:error]
49
+ change_status params[:ref], Payr::Bill::SIGN_ERROR, params[:error]
55
50
  end
56
51
 
57
52
  protected
@@ -1,3 +1,10 @@
1
1
  class Payr::Bill < ActiveRecord::Base
2
+ UNPROCESSED = "unprocessed"
3
+ PAID = "paid"
4
+ REFUSED = "refused"
5
+ CANCELLED = "cancelled"
6
+ SIGN_ERROR = "bad_signature"
7
+ NO_ERROR = "00000"
8
+
2
9
  attr_accessible :amount, :article_id, :buyer_id, :state, :bill_reference
3
10
  end
data/lib/payr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Payr
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.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-11-06 00:00:00.000000000 Z
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  segments:
140
140
  - 0
141
- hash: 3263532857104243643
141
+ hash: 2965356233940922850
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements:
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: 3263532857104243643
150
+ hash: 2965356233940922850
151
151
  requirements: []
152
152
  rubyforge_project:
153
153
  rubygems_version: 1.8.24