Module: Formi9::Client::B2b

Included in:
Formi9::Client
Defined in:
lib/formi9/client/b2b.rb

Instance Method Summary collapse

Instance Method Details

options =

b2b_username: 'Ryan Lyu'
company_id: 'workstreamdemo',
request_id: 'AUniqueId',
result_id: 'AUniqueId'



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/formi9/client/b2b.rb', line 15

def b2b_direct_link(options)
  string = "AlliancePartnerID=#{CGI.escape(partner_id)}"
  string << "&AlliancePartnerLogin=#{CGI.escape(username)}"
  string << "&AlliancePartnerPassword=#{CGI.escape(password)}"
  string << "&AlliancePartnerCompanyID=#{CGI.escape(options[:company_id])}"
  string << "&Target=DirectLink&B2BUserName=#{CGI.escape(options[:b2b_username])}"
  string << "&RequestID=#{CGI.escape(options[:request_id])}"
  string << "&ResultID=#{CGI.escape(options[:result_id])}&"

  data = b2b_encrypt(string)

  "https://www.formi9.com/FormI9Verify/FormI9LoginService.aspx?EPID=#{partner_id}&EDATA=#{data}"
end

#b2b_encrypt(string) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/formi9/client/b2b.rb', line 30

def b2b_encrypt(string)
  cipher = b2b_encryption_algorithm.new(b2b_encryption_cipher_mode) 
  cipher.encrypt
  cipher.key = b2b_encryption_key
  cipher.iv = b2b_encryption_iv
  encrypted_string = cipher.update(string)
  encrypted_string << cipher.final

  base64_string = Base64.strict_encode64(encrypted_string)
  escaped_data = CGI.escape(base64_string)
end