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

#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.



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

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: {})
  @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

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
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 (i.e. 123 Main St.). This value is merely passed through to the payment gateway.

Returns:

  • (String)


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

def billing_address
  @billing_address
end

#billing_address_2String

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

Returns:

  • (String)


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

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 (i.e. “Boston”). This value is merely passed through to the payment gateway.

Returns:

  • (String)


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

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](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format (i.e. “US”). This value is merely passed through to the payment gateway. Some gateways require country codes in a specific format. Please check your gateway’s documentation. If creating an ACH subscription, only US is supported at this time.

Returns:

  • (String)


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

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 (i.e. MA). This value is merely passed through to the payment gateway. This must conform to the [ISO_3166-1](en.wikipedia.org/wiki/ISO_3166-1#Current_codes) in order to be valid for tax locale purposes.

Returns:

  • (String)


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

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 (i.e. 12345). This value is merely passed through to the payment gateway.

Returns:

  • (String)


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

def billing_zip
  @billing_zip
end

#card_typeCardType

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

Returns:



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

def card_type
  @card_type
end

#chargify_tokenString

(Optional) Token received after sending billing information using chargify.js. This token must be passed as a sole attribute of ‘payment_profile_attributes` (i.e. 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:



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

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)


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

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)


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

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)


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

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, i.e. 5

Returns:

  • (Object)


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

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, i.e. 2012

Returns:

  • (Object)


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

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, i.e. 5424000000000015)

Returns:

  • (String)


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

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](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)


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

def gateway_handle
  @gateway_handle
end

#idInteger

(Optional) Token received after sending billing information using chargify.js. This token must be passed as a sole attribute of ‘payment_profile_attributes` (i.e. 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 (i.e. XXXX-XXXX-XXXX-1234) for display in the UI. Last 4 digits are required for refunds in Auth.Net.

Returns:

  • (String)


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

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)


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

def payment_method_nonce
  @payment_method_nonce
end

#payment_typePaymentType

(Optional) Token received after sending billing information using chargify.js. This token must be passed as a sole attribute of ‘payment_profile_attributes` (i.e. 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)


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

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)


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

def vault_token
  @vault_token
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

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.
  names.each_value { |k| hash.delete(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: hash)
end

.namesObject

A mapping from model property names to API property names.



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

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



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

def self.nullables
  %w[
    billing_address_2
  ]
end

.optionalsObject

An array for optional fields



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

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:



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

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

  return false unless value.instance_of? Hash

  true
end