Sha256: eba928d5052020ec61242b07e2c2a99a7a6fc4d883456fd29f7236a3bc4b827e

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 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::HostedPaymentIFrameCommunicatorUrl
    setting1.settingValue = "#{iframeCommunicatorUrl}"
    
    settings = Settings.new([setting,setting1])
    puts "TESTING #{setting1.settingValue}"
    
    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

1 entries across 1 versions & 1 rubygems

Version Path
authorizenetsample-1.0.4 lib/CustomerProfiles/get-accept-customer-profile-page.rb