Class: ActiveMerchant::Billing::PayuInGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/payu_in.rb

Constant Summary collapse

TEST_INFO_URL =
"https://test.payu.in/merchant/postservice.php?form=2"
LIVE_INFO_URL =
"https://info.payu.in/merchant/postservice.php?form=2"

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ PayuInGateway

Returns a new instance of PayuInGateway.



19
20
21
22
# File 'lib/active_merchant/billing/gateways/payu_in.rb', line 19

def initialize(options={})
  requires!(options, :key, :salt)
  super
end

Instance Method Details

#purchase(money, payment, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/active_merchant/billing/gateways/payu_in.rb', line 24

def purchase(money, payment, options={})
  requires!(options, :order_id)

  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment)
  add_addresses(post, options)
  add_customer_data(post, options)
  add_auth(post)

  MultiResponse.run do |r|
    r.process{commit(url("purchase"), post)}
    if(r.params["enrolled"].to_s == "0")
      r.process{commit(r.params["post_uri"], r.params["form_post_vars"])}
    else
      r.process{handle_3dsecure(r)}
    end
  end
end

#refund(money, authorization, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/active_merchant/billing/gateways/payu_in.rb', line 44

def refund(money, authorization, options={})
  raise ArgumentError, "Amount is required" unless money

  post = {}

  post[:command] = "cancel_refund_transaction"
  post[:var1] = authorization
  post[:var2] = generate_unique_id
  post[:var3] = amount(money)

  add_auth(post, :command, :var1)

  commit(url("refund"), post)
end

#scrub(transcript) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/active_merchant/billing/gateways/payu_in.rb', line 63

def scrub(transcript)
  transcript.
    gsub(/(ccnum=)[^&\n"]*(&|\n|"|$)/, '\1[FILTERED]\2').
    gsub(/(ccvv=)[^&\n"]*(&|\n|"|$)/, '\1[FILTERED]\2').
    gsub(/(card_hash=)[^&\n"]*(&|\n|"|$)/, '\1[FILTERED]\2').
    gsub(/(ccnum":")[^"]*(")/, '\1[FILTERED]\2').
    gsub(/(ccvv":")[^"]*(")/, '\1[FILTERED]\2')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/active_merchant/billing/gateways/payu_in.rb', line 59

def supports_scrubbing?
  true
end