Class: AdvancedBilling::PaymentProfileAttributes

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/payment_profile_attributes.rb

Overview

alias to credit_card_attributes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(chargify_token: SKIP, id: SKIP, payment_type: SKIP, first_name: SKIP, last_name: SKIP, masked_card_number: SKIP, full_number: SKIP, card_type: SKIP, expiration_month: SKIP, expiration_year: SKIP, billing_address: SKIP, billing_address_2: SKIP, billing_city: SKIP, billing_state: SKIP, billing_country: SKIP, billing_zip: SKIP, current_vault: SKIP, vault_token: SKIP, customer_vault_token: SKIP, customer_id: SKIP, paypal_email: SKIP, payment_method_nonce: SKIP, gateway_handle: SKIP, cvv: SKIP, last_four: SKIP, additional_properties: {}) ⇒ PaymentProfileAttributes

Returns a new instance of PaymentProfileAttributes.



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
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 238

def initialize(chargify_token: SKIP, id: SKIP, payment_type: SKIP,
               first_name: SKIP, last_name: SKIP, masked_card_number: SKIP,
               full_number: SKIP, card_type: SKIP, expiration_month: SKIP,
               expiration_year: SKIP, billing_address: SKIP,
               billing_address_2: SKIP, billing_city: SKIP,
               billing_state: SKIP, billing_country: SKIP,
               billing_zip: SKIP, current_vault: SKIP, vault_token: SKIP,
               customer_vault_token: SKIP, customer_id: SKIP,
               paypal_email: SKIP, payment_method_nonce: SKIP,
               gateway_handle: SKIP, cvv: SKIP, last_four: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @chargify_token = chargify_token unless chargify_token == SKIP
  @id = id unless id == SKIP
  @payment_type = payment_type unless payment_type == 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
  @full_number = full_number unless full_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
  @billing_address = billing_address unless billing_address == SKIP
  @billing_address_2 = billing_address_2 unless billing_address_2 == SKIP
  @billing_city = billing_city unless billing_city == SKIP
  @billing_state = billing_state unless billing_state == SKIP
  @billing_country = billing_country unless billing_country == SKIP
  @billing_zip = billing_zip unless billing_zip == SKIP
  @current_vault = current_vault unless current_vault == SKIP
  @vault_token = vault_token unless vault_token == SKIP
  @customer_vault_token = customer_vault_token unless customer_vault_token == SKIP
  @customer_id = customer_id unless customer_id == SKIP
  @paypal_email = paypal_email unless paypal_email == SKIP
  @payment_method_nonce = payment_method_nonce unless payment_method_nonce == SKIP
  @gateway_handle = gateway_handle unless gateway_handle == SKIP
  @cvv = cvv unless cvv == SKIP
  @last_four = last_four unless last_four == SKIP
end

Instance Attribute Details

#billing_addressString

(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing street address (e.g., 123 Main St.). This value is merely passed through to the payment gateway.

Returns:

  • (String)


72
73
74
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 72

def billing_address
  @billing_address
end

#billing_address_2String

(Optional) Second line of the customer’s billing address, e.g., Apt. 100

Returns:

  • (String)


76
77
78
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 76

def billing_address_2
  @billing_address_2
end

#billing_cityString

(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address city (e.g., “Boston”). This value is merely passed through to the payment gateway.

Returns:

  • (String)


82
83
84
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 82

def billing_city
  @billing_city
end

#billing_countryString

(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address country, required in ISO_3166-1 alpha-2 format (e.g., “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time.

Returns:

  • (String)


102
103
104
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 102

def billing_country
  @billing_country
end

#billing_stateString

(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address state (e.g., MA). This value is merely passed through to the payment gateway. This must conform to the ISO_3166-1 in order to be valid for tax locale purposes.

Returns:

  • (String)


91
92
93
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 91

def billing_state
  @billing_state
end

#billing_zipString

(Optional, may be required by your product configuration or gateway settings) The credit card or bank account billing address zip code (e.g., 12345). This value is merely passed through to the payment gateway.

Returns:

  • (String)


108
109
110
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 108

def billing_zip
  @billing_zip
end

#card_typeCardType

(Optional, used only for Subscription Import) If you know the card type (e.g., Visa, MC, etc.) you may supply it here so that we may display the card type in the UI.

Returns:



54
55
56
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 54

def card_type
  @card_type
end

#chargify_tokenString

(Optional) Token received after sending billing information using Maxio.js (formerly Chargify.js). This token must be passed as a sole attribute of payment_profile_attributes (e.g., tok_9g6hw85pnpt6knmskpwp4ttt).

Returns:

  • (String)


16
17
18
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 16

def chargify_token
  @chargify_token
end

#current_vaultAllVaults

(Optional, used only for Subscription Import) The vault that stores the payment profile with the provided vault_token.

Returns:



113
114
115
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 113

def current_vault
  @current_vault
end

#customer_idInteger

(Optional, used only for Subscription Import) (only for Authorize.Net CIM storage or Square) The customerProfileId for the owner of the customerPaymentProfileId provided as the vault_token

Returns:

  • (Integer)


130
131
132
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 130

def customer_id
  @customer_id
end

#customer_vault_tokenString

(Optional, used only for Subscription Import) (only for Authorize.Net CIM storage or Square) The customerProfileId for the owner of the customerPaymentProfileId provided as the vault_token

Returns:

  • (String)


124
125
126
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 124

def customer_vault_token
  @customer_vault_token
end

#cvvString

(Optional, may be required by your gateway settings) The 3- or 4-digit Card Verification Value. This value is merely passed through to the payment gateway.

Returns:

  • (String)


160
161
162
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 160

def cvv
  @cvv
end

#expiration_monthObject

(Optional when performing a Subscription Import via vault_token, required otherwise) The 1- or 2-digit credit card expiration month, as an integer or string, e.g., 5

Returns:

  • (Object)


60
61
62
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 60

def expiration_month
  @expiration_month
end

#expiration_yearObject

(Optional when performing a Subscription Import via vault_token, required otherwise) The 4-digit credit card expiration year, as an integer or string, e.g., 2012

Returns:

  • (Object)


66
67
68
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 66

def expiration_year
  @expiration_year
end

#first_nameString

(Optional) First name on card or bank account. If omitted, the first_name from customer attributes will be used.

Returns:

  • (String)


33
34
35
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 33

def first_name
  @first_name
end

#full_numberString

The full credit card number (string representation, e.g., 5424000000000015)

Returns:

  • (String)


48
49
50
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 48

def full_number
  @full_number
end

#gateway_handleString

(Optional) This attribute is only available if MultiGateway feature is enabled for your Site. This feature is in the Private Beta currently. gateway_handle is used to directly select a gateway where a payment profile will be stored in. Every connected gateway must have a unique gateway handle specified. Read [Multigateway description](https://chargify.zendesk.com/hc/en-us/articles/4407761759643# connecting-with-multiple-gateways) to learn more about new concepts that MultiGateway introduces and the default behavior when this attribute is not passed.

Returns:

  • (String)


154
155
156
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 154

def gateway_handle
  @gateway_handle
end

#idInteger

(Optional) Token received after sending billing information using Maxio.js (formerly Chargify.js). This token must be passed as a sole attribute of payment_profile_attributes (e.g., tok_9g6hw85pnpt6knmskpwp4ttt).

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 22

def id
  @id
end

#last_fourString

(Optional, used only for Subscription Import) If you have the last 4 digits of the credit card number, you may supply them here so that we may create a masked card number (e.g., XXXX-XXXX-XXXX-1234) for display in the UI. Last 4 digits are required for refunds in Auth.Net.

Returns:

  • (String)


167
168
169
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 167

def last_four
  @last_four
end

#last_nameString

(Optional) Last name on card or bank account. If omitted, the last_name from customer attributes will be used.

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 38

def last_name
  @last_name
end

#masked_card_numberString

(Optional) Last name on card or bank account. If omitted, the last_name from customer attributes will be used.

Returns:

  • (String)


43
44
45
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 43

def masked_card_number
  @masked_card_number
end

#payment_method_nonceString

(Required for Square unless importing with vault_token and customer_vault_token) The nonce generated by the Square Javascript library (SqPaymentForm)

Returns:

  • (String)


142
143
144
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 142

def payment_method_nonce
  @payment_method_nonce
end

#payment_typePaymentType

(Optional) Token received after sending billing information using Maxio.js (formerly Chargify.js). This token must be passed as a sole attribute of payment_profile_attributes (e.g., tok_9g6hw85pnpt6knmskpwp4ttt).

Returns:



28
29
30
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 28

def payment_type
  @payment_type
end

#paypal_emailString

(Optional, used only for Subscription Import) (only for Authorize.Net CIM storage or Square) The customerProfileId for the owner of the customerPaymentProfileId provided as the vault_token

Returns:

  • (String)


136
137
138
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 136

def paypal_email
  @paypal_email
end

#vault_tokenString

(Optional, used only for Subscription Import) The “token” provided by your vault storage for an already stored payment profile

Returns:

  • (String)


118
119
120
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 118

def vault_token
  @vault_token
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 282

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  chargify_token =
    hash.key?('chargify_token') ? hash['chargify_token'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  payment_type = hash.key?('payment_type') ? hash['payment_type'] : 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
  full_number = hash.key?('full_number') ? hash['full_number'] : SKIP
  card_type = hash.key?('card_type') ? hash['card_type'] : SKIP
  expiration_month = hash.key?('expiration_month') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:PaymentProfileAttributesExpirationMonth), hash['expiration_month']
  ) : SKIP
  expiration_year = hash.key?('expiration_year') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:PaymentProfileAttributesExpirationYear), hash['expiration_year']
  ) : SKIP
  billing_address =
    hash.key?('billing_address') ? hash['billing_address'] : SKIP
  billing_address_2 =
    hash.key?('billing_address_2') ? hash['billing_address_2'] : SKIP
  billing_city = hash.key?('billing_city') ? hash['billing_city'] : SKIP
  billing_state = hash.key?('billing_state') ? hash['billing_state'] : SKIP
  billing_country =
    hash.key?('billing_country') ? hash['billing_country'] : SKIP
  billing_zip = hash.key?('billing_zip') ? hash['billing_zip'] : SKIP
  current_vault = hash.key?('current_vault') ? hash['current_vault'] : SKIP
  vault_token = hash.key?('vault_token') ? hash['vault_token'] : SKIP
  customer_vault_token =
    hash.key?('customer_vault_token') ? hash['customer_vault_token'] : SKIP
  customer_id = hash.key?('customer_id') ? hash['customer_id'] : SKIP
  paypal_email = hash.key?('paypal_email') ? hash['paypal_email'] : SKIP
  payment_method_nonce =
    hash.key?('payment_method_nonce') ? hash['payment_method_nonce'] : SKIP
  gateway_handle =
    hash.key?('gateway_handle') ? hash['gateway_handle'] : SKIP
  cvv = hash.key?('cvv') ? hash['cvv'] : SKIP
  last_four = hash.key?('last_four') ? hash['last_four'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  PaymentProfileAttributes.new(chargify_token: chargify_token,
                               id: id,
                               payment_type: payment_type,
                               first_name: first_name,
                               last_name: last_name,
                               masked_card_number: masked_card_number,
                               full_number: full_number,
                               card_type: card_type,
                               expiration_month: expiration_month,
                               expiration_year: expiration_year,
                               billing_address: billing_address,
                               billing_address_2: billing_address_2,
                               billing_city: billing_city,
                               billing_state: billing_state,
                               billing_country: billing_country,
                               billing_zip: billing_zip,
                               current_vault: current_vault,
                               vault_token: vault_token,
                               customer_vault_token: customer_vault_token,
                               customer_id: customer_id,
                               paypal_email: paypal_email,
                               payment_method_nonce: payment_method_nonce,
                               gateway_handle: gateway_handle,
                               cvv: cvv,
                               last_four: last_four,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 170

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['chargify_token'] = 'chargify_token'
  @_hash['id'] = 'id'
  @_hash['payment_type'] = 'payment_type'
  @_hash['first_name'] = 'first_name'
  @_hash['last_name'] = 'last_name'
  @_hash['masked_card_number'] = 'masked_card_number'
  @_hash['full_number'] = 'full_number'
  @_hash['card_type'] = 'card_type'
  @_hash['expiration_month'] = 'expiration_month'
  @_hash['expiration_year'] = 'expiration_year'
  @_hash['billing_address'] = 'billing_address'
  @_hash['billing_address_2'] = 'billing_address_2'
  @_hash['billing_city'] = 'billing_city'
  @_hash['billing_state'] = 'billing_state'
  @_hash['billing_country'] = 'billing_country'
  @_hash['billing_zip'] = 'billing_zip'
  @_hash['current_vault'] = 'current_vault'
  @_hash['vault_token'] = 'vault_token'
  @_hash['customer_vault_token'] = 'customer_vault_token'
  @_hash['customer_id'] = 'customer_id'
  @_hash['paypal_email'] = 'paypal_email'
  @_hash['payment_method_nonce'] = 'payment_method_nonce'
  @_hash['gateway_handle'] = 'gateway_handle'
  @_hash['cvv'] = 'cvv'
  @_hash['last_four'] = 'last_four'
  @_hash
end

.nullablesObject

An array for nullable fields



232
233
234
235
236
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 232

def self.nullables
  %w[
    billing_address_2
  ]
end

.optionalsObject

An array for optional fields



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 201

def self.optionals
  %w[
    chargify_token
    id
    payment_type
    first_name
    last_name
    masked_card_number
    full_number
    card_type
    expiration_month
    expiration_year
    billing_address
    billing_address_2
    billing_city
    billing_state
    billing_country
    billing_zip
    current_vault
    vault_token
    customer_vault_token
    customer_id
    paypal_email
    payment_method_nonce
    gateway_handle
    cvv
    last_four
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



358
359
360
361
362
363
364
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 358

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 383

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} chargify_token: #{@chargify_token.inspect}, id: #{@id.inspect},"\
  " payment_type: #{@payment_type.inspect}, first_name: #{@first_name.inspect}, last_name:"\
  " #{@last_name.inspect}, masked_card_number: #{@masked_card_number.inspect}, full_number:"\
  " #{@full_number.inspect}, card_type: #{@card_type.inspect}, expiration_month:"\
  " #{@expiration_month.inspect}, expiration_year: #{@expiration_year.inspect},"\
  " billing_address: #{@billing_address.inspect}, billing_address_2:"\
  " #{@billing_address_2.inspect}, billing_city: #{@billing_city.inspect}, billing_state:"\
  " #{@billing_state.inspect}, billing_country: #{@billing_country.inspect}, billing_zip:"\
  " #{@billing_zip.inspect}, current_vault: #{@current_vault.inspect}, vault_token:"\
  " #{@vault_token.inspect}, customer_vault_token: #{@customer_vault_token.inspect},"\
  " customer_id: #{@customer_id.inspect}, paypal_email: #{@paypal_email.inspect},"\
  " payment_method_nonce: #{@payment_method_nonce.inspect}, gateway_handle:"\
  " #{@gateway_handle.inspect}, cvv: #{@cvv.inspect}, last_four: #{@last_four.inspect},"\
  " additional_properties: #{get_additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/advanced_billing/models/payment_profile_attributes.rb', line 367

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} chargify_token: #{@chargify_token}, id: #{@id}, payment_type:"\
  " #{@payment_type}, first_name: #{@first_name}, last_name: #{@last_name},"\
  " masked_card_number: #{@masked_card_number}, full_number: #{@full_number}, card_type:"\
  " #{@card_type}, expiration_month: #{@expiration_month}, expiration_year:"\
  " #{@expiration_year}, billing_address: #{@billing_address}, billing_address_2:"\
  " #{@billing_address_2}, billing_city: #{@billing_city}, billing_state: #{@billing_state},"\
  " billing_country: #{@billing_country}, billing_zip: #{@billing_zip}, current_vault:"\
  " #{@current_vault}, vault_token: #{@vault_token}, customer_vault_token:"\
  " #{@customer_vault_token}, customer_id: #{@customer_id}, paypal_email: #{@paypal_email},"\
  " payment_method_nonce: #{@payment_method_nonce}, gateway_handle: #{@gateway_handle}, cvv:"\
  " #{@cvv}, last_four: #{@last_four}, additional_properties: #{get_additional_properties}>"
end