skrill_payments 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,13 +1,4 @@
1
- # [WIP] -> WORK IN PROGRESS
2
-
3
- Plase wait day or two to next release.
4
- Next update will be 26.5.2014
5
-
6
- Thank you very much.
7
-
8
- # SkrillPayments
9
-
10
- TODO: Write a gem description
1
+ # [WIP] SkrillPayments
11
2
 
12
3
  ## Installation
13
4
 
@@ -23,15 +14,77 @@ Or install it yourself as:
23
14
 
24
15
  $ gem install skrill_payments
25
16
 
26
- Create config initializer for Skrill Payments.
17
+ Create a configuration file for Scrill Payments.
27
18
 
28
- For example, create a file config/initializers/skrill_payments.rb with following content:
19
+ $ touch config/initializers/scrill_payments.rb
29
20
 
30
- Rails.configuration.scrill_payments_email = 'michal.macejko1@gmail.com'
31
- Rails.configuration.scrill_payments_password = '3427342378427834782347832' # MD5
21
+ ```ruby
22
+ Rails.configuration.scrill_payments_email = 'michal.macejko1@gmail.com'
23
+ Rails.configuration.scrill_payments_password = '3427342378427834782347832' # MD5
24
+ ```
32
25
 
33
26
  ## Usage
34
27
 
28
+ Put this code into your Payment class.
29
+
30
+ ```ruby
31
+ include ScrillPayment
32
+ ```
33
+
34
+ Your payment class must contain all attributes/methods which is required for transfer money.
35
+
36
+ ```ruby
37
+ [:amount, :currency, :recipient_email, :subject, :note, :reference_id]
38
+ # :reference_id is optional attribute
39
+ ```
40
+
41
+ For example:
42
+
43
+ ```ruby
44
+ class Payment
45
+
46
+ include ScrillPayment
47
+
48
+ def amount
49
+ price + fees
50
+ end
51
+
52
+ def currency
53
+ bank.czech? 'CZK' : 'ENG'
54
+ end
55
+
56
+ def recipient_email
57
+ client.user
58
+ end
59
+
60
+ def subject
61
+ 'My super subject'
62
+ end
63
+
64
+ def note
65
+ 'Money for your service'
66
+ end
67
+
68
+ def reference_id
69
+ id
70
+ end
71
+
72
+ end
73
+ ```
74
+
75
+ And in your controller just put the following code:
76
+
77
+ ```ruby
78
+ def pay_for_service
79
+ payment = Payment.find(params[:id])
80
+ begin
81
+ ScrillPayment.pay!(payment)
82
+ rescue => e
83
+ # do stuff
84
+ end
85
+ redirect_to payments_path
86
+ end
87
+ ```
35
88
 
36
89
  ## Contributing
37
90
 
@@ -8,6 +8,18 @@ module SkrillPayments
8
8
  execute_transfer['transaction'][0]['status_msg'][0] == 'processed'
9
9
  end
10
10
 
11
+ class << self
12
+ attr_writer :configuration
13
+ end
14
+
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.configure
20
+ yield(configuration)
21
+ end
22
+
11
23
  end
12
24
 
13
25
  # VERSION
@@ -15,8 +27,10 @@ require 'skrill_payments/version'
15
27
 
16
28
  # GEM CLASS
17
29
  require 'skrill_payments/api'
30
+ require 'skrill_payments/scrill_payment'
18
31
  require 'skrill_payments/prepare_transfer'
19
32
  require 'skrill_payments/execute_transfer'
33
+ require 'skrill_payments/configuration'
20
34
 
21
35
  # GEMS
22
36
  require 'faraday'
@@ -29,8 +29,8 @@ class Api
29
29
 
30
30
  def default_params
31
31
  {
32
- email: Rails.configuration.scrill_payments_email,
33
- password: Rails.configuration.scrill_payments_password
32
+ email: SkrillPayments.configuration.email,
33
+ password: SkrillPayments.configuration.password
34
34
  }
35
35
  end
36
36
 
@@ -0,0 +1,6 @@
1
+ class Configuration
2
+
3
+ attr_accessor :email, :password
4
+
5
+ end
6
+
@@ -1,3 +1,3 @@
1
1
  module SkrillPayments
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec'
23
24
 
24
25
  spec.add_dependency('faraday')
25
26
  spec.add_dependency('xml-simple')
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe PrepareTransfer do
4
+
5
+ before do
6
+ @payment = Payment.new
7
+ @prepare_transfer = PrepareTransfer.new(@payment)
8
+ end
9
+
10
+ it 'returns all required params' do
11
+
12
+ @prepare_transfer.params
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,13 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'skrill_payments'
5
+
6
+ RSpec.configure do |config|
7
+ end
8
+
9
+ # SUPPORT FILES
10
+ require File.expand_path('../support/config.rb', __FILE__)
11
+ require File.expand_path('../support/payment.rb', __FILE__)
12
+
13
+
@@ -0,0 +1,4 @@
1
+ SkrillPayments.configure do |config|
2
+ config.email = 'michal.macejko1@gmail.com'
3
+ config.password = '2347237842346234623476276'
4
+ end
@@ -1,5 +1,3 @@
1
- require 'skrill_payments/scrill_payment'
2
-
3
1
  class Payment
4
2
  include ScrillPayment
5
3
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skrill_payments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: faraday
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -89,12 +105,16 @@ files:
89
105
  - Rakefile
90
106
  - lib/skrill_payments.rb
91
107
  - lib/skrill_payments/api.rb
108
+ - lib/skrill_payments/configuration.rb
92
109
  - lib/skrill_payments/execute_transfer.rb
93
- - lib/skrill_payments/payment.rb~
94
110
  - lib/skrill_payments/prepare_transfer.rb
95
111
  - lib/skrill_payments/scrill_payment.rb
96
112
  - lib/skrill_payments/version.rb
97
113
  - skrill_payments.gemspec
114
+ - spec/models/prepare_transfer_spec.rb
115
+ - spec/spec_helper.rb
116
+ - spec/support/config.rb
117
+ - spec/support/payment.rb
98
118
  homepage: ''
99
119
  licenses:
100
120
  - MIT
@@ -120,4 +140,8 @@ rubygems_version: 1.8.25
120
140
  signing_key:
121
141
  specification_version: 3
122
142
  summary: Skrill payments
123
- test_files: []
143
+ test_files:
144
+ - spec/models/prepare_transfer_spec.rb
145
+ - spec/spec_helper.rb
146
+ - spec/support/config.rb
147
+ - spec/support/payment.rb