Class: Beanstream::ProfilesAPI
- Inherits:
-
Transaction
- Object
- Transaction
- Beanstream::ProfilesAPI
- Defined in:
- lib/beanstream/profiles_api.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_profile_card(profile, card) ⇒ Object
- #create_profile(profile) ⇒ Object
- #delete_profile(profileId) ⇒ Object
- #delete_profile_card(profile, card_index) ⇒ Object
- #get_profile(profileId) ⇒ Object
- #get_profile_card(profile) ⇒ Object
- #getCreateProfileWithCardTemplate ⇒ Object
- #getCreateProfileWithTokenTemplate ⇒ Object
-
#getProfileTemplate ⇒ Object
a template for a Secure Payment Profile.
- #profile_cards_url ⇒ Object
- #profile_url ⇒ Object
- #update_profile(profile) ⇒ Object
- #update_profile_card(profile, card_index, card) ⇒ Object
Methods inherited from Transaction
#encode, #handle_api_error, #handle_restclient_error, #transaction_post
Class Method Details
.profile_successfully_created(response) ⇒ Object
95 96 97 |
# 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) ⇒ Object
99 100 101 |
# File 'lib/beanstream/profiles_api.rb', line 99 def self.profile_successfully_deleted(response) success = response['code'] == 1 && response['message'] == "Operation Successful" end |
Instance Method Details
#add_profile_card(profile, card) ⇒ Object
103 104 105 106 |
# 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) ⇒ Object
72 73 74 |
# 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) ⇒ Object
76 77 78 79 |
# 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) ⇒ Object
118 119 120 121 |
# 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 |
#get_profile(profileId) ⇒ Object
81 82 83 84 |
# 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) ⇒ Object
108 109 110 111 |
# 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 |
#getCreateProfileWithCardTemplate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# 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 ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/beanstream/profiles_api.rb', line 26 def getCreateProfileWithTokenTemplate() request = getProfileTemplate() request[:token] = { :name => "", :code => "" } return request end |
#getProfileTemplate ⇒ Object
a template for a Secure Payment Profile
36 37 38 39 40 41 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 67 68 69 70 |
# 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 |
#profile_cards_url ⇒ Object
10 11 12 |
# File 'lib/beanstream/profiles_api.rb', line 10 def profile_cards_url() "#{Beanstream.api_base_url()}/profiles/cards" end |
#profile_url ⇒ Object
6 7 8 |
# File 'lib/beanstream/profiles_api.rb', line 6 def profile_url "#{Beanstream.api_base_url()}/profiles" end |
#update_profile(profile) ⇒ Object
86 87 88 89 90 91 92 93 |
# 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) ⇒ Object
113 114 115 116 |
# 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 |