Payment3p
Provides integration with payment gateways (MIGS initially) to perform 3-Party online payment
Installation
Add this line to your application's Gemfile:
gem 'payment_3p'
And then execute:
$ bundle
Or install it yourself as:
$ gem install payment_3p
Now run a generator to create payment_3p.yml configuration file which contains the payment gateway configurations
$ rails generate payment3p:config
Add your specific configurations for the secure secret, access code and merchant id.
That's it, you're now ready to go.
Usage
Generate the payment URL that you'll redirect your users to
Payment3p.payment_url(
vpc_MerchTxnRef: "1",
vpc_ReturnURL: "http://example.com/payment_callback",
vpc_OrderInfo: "CART_1",
vpc_Amount: "100",
)
Where
vpc_MerchTxnRef
usually contains the transaction number used to identify this transaction in your applicationvpc_ReturnURL
the callback URL with payment result, the payment gateway will redirect to this URLvpc_OrderInfo
usually contains additional order information like cart number or order id for examplevpc_Amount
is the amount in CENTS
Now validate the payment response in your callback, this validates that the response is a payment gateway response
Payment3p.validate_response(response)
Which will return a boolean indicating whether the response was validated or not
NOTE:
You still need to validate that the transaction paid through the payment gateway is the same transaction that was generated by your application, don't just rely on validating the payment gateway response there are a lot of bad people out there!!!
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request