pesapal 1.0.0 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b77c7352914478f5db52c64dd9e5611cd9c8652
4
- data.tar.gz: 382a808b6a1d6464587477cd0ab30aa4c6e53b5b
3
+ metadata.gz: 0f47532ca078e1d0e6b8c6fb305548d86266ce79
4
+ data.tar.gz: 53f602f715e320d6a71bdad0bca49d1fd68a1f75
5
5
  SHA512:
6
- metadata.gz: 74576337022966c7ae613394507be8f2a4d1611fee53067430b80ae7d2376a8c34acb21cf933ab6c9f8697c119892c3608b17e9fd4604c59977fea2c6dd4e646
7
- data.tar.gz: 35fe01d3f3a0dbe097474e85710e65862f14a041ea5726df5c21ff2f1c13e94796b7ea07036acca4b800f672f034f4572481126939cdd0ea1bc8c680c6c7ea5f
6
+ metadata.gz: ab791fe5a5e3f889cbb2f40ff13aca5dc707bde0b9eb0e1db82a85d5dff0d103027a95de8d144c37081760382f41abd77649eb057a6cd46333a10e0b308e7aef
7
+ data.tar.gz: 32183c04ac5bfd5faa4dd85e607d19105d7fbffb1ff897ed23b8434af64f780ae5afb1dec5fb8f95b50b8b328ac880b101677a850ce6a0e68898169363bb4fce
data/README.md CHANGED
@@ -35,7 +35,8 @@ Or install it yourself as:
35
35
 
36
36
  $ gem install pesapal
37
37
 
38
- For Rails, you need to run the generator to set up some necessary stuff:
38
+ For Rails, you need to run the generator to set up some necessary stuff (create
39
+ initializer and config.yml file):
39
40
 
40
41
  rails generate pesapal:install
41
42
 
@@ -91,7 +92,7 @@ override, there's the assumption that you chose the right one).
91
92
 
92
93
  ```ruby
93
94
  # set pesapal api configuration manually (override YAML & bogus credentials)
94
- pesapal.config = { :callback_url => 'http://0.0.0.0:3000/pesapal/callback'
95
+ pesapal.config = { :callback_url => 'http://0.0.0.0:3000/pesapal/callback',
95
96
  :consumer_key => '<YOUR_CONSUMER_KEY>',
96
97
  :consumer_secret => '<YOUR_CONSUMER_SECRET>'
97
98
  }
@@ -196,14 +197,40 @@ The result is a hash that looks something like this ...
196
197
 
197
198
  ```
198
199
  {
199
- :method=>"MPESA",
200
- :status=>"COMPLETED",
201
- :merchant_reference=>"<MERCHANT_REFERENCE>",
202
- :transaction_tracking_id=>"<TRANSACTION_ID>"
200
+ :method => "<PAYMENT_METHOD>",
201
+ :status => "<PAYMENT_STATUS>",
202
+ :merchant_reference => "<MERCHANT_REFERENCE>",
203
+ :transaction_tracking_id => "<TRANSACTION_ID>"
203
204
  }
204
205
  ```
205
206
 
206
207
 
208
+ ### IPN Listening ###
209
+
210
+ Use the `ipn_listener` method to listen to Pesapal IPN calls to easily create an
211
+ appropriate response, example below.
212
+
213
+ ```ruby
214
+ # pass in the notification type, merchant reference and transaction id
215
+ response_to_ipn = pesapal.ipn_listener("<NOTIFICATION_TYPE>", "<MERCHANT_REFERENCE>","<TRANSACTION_ID>")
216
+ ```
217
+
218
+ The variable, `response_to_ipn`, now holds a response as the one shown below.
219
+ Using the status you can customise any actions (e.g. database inserts and
220
+ updates) and finally, it's upto you to send the `:response` back to pesapal. The
221
+ hard part is done for you.
222
+
223
+ ```
224
+ {
225
+ :status => "<PAYMENT_STATUS>",
226
+ :response => "<IPN_RESPONSE>"
227
+ }
228
+ ```
229
+
230
+ _Ps: Refer to Pesapal official documentation to make sure you understand what
231
+ data Pesapal sends to IPN and what result they expect back._
232
+
233
+
207
234
  Contributing
208
235
  ------------
209
236
 
@@ -133,6 +133,24 @@ module Pesapal
133
133
  set_endpoints
134
134
  end
135
135
 
136
+ # listen to ipn response
137
+ def ipn_listener(notification_type, merchant_reference, transaction_tracking_id)
138
+
139
+ status = query_payment_status(merchant_reference, transaction_tracking_id)
140
+
141
+ output = { :status => status }
142
+
143
+ if status == "COMPLETED"
144
+ output[:response] = "pesapal_notification_type=CHANGE&pesapal_transaction_tracking_id=#{transaction_tracking_id}&pesapal_merchant_reference=#{merchant_reference}"
145
+ elsif status == "FAILED"
146
+ output[:response] = "pesapal_notification_type=CHANGE&pesapal_transaction_tracking_id=#{transaction_tracking_id}&pesapal_merchant_reference=#{merchant_reference}"
147
+ else
148
+ output[:response] = ""
149
+ end
150
+
151
+ output
152
+ end
153
+
136
154
  private
137
155
 
138
156
  # set endpoints
@@ -1,3 +1,3 @@
1
1
  module Pesapal
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
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: 1.0.0
4
+ version: 1.1.0
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-13 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler