pesapal 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44aef97bfcafb5b7ce0a7db59a613eccb7dbacd7
4
- data.tar.gz: 87b26cead15de174dffe376207ba2c788483b38a
3
+ metadata.gz: 8166e77a88a3f62b22458f737b9342b1750aa18d
4
+ data.tar.gz: d95d4174f1b2b324b08c9a3a611d7a187e915d05
5
5
  SHA512:
6
- metadata.gz: 47c85fc5ae2a65a9158bda4ec6966ea0ddd3836e8d0e2a3fc9d223e3aef8780a82c8473beb8e7881a85c1eb9dfe99e08304c6c7fa6a403e127129e97465904a9
7
- data.tar.gz: 59e945655938a5a6def127f44eae00c4c3b75727348e43602605495a98bdbd0fb7cf635e24e0523c5bdbc4abb7505bac7d5b41bd87309a5fff384f319d7bf2e5
6
+ metadata.gz: 23618f43a0a739ff6871a1f1dba80324b6cad7de1f8006c13c651708792c3d7ba2d3fdea0f608a10e95a3fef8b5d4c52c16ca10e494da704bce922dbef6159e9
7
+ data.tar.gz: a833ad55d35d4c83b736ec708d4e4e4762565ca1d0d2a044059d099b4ef7479c0b54b26e33d370cf555e81140fd64a62791937fd1feda9aa61b9502a85103a15
data/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ Changelog
2
+ =========
3
+
4
+ v0.2.0
5
+ ------
6
+
7
+ * Fix syntax error, and incorrect config hash name
8
+ * Add pesapal config file generator
9
+ * Move loading YAML config to initializer instead of each time the object is initialized
10
+
11
+ v0.1.0
12
+ ------
13
+
14
+ * Add configuration with YAML file functionality, fall back to default, previous method still applies
15
+ * Move callback details to config hash (breaking change)
16
+
17
+ v0.0.3
18
+ ------
19
+
20
+ * Fix screwed up the specifying of dependencies
21
+
22
+ v0.0.2
23
+ ------
24
+
25
+ * Add dependencies htmlentities
26
+ * Update homepage url in rubygem
27
+ * Update to README
28
+
29
+ v0.0.1
30
+ ------
31
+
32
+ Initial release, kind of a proof of concept ... by v1.0.0 we should have a
33
+ version ready for deployment in production environment and having all those
34
+ other features that should be there at bare minimum such IPN stuff and all. Also
35
+ by then, the demo (in rails) should have been complete.
36
+
37
+ * Transparently handles authentication on API calls
38
+ * Has method to generate post-order-url with ease i.e. that url that has the various payment options and whatnot
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -40,6 +40,10 @@ Or install it yourself as:
40
40
 
41
41
  $ gem install pesapal
42
42
 
43
+ For Rails, you need to run the generator to set up some necessary stuff:
44
+
45
+ rails generate pesapal:install
46
+
43
47
 
44
48
  Usage
45
49
  -----
@@ -56,19 +60,22 @@ with the testing or the live Pesapal API.
56
60
  pesapal = Pesapal::Merchant.new(:development)
57
61
  ```
58
62
 
59
- You can set the configuration details from a YAML file at the location of
60
- your choice upon initialization as shown in the example below for a Rails app.
61
- The second parameter is optional and has a default value of
62
- `"#{Rails.root}/config/pesapal.yml"` if left out as in the example above.
63
+ You can set the configuration details from a YAML file at the location of your
64
+ choice upon initialization as shown in the example below for a Rails app. The
65
+ second parameter is optional and has a default value of
66
+ `"#{Rails.root}/config/pesapal.yml"` if left out as in the example above. In
67
+ this case, please note that this YAML file is only loaded when your application
68
+ starts and not everytime an object is initialized.
63
69
 
64
70
  ```ruby
65
71
  # initiate pesapal object set to development mode and use the YAML file found at
66
- # the specified location
72
+ # the specified location ... this overrides and loads the YAML file afresh
67
73
  pesapal = Pesapal::Merchant.new(:development, "<PATH_TO_YAML_FILE>")
68
74
  ```
69
75
 
70
- And the YAML file should look something like this. Feel free to change to the
71
- appropriate values.
76
+ The YAML file should look something like this. If you ran the generator you
77
+ should have it already in place with some default values. Feel free to change
78
+ them appropriately.
72
79
 
73
80
  ```yaml
74
81
  development:
@@ -153,12 +160,15 @@ Contributing
153
160
  4. Push to the branch (`git push origin BRANCH_NAME`)
154
161
  5. Create new pull request and we can [have the conversations here][17]
155
162
 
163
+ _Ps: See [current contributors][19]._
164
+
156
165
 
157
166
  References
158
167
  ----------
159
168
 
160
169
  * [oAuth 1.0 Spec][1]
161
170
  * [Developing a RubyGem using Bundler][2]
171
+ * [RailsGuides][20]
162
172
  * [Make your own gem][3]
163
173
  * [Pesapal API Reference (Official)][4]
164
174
  * [Pesapal Step-By-Step Reference (Official)][18]
@@ -190,3 +200,5 @@ they want as long as they provide attribution and waive liability.
190
200
  [16]: http://kingori.co/articles/2013/09/modus-operandi/
191
201
  [17]: https://github.com/itsmrwave/pesapal-rubygem/pulls
192
202
  [18]: http://developer.pesapal.com/how-to-integrate/step-by-step
203
+ [19]: https://github.com/itsmrwave/pesapal-rubygem/graphs/contributors
204
+ [20]: http://guides.rubyonrails.org/
data/Rakefile CHANGED
File without changes
@@ -0,0 +1,21 @@
1
+ module Pesapal
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Creates a Pesapal config file to your application."
7
+
8
+ def copy_config
9
+ copy_file "pesapal.yml", "config/pesapal.yml"
10
+ end
11
+
12
+ def copy_initializer
13
+ copy_file "pesapal.rb", "config/initializers/pesapal.rb"
14
+ end
15
+
16
+ def show_readme
17
+ readme "README.md" if behavior == :invoke
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+
2
+ How To Use Config File
3
+ ----------------------
4
+
5
+ The Pesapal config file is in YAML format and looks something like this. Change
6
+ the values appropriately.
7
+
8
+ ```
9
+ development:
10
+ callback_url: 'http://0.0.0.0:3000/pesapal/callback'
11
+ consumer_key: '<YOUR_CONSUMER_KEY>'
12
+ consumer_secret: '<YOUR_CONSUMER_SECRET>'
13
+
14
+ production:
15
+ callback_url: 'http://1.2.3.4:3000/pesapal/callback'
16
+ consumer_key: '<YOUR_CONSUMER_KEY>'
17
+ consumer_secret: '<YOUR_CONSUMER_SECRET>'
18
+ ```
19
+
20
+ The config file can be found at `#{Rails.root}/config/pesapal.yml`.
21
+
@@ -0,0 +1,7 @@
1
+ # Load Pesapal config file when applicatin is loaded ... the config can then be
2
+ # accessed from PesapalRails::Application.config.yaml
3
+ module PesapalRails
4
+ class Application < Rails::Application
5
+ config.yaml = YAML::load(IO.read("#{Rails.root}/config/pesapal.yml"))
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ development:
2
+ callback_url: 'http://0.0.0.0:3000/pesapal/callback'
3
+ consumer_key: '<YOUR_CONSUMER_KEY>'
4
+ consumer_secret: '<YOUR_CONSUMER_SECRET>'
5
+
6
+ production:
7
+ callback_url: 'http://1.2.3.4:3000/pesapal/callback'
8
+ consumer_key: '<YOUR_CONSUMER_KEY>'
9
+ consumer_secret: '<YOUR_CONSUMER_SECRET>'
data/lib/pesapal.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "rails"
1
2
  require "htmlentities"
2
3
  require "pesapal/merchant"
3
4
  require "pesapal/merchant/post"
@@ -1,5 +1,5 @@
1
1
  module Pesapal
2
-
2
+
3
3
  class Merchant
4
4
 
5
5
  attr_accessor :config, :order_details
@@ -42,7 +42,7 @@ module Pesapal
42
42
  public
43
43
 
44
44
  # constructor
45
- def initialize(mode = :development, path_to_file = "#{Rails.root}/config/pesapal.yml")
45
+ def initialize(mode = :development, path_to_file = nil)
46
46
 
47
47
  # initialize
48
48
  @params = nil
@@ -52,8 +52,14 @@ module Pesapal
52
52
  # convert symbol to string and downcase
53
53
  @mode = "#{mode.to_s.downcase}"
54
54
 
55
- # set the credentials
56
- set_configuration_from_yaml path_to_file
55
+ # set the credentials if we have not set a custom path for the YAML config file
56
+ if path_to_file.nil?
57
+ # no path to file so no YAML override so we load from initializer
58
+ set_configuration PesapalRails::Application.config.yaml[@mode]
59
+ else
60
+ # we have custom path so we load from file
61
+ set_configuration_from_yaml path_to_file
62
+ end
57
63
 
58
64
  # set api endpoints depending on the mode
59
65
  set_endpoints
@@ -67,10 +73,10 @@ module Pesapal
67
73
  @post_xml = Pesapal::Post::generate_post_xml @order_details
68
74
 
69
75
  # initialize setting of @params (oauth_signature left empty) ... this gene
70
- @params = Pesapal::Post::set_parameters(@credentials[:callback_url], @credentials[:consumer_key], @post_xml)
76
+ @params = Pesapal::Post::set_parameters(@config[:callback_url], @config[:consumer_key], @post_xml)
71
77
 
72
78
  # generate oauth signature and add signature to the request parameters
73
- @params[:oauth_signature] = Pesapal::Oauth::generate_oauth_signature("GET", @api_endpoints[:postpesapaldirectorderv4], @params, @credentials[:consumer_secret], @token_secret)
79
+ @params[:oauth_signature] = Pesapal::Oauth::generate_oauth_signature("GET", @api_endpoints[:postpesapaldirectorderv4], @params, @config[:consumer_secret], @token_secret)
74
80
 
75
81
  # change params (with signature) to a query string
76
82
  query_string = Pesapal::Oauth::generate_encoded_params_query_string @params
@@ -100,9 +106,9 @@ module Pesapal
100
106
  def set_configuration(consumer_details = {})
101
107
 
102
108
  # set the configuration
103
- @config = { :callback_url => 'http://0.0.0.0:3000/pesapal/callback'
109
+ @config = { :callback_url => 'http://0.0.0.0:3000/pesapal/callback',
104
110
  :consumer_key => '<YOUR_CONSUMER_KEY>',
105
- :consumer_secret => '<YOUR_CONSUMER_SECRET>'
111
+ :consumer_secret => '<YOUR_CONSUMER_SECRET>'
106
112
  }
107
113
 
108
114
  valid_config_keys = @config.keys
@@ -133,7 +139,7 @@ module Pesapal
133
139
 
134
140
  # in this case default values will be set
135
141
  set_configuration
136
- end
142
+ end
137
143
  end
138
144
  end
139
145
  end
File without changes
data/lib/pesapal/oauth.rb CHANGED
File without changes
@@ -1,3 +1,3 @@
1
1
  module Pesapal
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/pesapal.gemspec CHANGED
@@ -5,7 +5,7 @@ require "pesapal/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "pesapal"
7
7
  spec.version = Pesapal::VERSION
8
- spec.date = "2013-10-01"
8
+ spec.date = "2013-10-13"
9
9
  spec.authors = ["Job King'ori Maina"]
10
10
  spec.email = ["j@kingori.co"]
11
11
  spec.description = "Make authenticated Pesapal API calls without the fuss!"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pesapal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Job King'ori Maina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-01 00:00:00.000000000 Z
11
+ date: 2013-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,10 +60,15 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - .gitignore
63
+ - CHANGELOG.md
63
64
  - Gemfile
64
65
  - LICENSE.txt
65
66
  - README.md
66
67
  - Rakefile
68
+ - lib/generators/pesapal/install_generator.rb
69
+ - lib/generators/templates/README.md
70
+ - lib/generators/templates/pesapal.rb
71
+ - lib/generators/templates/pesapal.yml
67
72
  - lib/pesapal.rb
68
73
  - lib/pesapal/merchant.rb
69
74
  - lib/pesapal/merchant/post.rb
@@ -90,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
95
  version: '0'
91
96
  requirements: []
92
97
  rubyforge_project:
93
- rubygems_version: 2.1.5
98
+ rubygems_version: 2.1.8
94
99
  signing_key:
95
100
  specification_version: 4
96
101
  summary: Make authenticated Pesapal API calls without the fuss! Handles all the oAuth