Class: AdvancedBilling::CreditCardPaymentProfile
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreditCardPaymentProfile
- Defined in:
- lib/advanced_billing/models/credit_card_payment_profile.rb
Overview
CreditCardPaymentProfile Model.
Instance Attribute Summary collapse
-
#billing_address ⇒ String
The current billing street address for the card.
-
#billing_address_2 ⇒ String
The current billing street address, second line, for the card.
-
#billing_city ⇒ String
The current billing address city for the card.
-
#billing_country ⇒ String
The current billing address country for the card.
-
#billing_state ⇒ String
The current billing address state for the card.
-
#billing_zip ⇒ String
The current billing address zip code for the card.
-
#card_type ⇒ CardType
The type of card used.
-
#chargify_token ⇒ String
Token received after sending billing information using chargify.js.
-
#current_vault ⇒ CreditCardVault
The vault that stores the payment profile with the provided ‘vault_token`.
-
#customer_id ⇒ Integer
The Chargify-assigned id for the customer record to which the card belongs.
-
#customer_vault_token ⇒ String
(only for Authorize.Net CIM storage): the customerProfileId for the owner of the customerPaymentProfileId provided as the vault_token.
-
#disabled ⇒ TrueClass | FalseClass
The current billing street address, second line, for the card.
-
#expiration_month ⇒ Integer
An integer representing the expiration month of the card(1 – 12).
-
#expiration_year ⇒ Integer
An integer representing the 4-digit expiration year of the card(i.e. ‘2012’).
-
#first_name ⇒ String
The first name of the card holder.
-
#gateway_handle ⇒ String
An identifier of connected gateway.
-
#id ⇒ Integer
The Chargify-assigned ID of the stored card.
-
#last_name ⇒ String
The last name of the card holder.
-
#masked_card_number ⇒ String
A string representation of the credit card number with all but the last 4 digits masked with X’s (i.e. ‘XXXX-XXXX-XXXX-1234’).
-
#payment_type ⇒ PaymentType
The current billing street address, second line, for the card.
-
#site_gateway_setting_id ⇒ Integer
Token received after sending billing information using chargify.js.
-
#vault_token ⇒ String
The “token” provided by your vault storage for an already stored payment profile.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
Methods inherited from BaseModel
Constructor Details
#initialize(payment_type: PaymentType::CREDIT_CARD, id: SKIP, first_name: SKIP, last_name: SKIP, masked_card_number: SKIP, card_type: SKIP, expiration_month: SKIP, expiration_year: SKIP, customer_id: SKIP, current_vault: SKIP, vault_token: SKIP, billing_address: SKIP, billing_city: SKIP, billing_state: SKIP, billing_zip: SKIP, billing_country: SKIP, customer_vault_token: SKIP, billing_address_2: SKIP, disabled: SKIP, chargify_token: SKIP, site_gateway_setting_id: SKIP, gateway_handle: SKIP, additional_properties: {}) ⇒ CreditCardPaymentProfile
Returns a new instance of CreditCardPaymentProfile.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 183 def initialize(payment_type: PaymentType::CREDIT_CARD, id: SKIP, first_name: SKIP, last_name: SKIP, masked_card_number: SKIP, card_type: SKIP, expiration_month: SKIP, expiration_year: SKIP, customer_id: SKIP, current_vault: SKIP, vault_token: SKIP, billing_address: SKIP, billing_city: SKIP, billing_state: SKIP, billing_zip: SKIP, billing_country: SKIP, customer_vault_token: SKIP, billing_address_2: SKIP, disabled: SKIP, chargify_token: SKIP, site_gateway_setting_id: SKIP, gateway_handle: SKIP, additional_properties: {}) @id = id unless id == SKIP @first_name = first_name unless first_name == SKIP @last_name = last_name unless last_name == SKIP @masked_card_number = masked_card_number unless masked_card_number == SKIP @card_type = card_type unless card_type == SKIP @expiration_month = expiration_month unless expiration_month == SKIP @expiration_year = expiration_year unless expiration_year == SKIP @customer_id = customer_id unless customer_id == SKIP @current_vault = current_vault unless current_vault == SKIP @vault_token = vault_token unless vault_token == SKIP @billing_address = billing_address unless billing_address == SKIP @billing_city = billing_city unless billing_city == SKIP @billing_state = billing_state unless billing_state == SKIP @billing_zip = billing_zip unless billing_zip == SKIP @billing_country = billing_country unless billing_country == SKIP @customer_vault_token = customer_vault_token unless customer_vault_token == SKIP @billing_address_2 = billing_address_2 unless billing_address_2 == SKIP @payment_type = payment_type @disabled = disabled unless disabled == SKIP @chargify_token = chargify_token unless chargify_token == SKIP @site_gateway_setting_id = site_gateway_setting_id unless site_gateway_setting_id == SKIP @gateway_handle = gateway_handle unless gateway_handle == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#billing_address ⇒ String
The current billing street address for the card.
61 62 63 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 61 def billing_address @billing_address end |
#billing_address_2 ⇒ String
The current billing street address, second line, for the card.
86 87 88 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 86 def billing_address_2 @billing_address_2 end |
#billing_city ⇒ String
The current billing address city for the card.
65 66 67 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 65 def billing_city @billing_city end |
#billing_country ⇒ String
The current billing address country for the card.
77 78 79 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 77 def billing_country @billing_country end |
#billing_state ⇒ String
The current billing address state for the card.
69 70 71 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 69 def billing_state @billing_state end |
#billing_zip ⇒ String
The current billing address zip code for the card.
73 74 75 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 73 def billing_zip @billing_zip end |
#card_type ⇒ CardType
The type of card used.
33 34 35 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 33 def card_type @card_type end |
#chargify_token ⇒ String
Token received after sending billing information using chargify.js. This token will only be received if passed as a sole attribute of credit_card_attributes (i.e. tok_9g6hw85pnpt6knmskpwp4ttt)
100 101 102 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 100 def chargify_token @chargify_token end |
#current_vault ⇒ CreditCardVault
The vault that stores the payment profile with the provided ‘vault_token`. Use `bogus` for testing.
52 53 54 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 52 def current_vault @current_vault end |
#customer_id ⇒ Integer
The Chargify-assigned id for the customer record to which the card belongs.
47 48 49 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 47 def customer_id @customer_id end |
#customer_vault_token ⇒ String
(only for Authorize.Net CIM storage): the customerProfileId for the owner of the customerPaymentProfileId provided as the vault_token.
82 83 84 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 82 def customer_vault_token @customer_vault_token end |
#disabled ⇒ TrueClass | FalseClass
The current billing street address, second line, for the card.
94 95 96 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 94 def disabled @disabled end |
#expiration_month ⇒ Integer
An integer representing the expiration month of the card(1 – 12).
37 38 39 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 37 def expiration_month @expiration_month end |
#expiration_year ⇒ Integer
An integer representing the 4-digit expiration year of the card(i.e. ‘2012’).
42 43 44 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 42 def expiration_year @expiration_year end |
#first_name ⇒ String
The first name of the card holder.
20 21 22 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 20 def first_name @first_name end |
#gateway_handle ⇒ String
An identifier of connected gateway.
110 111 112 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 110 def gateway_handle @gateway_handle end |
#id ⇒ Integer
The Chargify-assigned ID of the stored card. This value can be used as an input to payment_profile_id when creating a subscription, in order to re-use a stored payment profile for the same customer.
16 17 18 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 16 def id @id end |
#last_name ⇒ String
The last name of the card holder.
24 25 26 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 24 def last_name @last_name end |
#masked_card_number ⇒ String
A string representation of the credit card number with all but the last 4 digits masked with X’s (i.e. ‘XXXX-XXXX-XXXX-1234’).
29 30 31 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 29 def masked_card_number @masked_card_number end |
#payment_type ⇒ PaymentType
The current billing street address, second line, for the card.
90 91 92 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 90 def payment_type @payment_type end |
#site_gateway_setting_id ⇒ Integer
Token received after sending billing information using chargify.js. This token will only be received if passed as a sole attribute of credit_card_attributes (i.e. tok_9g6hw85pnpt6knmskpwp4ttt)
106 107 108 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 106 def site_gateway_setting_id @site_gateway_setting_id end |
#vault_token ⇒ String
The “token” provided by your vault storage for an already stored payment profile.
57 58 59 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 57 def vault_token @vault_token end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 224 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. payment_type = hash['payment_type'] ||= PaymentType::CREDIT_CARD id = hash.key?('id') ? hash['id'] : SKIP first_name = hash.key?('first_name') ? hash['first_name'] : SKIP last_name = hash.key?('last_name') ? hash['last_name'] : SKIP masked_card_number = hash.key?('masked_card_number') ? hash['masked_card_number'] : SKIP card_type = hash.key?('card_type') ? hash['card_type'] : SKIP expiration_month = hash.key?('expiration_month') ? hash['expiration_month'] : SKIP expiration_year = hash.key?('expiration_year') ? hash['expiration_year'] : SKIP customer_id = hash.key?('customer_id') ? hash['customer_id'] : SKIP current_vault = hash.key?('current_vault') ? hash['current_vault'] : SKIP vault_token = hash.key?('vault_token') ? hash['vault_token'] : SKIP billing_address = hash.key?('billing_address') ? hash['billing_address'] : SKIP billing_city = hash.key?('billing_city') ? hash['billing_city'] : SKIP billing_state = hash.key?('billing_state') ? hash['billing_state'] : SKIP billing_zip = hash.key?('billing_zip') ? hash['billing_zip'] : SKIP billing_country = hash.key?('billing_country') ? hash['billing_country'] : SKIP customer_vault_token = hash.key?('customer_vault_token') ? hash['customer_vault_token'] : SKIP billing_address_2 = hash.key?('billing_address_2') ? hash['billing_address_2'] : SKIP disabled = hash.key?('disabled') ? hash['disabled'] : SKIP chargify_token = hash.key?('chargify_token') ? hash['chargify_token'] : SKIP site_gateway_setting_id = hash.key?('site_gateway_setting_id') ? hash['site_gateway_setting_id'] : SKIP gateway_handle = hash.key?('gateway_handle') ? hash['gateway_handle'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. CreditCardPaymentProfile.new(payment_type: payment_type, id: id, first_name: first_name, last_name: last_name, masked_card_number: masked_card_number, card_type: card_type, expiration_month: expiration_month, expiration_year: expiration_year, customer_id: customer_id, current_vault: current_vault, vault_token: vault_token, billing_address: billing_address, billing_city: billing_city, billing_state: billing_state, billing_zip: billing_zip, billing_country: billing_country, customer_vault_token: customer_vault_token, billing_address_2: billing_address_2, disabled: disabled, chargify_token: chargify_token, site_gateway_setting_id: site_gateway_setting_id, gateway_handle: gateway_handle, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 113 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['first_name'] = 'first_name' @_hash['last_name'] = 'last_name' @_hash['masked_card_number'] = 'masked_card_number' @_hash['card_type'] = 'card_type' @_hash['expiration_month'] = 'expiration_month' @_hash['expiration_year'] = 'expiration_year' @_hash['customer_id'] = 'customer_id' @_hash['current_vault'] = 'current_vault' @_hash['vault_token'] = 'vault_token' @_hash['billing_address'] = 'billing_address' @_hash['billing_city'] = 'billing_city' @_hash['billing_state'] = 'billing_state' @_hash['billing_zip'] = 'billing_zip' @_hash['billing_country'] = 'billing_country' @_hash['customer_vault_token'] = 'customer_vault_token' @_hash['billing_address_2'] = 'billing_address_2' @_hash['payment_type'] = 'payment_type' @_hash['disabled'] = 'disabled' @_hash['chargify_token'] = 'chargify_token' @_hash['site_gateway_setting_id'] = 'site_gateway_setting_id' @_hash['gateway_handle'] = 'gateway_handle' @_hash end |
.nullables ⇒ Object
An array for nullable fields
168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 168 def self.nullables %w[ vault_token billing_address billing_city billing_state billing_zip billing_country customer_vault_token billing_address_2 site_gateway_setting_id gateway_handle ] end |
.optionals ⇒ Object
An array for optional fields
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 141 def self.optionals %w[ id first_name last_name masked_card_number card_type expiration_month expiration_year customer_id current_vault vault_token billing_address billing_city billing_state billing_zip billing_country customer_vault_token billing_address_2 disabled chargify_token site_gateway_setting_id gateway_handle ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/advanced_billing/models/credit_card_payment_profile.rb', line 292 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.payment_type, ->(val) { PaymentType.validate(val) }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['payment_type'], ->(val) { PaymentType.validate(val) }) end |