Provide a URL at which WebPAY would post back the authorization response (callback url).

POST these transaction details to WebPAY page

Once the transaction is done, query the transaction details directly from WebPAY to ensure the actual transaction amount and the transaction status.

To integrate WebPay with any rails application seamlessly we have extracted the code into WebPay Interswitch Gem. The gem provides a form helper for generating a form, which is eventually submitted to the gateway. This form helper would need a transaction reference token to uniquely identify the transaction, so we need to generate this transaction token our own and pass it to form helper along with the transaction amount. For example:

<%= form_for_webpay(txn_ref, amount) %>

The gem needs a configuration file to store WebPay’s credentials, the example configuration file can be generated by runningrails generate webpay_interswitch:install.

The Gem also provides a nice interface to query the response received at the callback url. This gives us several basic methods to test the integrity of our transaction and inspect it.

You need to pass in the transaction amount to the TransactionQuery initializer as Interswitch expects you to validate the amount of transaction to detect any tampering with the parameters by a potential attackers.