Class: GpWebpay::Http::BaseSignedRequest

Inherits:
Service
  • Object
show all
Defined in:
lib/gp_webpay/http/base_signed_request.rb

Direct Known Subclasses

Services::CreateOrder, Services::VerifyCard

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes, locale, operation, merchant_number: :default, url_attributes: {}) ⇒ BaseSignedRequest

Returns a new instance of BaseSignedRequest.



19
20
21
22
23
24
25
26
27
# File 'lib/gp_webpay/http/base_signed_request.rb', line 19

def initialize(attributes, locale, operation, merchant_number: :default, url_attributes: {})
  super()
  @attributes = attributes
  @locale = locale
  @merchant_number = merchant_number
  @operation = operation
  @url_attributes = url_attributes
  @config = GpWebpay.config[@merchant_number] || GpWebpay.config.default
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



17
18
19
# File 'lib/gp_webpay/http/base_signed_request.rb', line 17

def attributes
  @attributes
end

#configObject (readonly)

Returns the value of attribute config.



17
18
19
# File 'lib/gp_webpay/http/base_signed_request.rb', line 17

def config
  @config
end

#localeObject (readonly)

Returns the value of attribute locale.



17
18
19
# File 'lib/gp_webpay/http/base_signed_request.rb', line 17

def locale
  @locale
end

#operationObject (readonly)

Returns the value of attribute operation.



17
18
19
# File 'lib/gp_webpay/http/base_signed_request.rb', line 17

def operation
  @operation
end

#url_attributesObject (readonly)

Returns the value of attribute url_attributes.



17
18
19
# File 'lib/gp_webpay/http/base_signed_request.rb', line 17

def url_attributes
  @url_attributes
end

Instance Method Details

#callObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gp_webpay/http/base_signed_request.rb', line 29

def call
  request = HttpRequest.new(
    attributes.merge(
      merchant_number: @config.merchant_number,
      operation: operation,
      url: callback_url
    )
  ).to_gpwebpay

  attrs_with_digest = payment_attributes_with_digest(request)
  uri = URI(@config.http_url)

  ExternalUrl.new(
    url: uri.to_s,
    full_url: build_full_url(uri, attrs_with_digest),
    params: attrs_with_digest
  )
end

#callback_urlObject

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/gp_webpay/http/base_signed_request.rb', line 48

def callback_url
  raise NotImplementedError
end