README.md in pesapal-1.0.0 vs README.md in pesapal-1.1.0
- old
+ new
@@ -33,11 +33,12 @@
Or install it yourself as:
$ gem install pesapal
-For Rails, you need to run the generator to set up some necessary stuff:
+For Rails, you need to run the generator to set up some necessary stuff (create
+initializer and config.yml file):
rails generate pesapal:install
Usage
@@ -89,11 +90,11 @@
Pesapal provides different keys for different modes and since this is like an
override, there's the assumption that you chose the right one).
```ruby
# set pesapal api configuration manually (override YAML & bogus credentials)
-pesapal.config = { :callback_url => 'http://0.0.0.0:3000/pesapal/callback'
+pesapal.config = { :callback_url => 'http://0.0.0.0:3000/pesapal/callback',
:consumer_key => '<YOUR_CONSUMER_KEY>',
:consumer_secret => '<YOUR_CONSUMER_SECRET>'
}
```
@@ -194,15 +195,41 @@
The result is a hash that looks something like this ...
```
{
- :method=>"MPESA",
- :status=>"COMPLETED",
- :merchant_reference=>"<MERCHANT_REFERENCE>",
- :transaction_tracking_id=>"<TRANSACTION_ID>"
+ :method => "<PAYMENT_METHOD>",
+ :status => "<PAYMENT_STATUS>",
+ :merchant_reference => "<MERCHANT_REFERENCE>",
+ :transaction_tracking_id => "<TRANSACTION_ID>"
}
```
+
+
+### IPN Listening ###
+
+Use the `ipn_listener` method to listen to Pesapal IPN calls to easily create an
+appropriate response, example below.
+
+```ruby
+# pass in the notification type, merchant reference and transaction id
+response_to_ipn = pesapal.ipn_listener("<NOTIFICATION_TYPE>", "<MERCHANT_REFERENCE>","<TRANSACTION_ID>")
+```
+
+The variable, `response_to_ipn`, now holds a response as the one shown below.
+Using the status you can customise any actions (e.g. database inserts and
+updates) and finally, it's upto you to send the `:response` back to pesapal. The
+hard part is done for you.
+
+```
+{
+ :status => "<PAYMENT_STATUS>",
+ :response => "<IPN_RESPONSE>"
+}
+```
+
+_Ps: Refer to Pesapal official documentation to make sure you understand what
+data Pesapal sends to IPN and what result they expect back._
Contributing
------------