micropayment-rails 0.1.0 → 0.1.1
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.markdown
    CHANGED
    
    | 
         @@ -11,15 +11,24 @@ gem 'micropayment-rails' 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            ## Usage
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
      
 14 
     | 
    
         
            +
            In an initializer (e.g. config/initializers/micropayment.rb):
         
     | 
| 
      
 15 
     | 
    
         
            +
            ```
         
     | 
| 
      
 16 
     | 
    
         
            +
            Micropayment.setup do |config|
         
     | 
| 
      
 17 
     | 
    
         
            +
              config.api_key = 'your api key from micropayment.de'
         
     | 
| 
      
 18 
     | 
    
         
            +
              config.sandbox = 1  # to enable sandbox mode
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
      
 20 
     | 
    
         
            +
            ```
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            Let's play with the API:
         
     | 
| 
       14 
23 
     | 
    
         
             
            ```
         
     | 
| 
       15 
24 
     | 
    
         
             
            # create a blank customer
         
     | 
| 
       16 
     | 
    
         
            -
            customer = Micropayment::Customer.create
         
     | 
| 
      
 25 
     | 
    
         
            +
            customer = Micropayment::Customer.create!
         
     | 
| 
       17 
26 
     | 
    
         | 
| 
       18 
27 
     | 
    
         
             
            # create a customer with a customer id
         
     | 
| 
       19 
     | 
    
         
            -
            customer = Micropayment::Customer.create :customerId => 'my_customer_id'
         
     | 
| 
      
 28 
     | 
    
         
            +
            customer = Micropayment::Customer.create! :customerId => 'my_customer_id'
         
     | 
| 
       20 
29 
     | 
    
         | 
| 
       21 
30 
     | 
    
         
             
            # create a customer with a bank_account
         
     | 
| 
       22 
     | 
    
         
            -
            customer = Micropayment::Customer.create :bank_account => { :bankCode => '10010010', :accountNumber => '1234567', :accountHolder => 'Jeff Winger' }
         
     | 
| 
      
 31 
     | 
    
         
            +
            customer = Micropayment::Customer.create! :bank_account => { :bankCode => '10010010', :accountNumber => '1234567', :accountHolder => 'Jeff Winger' }
         
     | 
| 
       23 
32 
     | 
    
         | 
| 
       24 
33 
     | 
    
         
             
            # access a customers bank account
         
     | 
| 
       25 
34 
     | 
    
         
             
            customer.bank_account
         
     | 
| 
         @@ -29,7 +38,7 @@ customer.bank_account = { :bankCode => '10010010', :accountNumber => '1234567', 
     | 
|
| 
       29 
38 
     | 
    
         | 
| 
       30 
39 
     | 
    
         
             
            # initiate a session
         
     | 
| 
       31 
40 
     | 
    
         
             
            # (defaults for all hash params can be set on micropayment.de)
         
     | 
| 
       32 
     | 
    
         
            -
            Micropayment::Session.create 'project_key', customer, :amount => 1000, :currency => 'EUR'
         
     | 
| 
      
 41 
     | 
    
         
            +
            Micropayment::Session.create! 'project_key', customer, :amount => 1000, :currency => 'EUR'
         
     | 
| 
       33 
42 
     | 
    
         | 
| 
       34 
43 
     | 
    
         
             
            ```
         
     | 
| 
       35 
44 
     | 
    
         | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.1. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.1.1
         
     | 
| 
         @@ -28,11 +28,11 @@ module Micropayment 
     | 
|
| 
       28 
28 
     | 
    
         
             
                  when "0"
         
     | 
| 
       29 
29 
     | 
    
         
             
                    self.new( :customerId => customerId, :freeParams => result["freeParams"] )
         
     | 
| 
       30 
30 
     | 
    
         
             
                  else
         
     | 
| 
       31 
     | 
    
         
            -
                    raise "#{result["error"]}: #{result["errorMessage"]}"
         
     | 
| 
      
 31 
     | 
    
         
            +
                    raise "Customer#find - #{result["error"]}: #{result["errorMessage"]}"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         
             
                end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                def self.create(params={})
         
     | 
| 
      
 35 
     | 
    
         
            +
                def self.create!(params={})
         
     | 
| 
       36 
36 
     | 
    
         
             
                  params.symbolized_keys!
         
     | 
| 
       37 
37 
     | 
    
         
             
                  bank_account_params = params.delete(:bank_account)
         
     | 
| 
       38 
38 
     | 
    
         
             
                  address_params      = params.delete(:address)
         
     | 
| 
         @@ -51,6 +51,12 @@ module Micropayment 
     | 
|
| 
       51 
51 
     | 
    
         
             
                  end
         
     | 
| 
       52 
52 
     | 
    
         
             
                end
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
      
 54 
     | 
    
         
            +
                def self.find_or_create_by_id(id, params={})
         
     | 
| 
      
 55 
     | 
    
         
            +
                  params.symbolized_keys!
         
     | 
| 
      
 56 
     | 
    
         
            +
                  obj = (find(id) rescue nil)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  obj ? obj : create( params.merge(:customerId => id) )
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
       54 
60 
     | 
    
         
             
                def self.session_list
         
     | 
| 
       55 
61 
     | 
    
         
             
                  # TODO wrap in an array
         
     | 
| 
       56 
62 
     | 
    
         
             
                  Micropayment::Debit.sessionList( :customerId => id )
         
     | 
| 
         @@ -7,7 +7,7 @@ module Micropayment 
     | 
|
| 
       7 
7 
     | 
    
         
             
                CREATE_METHOD     = :sessionCreate
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                def create(project, customer, params={})
         
     | 
| 
      
 10 
     | 
    
         
            +
                def 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 )
         
     | 
| 
         @@ -19,7 +19,7 @@ module Micropayment 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                def approve
         
     | 
| 
      
 22 
     | 
    
         
            +
                def approve!
         
     | 
| 
       23 
23 
     | 
    
         
             
                  result = Micropayment::Debit.sessionApprove( :sessionId => id )
         
     | 
| 
       24 
24 
     | 
    
         
             
                  case result["error"]
         
     | 
| 
       25 
25 
     | 
    
         
             
                  when "0"
         
     | 
    
        data/micropayment-rails.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = "micropayment-rails"
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.1. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.1.1"
         
     | 
| 
       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- 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = "2012-05-20"
         
     | 
| 
       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 = [
         
     | 
| 
         @@ -38,7 +38,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       38 
38 
     | 
    
         
             
              s.homepage = "http://github.com/jeanmartin/micropayment-rails"
         
     | 
| 
       39 
39 
     | 
    
         
             
              s.licenses = ["MIT"]
         
     | 
| 
       40 
40 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       41 
     | 
    
         
            -
              s.rubygems_version = "1.8. 
     | 
| 
      
 41 
     | 
    
         
            +
              s.rubygems_version = "1.8.22"
         
     | 
| 
       42 
42 
     | 
    
         
             
              s.summary = "Rails wrapper for the micropayment gem"
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
              if s.respond_to? :specification_version then
         
     | 
    
        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:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 25
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 1
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.1.1
         
     | 
| 
       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- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2012-05-20 00:00:00 Z
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       21 
21 
     | 
    
         
             
              type: :runtime
         
     | 
| 
         @@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       176 
176 
     | 
    
         
             
            requirements: []
         
     | 
| 
       177 
177 
     | 
    
         | 
| 
       178 
178 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       179 
     | 
    
         
            -
            rubygems_version: 1.8. 
     | 
| 
      
 179 
     | 
    
         
            +
            rubygems_version: 1.8.22
         
     | 
| 
       180 
180 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       181 
181 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       182 
182 
     | 
    
         
             
            summary: Rails wrapper for the micropayment gem
         
     |