Sha256: 443ba47310a2bd292db8121022623cd237ddcc2aa9e687ae09a5d7d4b8f23a40

Contents?: true

Size: 1.65 KB

Versions: 3

Compression:

Stored size: 1.65 KB

Contents

require 'rubygems'
require 'yaml'
require 'authorizenet' 
require 'securerandom'

  include AuthorizeNet::API

  def get_accept_customer_profile_page(api_login_id,api_transaction_key,iframeCommunicatorUrl,customerProfileId = '37696245')
    config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")

    transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
    
    setting = SettingType.new
    setting.settingName = SettingNameEnum::HostedProfileReturnUrl
    setting.settingValue = "https://returnurl.com/return/"

    setting1 = SettingType.new
    setting1.settingName = SettingNameEnum::hostedProfileIFrameCommunicatorUrl
    setting1.settingValue = iframeCommunicatorUrl
    
    settings = Settings.new([setting,setting1])
    
    
    request = GetHostedProfilePageRequest.new
    request.customerProfileId = customerProfileId
    request.refId = ""
    request.hostedProfileSettings = settings
    
    response = transaction.get_hosted_profile_page(request)
    
    if response.messages.resultCode == MessageTypeEnum::Ok
      puts "Successfully got Accept Customer page token."
      puts "  Response code: #{response.messages.messages[0].code}"
      puts "  Response message: #{response.messages.messages[0].text}"
      puts "  Token: #{response.token}"
    else
      puts "#{response.messages.messages[0].code}"
      puts "#{response.messages.messages[0].text}"
      raise "Failed to get hosted profile page with customer profile ID #{request.customerProfileId}"
    end
    return response
  end
  
if __FILE__ == $0
  get_accept_customer_profile_page()
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authorizenetsample-0.7 lib/CustomerProfiles/get-accept-customer-profile-page.rb
authorizenetsample-0.6 lib/CustomerProfiles/get-accept-customer-profile-page.rb
authorizenetsample-0.5 lib/CustomerProfiles/get-accept-customer-profile-page.rb