Class: UnivapayClientSdk::ChargeCreateRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/univapay_client_sdk/models/charge_create_request.rb

Overview

Request payload for creating a charge.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

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

Constructor Details

#initialize(transaction_token_id:, amount:, currency: 'JPY', capture: true, capture_at: SKIP, merchant_transaction_id: SKIP, metadata: SKIP, client_metadata: SKIP, redirect: SKIP, three_ds: SKIP, additional_properties: nil) ⇒ ChargeCreateRequest

Returns a new instance of ChargeCreateRequest.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 89

def initialize(transaction_token_id:, amount:, currency: 'JPY',
               capture: true, capture_at: SKIP,
               merchant_transaction_id: SKIP, metadata: SKIP,
               client_metadata: SKIP, redirect: SKIP, three_ds: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @transaction_token_id = transaction_token_id
  @amount = amount
  @currency = currency
  @capture = capture unless capture == SKIP
  @capture_at = capture_at unless capture_at == SKIP
  @merchant_transaction_id = merchant_transaction_id unless merchant_transaction_id == SKIP
  @metadata =  unless  == SKIP
  @client_metadata =  unless  == SKIP
  @redirect = redirect unless redirect == SKIP
  @three_ds = three_ds unless three_ds == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountInteger

The charge amount.

Returns:

  • (Integer)


19
20
21
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 19

def amount
  @amount
end

#captureTrueClass | FalseClass

If false, creates an Authorization only (Hold).

Returns:

  • (TrueClass | FalseClass)


27
28
29
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 27

def capture
  @capture
end

#capture_atDateTime

Auto-capture date for cards, or payment deadline for Konbini/Bank. Note: Time specification is ignored for 7-Eleven, Seicomart, and PayEasy.

Returns:

  • (DateTime)


32
33
34
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 32

def capture_at
  @capture_at
end

#client_metadataChargeCreateRequestClientMetadata

Charge Create Request Client Metadata schema.



45
46
47
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 45

def 
  @client_metadata
end

#currencyString

ISO-4217 currency code.

Returns:

  • (String)


23
24
25
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 23

def currency
  @currency
end

#merchant_transaction_idString

Unique transaction ID for the merchant. Required/used by specific brands like we_chat, we_chat_mpm, and we_chat_online.

Returns:

  • (String)


37
38
39
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 37

def merchant_transaction_id
  @merchant_transaction_id
end

#metadataGenericMetadata

A free-form dictionary for custom metadata.

Returns:



41
42
43
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 41

def 
  @metadata
end

#redirectChargeCreateRequestRedirect

Charge Create Request Redirect schema.



49
50
51
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 49

def redirect
  @redirect
end

#three_dsChargeCreateRequestThreeDs

Charge Create Request Three Ds schema.



53
54
55
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 53

def three_ds
  @three_ds
end

#transaction_token_idUUID | String

Transaction token identifier.

Returns:

  • (UUID | String)


15
16
17
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 15

def transaction_token_id
  @transaction_token_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



111
112
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 111

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_token_id =
    hash.key?('transaction_token_id') ? hash['transaction_token_id'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  currency = hash['currency'] ||= 'JPY'
  capture = hash['capture'] ||= true
  capture_at = if hash.key?('capture_at')
                 (DateTimeHelper.from_rfc3339(hash['capture_at']) if hash['capture_at'])
               else
                 SKIP
               end
  merchant_transaction_id =
    hash.key?('merchant_transaction_id') ? hash['merchant_transaction_id'] : SKIP
   = GenericMetadata.from_hash(hash['metadata']) if hash['metadata']
   = ChargeCreateRequestClientMetadata.from_hash(hash['client_metadata']) if
    hash['client_metadata']
  redirect = ChargeCreateRequestRedirect.from_hash(hash['redirect']) if hash['redirect']
  three_ds = ChargeCreateRequestThreeDs.from_hash(hash['three_ds']) if hash['three_ds']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  ChargeCreateRequest.new(transaction_token_id: transaction_token_id,
                          amount: amount,
                          currency: currency,
                          capture: capture,
                          capture_at: capture_at,
                          merchant_transaction_id: merchant_transaction_id,
                          metadata: ,
                          client_metadata: ,
                          redirect: redirect,
                          three_ds: three_ds,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 56

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_token_id'] = 'transaction_token_id'
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['capture'] = 'capture'
  @_hash['capture_at'] = 'capture_at'
  @_hash['merchant_transaction_id'] = 'merchant_transaction_id'
  @_hash['metadata'] = 'metadata'
  @_hash['client_metadata'] = 'client_metadata'
  @_hash['redirect'] = 'redirect'
  @_hash['three_ds'] = 'three_ds'
  @_hash
end

.nullablesObject

An array for nullable fields



85
86
87
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 85

def self.nullables
  []
end

.optionalsObject

An array for optional fields



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 72

def self.optionals
  %w[
    capture
    capture_at
    merchant_transaction_id
    metadata
    client_metadata
    redirect
    three_ds
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



169
170
171
172
173
174
175
176
177
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 169

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_token_id: #{@transaction_token_id.inspect}, amount:"\
  " #{@amount.inspect}, currency: #{@currency.inspect}, capture: #{@capture.inspect},"\
  " capture_at: #{@capture_at.inspect}, merchant_transaction_id:"\
  " #{@merchant_transaction_id.inspect}, metadata: #{@metadata.inspect}, client_metadata:"\
  " #{@client_metadata.inspect}, redirect: #{@redirect.inspect}, three_ds:"\
  " #{@three_ds.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_capture_atObject



154
155
156
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 154

def to_custom_capture_at
  DateTimeHelper.to_rfc3339(capture_at)
end

#to_sObject

Provides a human-readable string representation of the object.



159
160
161
162
163
164
165
166
# File 'lib/univapay_client_sdk/models/charge_create_request.rb', line 159

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} transaction_token_id: #{@transaction_token_id}, amount: #{@amount},"\
  " currency: #{@currency}, capture: #{@capture}, capture_at: #{@capture_at},"\
  " merchant_transaction_id: #{@merchant_transaction_id}, metadata: #{@metadata},"\
  " client_metadata: #{@client_metadata}, redirect: #{@redirect}, three_ds: #{@three_ds},"\
  " additional_properties: #{@additional_properties}>"
end