micropayment-rails 0.1.1 → 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/Gemfile.lock CHANGED
@@ -46,7 +46,7 @@ GEM
46
46
  i18n (>= 0.4.0)
47
47
  mime-types (~> 1.16)
48
48
  treetop (~> 1.4.8)
49
- micropayment (0.1.1)
49
+ micropayment (0.1.3)
50
50
  addressable
51
51
  yajl-ruby
52
52
  mime-types (1.18)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.3
@@ -21,6 +21,28 @@ module Micropayment
21
21
  end
22
22
 
23
23
 
24
+
25
+
26
+ def update!(params={})
27
+ params.symbolized_keys!
28
+ bank_account_params = params.delete(:bank_account)
29
+ address_params = params.delete(:address)
30
+ update_params = {}.tap do |hsh|
31
+ hsh[:customerId] = id
32
+ hsh[:freeParams] = params
33
+ end
34
+ result = Micropayment::Debit.customerSet( update_params )
35
+ if result["error"] == "0"
36
+ self.bank_account = bank_account_params if bank_account_params
37
+ self.customer.address = address_params if address_params
38
+ self
39
+ else
40
+ raise "Customer#update! - #{result["error"]}: #{result["errorMessage"]}"
41
+ end
42
+ end
43
+
44
+
45
+
24
46
 
25
47
  def self.find(customerId)
26
48
  result = Micropayment::Debit.customerGet( :customerId => customerId )
@@ -47,14 +69,20 @@ module Micropayment
47
69
  customer.address = address_params if address_params
48
70
  customer
49
71
  else
50
- raise "#{result["error"]}: #{result["errorMessage"]}"
72
+ raise "Customer#create! - #{result["error"]}: #{result["errorMessage"]}"
51
73
  end
52
74
  end
53
75
 
54
76
  def self.find_or_create_by_id(id, params={})
55
77
  params.symbolized_keys!
56
78
  obj = (find(id) rescue nil)
57
- obj ? obj : create( params.merge(:customerId => id) )
79
+ obj ? obj : create!( params.merge(:customerId => id) )
80
+ end
81
+
82
+ def self.find_create_or_update_by_id(id, params={})
83
+ params.symbolized_keys!
84
+ obj = (find(id) rescue nil)
85
+ obj ? obj.update!(params) : create!( params.merge(:customerId => id) )
58
86
  end
59
87
 
60
88
  def self.session_list
@@ -7,7 +7,7 @@ module Micropayment
7
7
  CREATE_METHOD = :sessionCreate
8
8
 
9
9
 
10
- def create!(project, customer, params={})
10
+ def self.create!(project, customer, params={})
11
11
  params.symbolize_keys!
12
12
  params.merge!( :customerId => customer.id, :project => project )
13
13
  result = Micropayment::Debit.sessionCreate( params )
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "micropayment-rails"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan Schwenzien"]
12
- s.date = "2012-05-20"
12
+ s.date = "2012-05-22"
13
13
  s.description = "Use the micropayment API in your Rails project."
14
14
  s.email = "jan@general-scripting.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micropayment-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jan Schwenzien
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-20 00:00:00 Z
18
+ date: 2012-05-22 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :runtime