class Beanstream::ProfilesAPI

Public Class Methods

profile_successfully_created(response) click to toggle source
# File lib/beanstream/profiles_api.rb, line 95
def self.profile_successfully_created(response)
  success = response['code'] == 1 && response['message'] == "Operation Successful"
end
profile_successfully_deleted(response) click to toggle source
# File lib/beanstream/profiles_api.rb, line 99
def self.profile_successfully_deleted(response)
  success = response['code'] == 1 && response['message'] == "Operation Successful"
end

Public Instance Methods

add_profile_card(profile,card) click to toggle source
# File lib/beanstream/profiles_api.rb, line 103
def add_profile_card(profile,card)
  addCardUrl = profile_url + "/" + profile['customer_code'] + "/cards/"
  val = transaction_post("POST", addCardUrl, Beanstream.merchant_id, Beanstream.profiles_api_key, card)
end
create_profile(profile) click to toggle source
# File lib/beanstream/profiles_api.rb, line 72
def create_profile(profile)
  val = transaction_post("POST", profile_url, Beanstream.merchant_id, Beanstream.profiles_api_key, profile)
end
delete_profile(profileId) click to toggle source
# File lib/beanstream/profiles_api.rb, line 76
def delete_profile(profileId)
  delUrl = profile_url+"/"+profileId
  val = transaction_post("DELETE", delUrl, Beanstream.merchant_id, Beanstream.profiles_api_key, nil)
end
delete_profile_card(profile,card_index) click to toggle source
# File lib/beanstream/profiles_api.rb, line 118
def delete_profile_card(profile,card_index)
  deleteUrl = profile_url + "/" + profile['customer_code'] + "/cards/" + card_index.to_s
  val = transaction_post("DELETE", deleteUrl, Beanstream.merchant_id, Beanstream.profiles_api_key, nil)
end
getCreateProfileWithCardTemplate() click to toggle source
# File lib/beanstream/profiles_api.rb, line 14
def getCreateProfileWithCardTemplate()
  request = getProfileTemplate()
  request[:card] = {
    :name => "",
    :number => "",
    :expiry_month => "",
    :expiry_year => "",
    :cvd => ""
  }
  return request
end
getCreateProfileWithTokenTemplate() click to toggle source
# File lib/beanstream/profiles_api.rb, line 26
def getCreateProfileWithTokenTemplate()
  request = getProfileTemplate()
  request[:token] = {
    :name => "",
    :code => ""
  }
  return request
end
getProfileTemplate() click to toggle source

a template for a Secure Payment Profile

# File lib/beanstream/profiles_api.rb, line 36
def getProfileTemplate()
  request = {
    :language=> "",
    :comments=> "",
    :billing=> {
      :name=> "",
      :address_line1=> "",
      :address_line2=> "",
      :city=> "",
      :province=> "",
      :country=> "",
      :postal_code=> "",
      :phone_number=> "",
      :email_address=> ""
    },
    :shipping=> {
      :name=> "",
      :address_line1=> "",
      :address_line2=> "",
      :city=> "",
      :province=> "",
      :country=> "",
      :postal_code=> "",
      :phone_number=> "",
      :email_address=> ""
    },
    :custom=> {
      :ref1=> "",
      :ref2=> "",
      :ref3=> "",
      :ref4=> "",
      :ref5=> ""
    }
  }
end
get_profile(profileId) click to toggle source
# File lib/beanstream/profiles_api.rb, line 81
def get_profile(profileId)
  getUrl = profile_url+"/"+profileId
  val = transaction_post("GET", getUrl, Beanstream.merchant_id, Beanstream.profiles_api_key, nil)
end
get_profile_card(profile) click to toggle source
# File lib/beanstream/profiles_api.rb, line 108
def get_profile_card(profile)
  getCardUrl = profile_url + "/" + profile['customer_code'] + "/cards/"
  val = transaction_post("get", getCardUrl, Beanstream.merchant_id, Beanstream.profiles_api_key)
end
profile_cards_url() click to toggle source
# File lib/beanstream/profiles_api.rb, line 10
def profile_cards_url()
  "#{Beanstream.api_base_url()}/profiles/cards"
end
profile_url() click to toggle source
# File lib/beanstream/profiles_api.rb, line 6
def profile_url
  "#{Beanstream.api_base_url()}/profiles"
end
update_profile(profile) click to toggle source
# File lib/beanstream/profiles_api.rb, line 86
def update_profile(profile)
  getUrl = profile_url+"/"+profile['customer_code']
  # remove card field for profile update. Card updates are done using update_profile_card()
  if (profile['card'] != nil)
    profile.tap{ |h| h.delete('card') }
  end
  val = transaction_post("PUT", getUrl, Beanstream.merchant_id, Beanstream.profiles_api_key, profile)
end
update_profile_card(profile,card_index,card) click to toggle source
# File lib/beanstream/profiles_api.rb, line 113
def update_profile_card(profile,card_index,card)
  updateUrl = profile_url + "/" + profile['customer_code'] + "/cards/" + card_index.to_s
  val = transaction_post("PUT", updateUrl, Beanstream.merchant_id, Beanstream.profiles_api_key, card)
end