Class: Transbank::Patpass::PatpassComercio::Inscription

Inherits:
Common::BaseTransaction show all
Defined in:
lib/transbank/sdk/patpass/patpass_comercio/inscription.rb

Constant Summary collapse

RESOURCES_URL =
::Transbank::Common::ApiConstants::PATPASS_ENDPOINT
START_ENDPOINT =
(RESOURCES_URL + '/patInscription').freeze
STATUS_ENDPOINT =
(RESOURCES_URL + '/status').freeze
ENVIRONMENTS =
{
  production: 'https://www.pagoautomaticocontarjetas.cl/',
  integration: 'https://pagoautomaticocontarjetasint.transbank.cl/'
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Inscription

Returns a new instance of Inscription.



15
16
17
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 15

def initialize(options)
  super
end

Class Method Details

.build_for_integration(commerce_code, api_key) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 23

def self.build_for_integration(commerce_code, api_key)
  options = Options.new(
    commerce_code,
    api_key,
    :integration
  )
  
  new(options)
end

.build_for_production(commerce_code, api_key) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 33

def self.build_for_production(commerce_code, api_key)
  options = Options.new(
    commerce_code,
    api_key,
    :production
  )
  new(options)
end

.new(options) ⇒ Object



19
20
21
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 19

def self.new(options)
  super(options)
end

Instance Method Details

#start(url, name, last_name, second_last_name, rut, service_id, final_url, max_amount, phone, cell_phone, patpass_name, person_email, commerce_email, address, city) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 42

def start(url, name, last_name, second_last_name, rut, service_id, final_url, max_amount, phone, cell_phone, patpass_name, person_email, commerce_email, address, city)
  request_service = ::Transbank::Shared::RequestService.new(
    @environment, ENVIRONMENTS[@environment] + START_ENDPOINT, @commerce_code, @api_key, @timeout, true
  )
  request_service.set_patpass();
  request_service.post({
      url: url,
      nombre: name,
      pApellido: last_name,
      sApellido: second_last_name,
      rut: rut,
      serviceId: service_id,
      finalUrl: final_url,
      commerceCode: @commerce_code,
      montoMaximo: max_amount,
      telefonoFijo: phone,
      telefonoCelular: cell_phone,
      nombrePatPass: patpass_name,
      correoPersona: person_email,
      correoComercio: commerce_email,
      direccion: address,
      ciudad: city
  })
  
end

#status(token) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 68

def status(token)
  request_service = ::Transbank::Shared::RequestService.new(
   @environment, ENVIRONMENTS[@environment] + format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key, @timeout, true
  )
  request_service.set_patpass();
  request_service.post({token: token})
end