Class: ActiveMerchant::Billing::PayuPolskaGateway

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

Constant Summary

Constants inherited from Gateway

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

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, #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 = {}) ⇒ PayuPolskaGateway

notify_url is the webhook callback URL



37
38
39
40
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 37

def initialize(options = {})
  requires!(options, :merchant_pos_id, :client_id, :client_secret, :notify_url)
  super
end

Instance Method Details

#app_token_from(response) ⇒ Object



51
52
53
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 51

def app_token_from(response)
  options[:app_token] = response.params['access_token']
end

#app_token_request(options) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 55

def app_token_request(options)
  {
    grant_type: 'client_credentials',
    client_id: @options[:client_id],
    client_secret: @options[:client_secret]
  }
end

#authorize(options = {}) ⇒ Object



63
64
65
66
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 63

def authorize(options = {})
  response = commit('pl/standard/user/oauth/authorize', app_token_request(options))
  app_token_from(response)
end

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



68
69
70
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 68

def capture(money, authorization, options = {})
  commit('capture', post)
end

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



42
43
44
45
46
47
48
49
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 42

def purchase(money, options = {})
  post = {}
  add_invoice(post, money, options)
  add_customer_data(post, options)

  authorize(options)
  commit('api/v2_1/orders', post)
end

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



72
73
74
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 72

def refund(money, authorization, options = {})
  commit('refund', post)
end

#scrub(transcript) ⇒ Object



91
92
93
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 91

def scrub(transcript)
  transcript
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 87

def supports_scrubbing?
  false
end

#verify(credit_card, options = {}) ⇒ Object



80
81
82
83
84
85
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 80

def verify(credit_card, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

#void(authorization, options = {}) ⇒ Object



76
77
78
# File 'lib/active_merchant/billing/gateways/payu_polska.rb', line 76

def void(authorization, options = {})
  commit('void', post)
end