Module: Payu

Defined in:
lib/payu.rb,
lib/payu/hash.rb,
lib/payu/http.rb,
lib/payu/client.rb,
lib/payu/errors.rb,
lib/payu/refund.rb,
lib/payu/version.rb,
lib/payu/payment_form.rb,
lib/payu/configuration.rb,
lib/payu/callback_result.rb,
lib/payu/verification_result.rb

Overview

Payu — Ruby client for PayU India payment gateway.

Usage:

client = Payu::Client.new(
key:       "your_merchant_key",
salt:      "your_merchant_salt",
test_mode: true   # use test.payu.in
)

# 1. Build the hosted-checkout redirect form (no network call)
form = client.build_payment(
txnid:       "ORDER-123",
amount:      499.00,
productinfo: "Tickets for RubyConf",
firstname:   "Jane",
email:       "jane@example.com",
phone:       "9876543210",
surl:        "https://app.example.com/payu/callback",
furl:        "https://app.example.com/payu/callback",
notify_url:  "https://app.example.com/webhooks/payu"
)
form.payment_url  # => URL to POST form.fields to (form submit or WebView)
form.fields        # => Hash of all form fields including :hash
form.to_html        # => self-contained auto-submitting checkout page

# 2. Verify an inbound callback/redirect's hash (never trust it for final state)
callback = client.verify_callback(params)
callback.valid?  # => true/false

# 3. Server-to-server reconciliation — the source of truth
result = client.verify_payment(txnid: "ORDER-123")
result.success? / result.pending? / result.failed?
result.mihpayid
result.raw        # full parsed JSON, for audit logging

form.to_html renders a complete auto-submitting checkout page — expose it from one GET route and that URL is all any client needs: redirect a browser to it, or point a mobile WebView at it. See README for details.

Defined Under Namespace

Modules: Hash Classes: ApiError, CallbackResult, Client, Configuration, ConfigurationError, HashMismatchError, Http, NetworkError, PaymentFailedError, PaymentForm, PayuError, Refund, ResponseError, ValidationError, VerificationResult

Constant Summary collapse

VERSION =
"0.2.0"