Class: Lithic::Resources::Transactions

Inherits:
Object
  • Object
show all
Defined in:
lib/lithic/resources/transactions.rb,
lib/lithic/resources/transactions/events.rb,
lib/lithic/resources/transactions/enhanced_commercial_data.rb,
lib/lithic/resources/transactions/events/enhanced_commercial_data.rb,
sig/lithic/resources/transactions.rbs,
sig/lithic/resources/transactions/events.rbs,
sig/lithic/resources/transactions/enhanced_commercial_data.rbs,
sig/lithic/resources/transactions/events/enhanced_commercial_data.rbs

Defined Under Namespace

Classes: EnhancedCommercialData, Events

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Transactions

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Transactions.

Parameters:



367
368
369
370
371
# File 'lib/lithic/resources/transactions.rb', line 367

def initialize(client:)
  @client = client
  @enhanced_commercial_data = Lithic::Resources::Transactions::EnhancedCommercialData.new(client: client)
  @events = Lithic::Resources::Transactions::Events.new(client: client)
end

Instance Attribute Details

#enhanced_commercial_dataLithic::Resources::Transactions::EnhancedCommercialData (readonly)



7
8
9
# File 'lib/lithic/resources/transactions.rb', line 7

def enhanced_commercial_data
  @enhanced_commercial_data
end

#eventsLithic::Resources::Transactions::Events (readonly)



10
11
12
# File 'lib/lithic/resources/transactions.rb', line 10

def events
  @events
end

Instance Method Details

#expire_authorization(transaction_token, request_options: {}) ⇒ nil

Expire authorization

Parameters:

  • transaction_token (String)

    The token of the transaction to expire.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



88
89
90
91
92
93
94
95
# File 'lib/lithic/resources/transactions.rb', line 88

def expire_authorization(transaction_token, params = {})
  @client.request(
    method: :post,
    path: ["v1/transactions/%1$s/expire_authorization", transaction_token],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(account_token: nil, begin_: nil, card_token: nil, end_: nil, ending_before: nil, page_size: nil, result: nil, starting_after: nil, status: nil, request_options: {}) ⇒ Lithic::Internal::CursorPage<Lithic::Models::Transaction>

Some parameter documentations has been truncated, see Models::TransactionListParams for more details.

List card transactions. All amounts are in the smallest unit of their respective currency (e.g., cents for USD) and inclusive of any acquirer fees.

Parameters:

  • account_token (String)

    Filters for transactions associated with a specific account.

  • begin_ (Time)

    Date string in RFC 3339 format. Only entries created after the specified time wi

  • card_token (String)

    Filters for transactions associated with a specific card.

  • end_ (Time)

    Date string in RFC 3339 format. Only entries created before the specified time w

  • ending_before (String)

    A cursor representing an item's token before which a page of results should end.

  • page_size (Integer)

    Page size (for pagination).

  • result (Symbol, Lithic::Models::TransactionListParams::Result)

    Filters for transactions using transaction result field. Can filter by `APPROVED

  • starting_after (String)

    A cursor representing an item's token after which a page of results should begin

  • status (Symbol, Lithic::Models::TransactionListParams::Status)

    Filters for transactions using transaction status field.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/lithic/resources/transactions.rb', line 64

def list(params = {})
  parsed, options = Lithic::TransactionListParams.dump_request(params)
  query = Lithic::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/transactions",
    query: query.transform_keys(begin_: "begin", end_: "end"),
    page: Lithic::Internal::CursorPage,
    model: Lithic::Transaction,
    options: options
  )
end

#retrieve(transaction_token, request_options: {}) ⇒ Lithic::Models::Transaction

Get a specific card transaction. All amounts are in the smallest unit of their respective currency (e.g., cents for USD).

Parameters:

  • transaction_token (String)

    Globally unique identifier for the transaction.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



24
25
26
27
28
29
30
31
# File 'lib/lithic/resources/transactions.rb', line 24

def retrieve(transaction_token, params = {})
  @client.request(
    method: :get,
    path: ["v1/transactions/%1$s", transaction_token],
    model: Lithic::Transaction,
    options: params[:request_options]
  )
end

#route(transaction_token, financial_account_token:, request_options: {}) ⇒ nil

Route a card transaction to a financial account. Only available for select use cases and programs.

Parameters:

  • transaction_token (String)

    The token of the transaction to route.

  • financial_account_token (String)

    The token of the financial account to route the transaction to.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



111
112
113
114
115
116
117
118
119
120
# File 'lib/lithic/resources/transactions.rb', line 111

def route(transaction_token, params)
  parsed, options = Lithic::TransactionRouteParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/transactions/%1$s/route", transaction_token],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#simulate_authorization(amount:, descriptor:, pan:, mcc: nil, merchant_acceptor_city: nil, merchant_acceptor_country: nil, merchant_acceptor_id: nil, merchant_acceptor_state: nil, merchant_amount: nil, merchant_currency: nil, partial_approval_capable: nil, pin: nil, status: nil, request_options: {}) ⇒ Lithic::Models::TransactionSimulateAuthorizationResponse

Some parameter documentations has been truncated, see Models::TransactionSimulateAuthorizationParams for more details.

Simulates an authorization request from the card network as if it came from a merchant acquirer. If you are configured for ASA, simulating authorizations requires your ASA client to be set up properly, i.e. be able to respond to the ASA request with a valid JSON. For users that are not configured for ASA, a daily transaction limit of $5000 USD is applied by default. You can update this limit via the update account endpoint.

Parameters:

  • amount (Integer)

    Amount (in cents) to authorize. For credit authorizations and financial credit a

  • descriptor (String)

    Merchant descriptor.

  • pan (String)

    Sixteen digit card number.

  • mcc (String)

    Merchant category code for the transaction to be simulated. A four-digit number

  • merchant_acceptor_city (String)

    Merchant acceptor city

  • merchant_acceptor_country (String)

    Merchant acceptor country code (ISO 3166-1 alpha-3)

  • merchant_acceptor_id (String)

    Unique identifier to identify the payment card acceptor.

  • merchant_acceptor_state (String)

    Merchant acceptor state/province (ISO 3166-2 subdivision code)

  • merchant_amount (Integer)

    Amount of the transaction to be simulated in currency specified in merchant_curr

  • merchant_currency (String)

    3-character alphabetic ISO 4217 currency code. Note: Simulator only accepts USD,

  • partial_approval_capable (Boolean)

    Set to true if the terminal is capable of partial approval otherwise false.

  • pin (String)

    Simulate entering a PIN. If omitted, PIN check will not be performed.

  • status (Symbol, Lithic::Models::TransactionSimulateAuthorizationParams::Status)

    Type of event to simulate.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



167
168
169
170
171
172
173
174
175
176
# File 'lib/lithic/resources/transactions.rb', line 167

def simulate_authorization(params)
  parsed, options = Lithic::TransactionSimulateAuthorizationParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/simulate/authorize",
    body: parsed,
    model: Lithic::Models::TransactionSimulateAuthorizationResponse,
    options: options
  )
end

#simulate_authorization_advice(token:, amount:, request_options: {}) ⇒ Lithic::Models::TransactionSimulateAuthorizationAdviceResponse

Some parameter documentations has been truncated, see Models::TransactionSimulateAuthorizationAdviceParams for more details.

Simulates an authorization advice from the card network as if it came from a merchant acquirer. An authorization advice changes the pending amount of the transaction.

Parameters:

  • token (String)

    The transaction token returned from the /v1/simulate/authorize. response.

  • amount (Integer)

    Amount (in cents) to authorize. This amount will override the transaction's amou

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



196
197
198
199
200
201
202
203
204
205
# File 'lib/lithic/resources/transactions.rb', line 196

def simulate_authorization_advice(params)
  parsed, options = Lithic::TransactionSimulateAuthorizationAdviceParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/simulate/authorization_advice",
    body: parsed,
    model: Lithic::Models::TransactionSimulateAuthorizationAdviceResponse,
    options: options
  )
end

#simulate_clearing(token:, amount: nil, request_options: {}) ⇒ Lithic::Models::TransactionSimulateClearingResponse

Some parameter documentations has been truncated, see Models::TransactionSimulateClearingParams for more details.

Clears an existing authorization, either debit or credit. After this event, the transaction transitions from PENDING to SETTLED status.

If amount is not set, the full amount of the transaction will be cleared. Transactions that have already cleared, either partially or fully, cannot be cleared again using this endpoint.

Parameters:

  • token (String)

    The transaction token returned from the /v1/simulate/authorize response.

  • amount (Integer)

    Amount (in cents) to clear. Typically this will match the amount in the original

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



228
229
230
231
232
233
234
235
236
237
# File 'lib/lithic/resources/transactions.rb', line 228

def simulate_clearing(params)
  parsed, options = Lithic::TransactionSimulateClearingParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/simulate/clearing",
    body: parsed,
    model: Lithic::Models::TransactionSimulateClearingResponse,
    options: options
  )
end

#simulate_credit_authorization_advice(amount:, descriptor:, pan:, mcc: nil, merchant_acceptor_city: nil, merchant_acceptor_country: nil, merchant_acceptor_id: nil, merchant_acceptor_state: nil, request_options: {}) ⇒ Lithic::Models::TransactionSimulateCreditAuthorizationAdviceResponse

Some parameter documentations has been truncated, see Models::TransactionSimulateCreditAuthorizationAdviceParams for more details.

Simulates a credit authorization advice from the card network. This message indicates that the network approved a credit authorization on your behalf.

Parameters:

  • amount (Integer)

    Amount (in cents). Any value entered will be converted into a negative amount in

  • descriptor (String)

    Merchant descriptor.

  • pan (String)

    Sixteen digit card number.

  • mcc (String)

    Merchant category code for the transaction to be simulated. A four-digit number

  • merchant_acceptor_city (String)

    Merchant acceptor city

  • merchant_acceptor_country (String)

    Merchant acceptor country code (ISO 3166-1 alpha-3)

  • merchant_acceptor_id (String)

    Unique identifier to identify the payment card acceptor.

  • merchant_acceptor_state (String)

    Merchant acceptor state/province (ISO 3166-2 subdivision code)

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



269
270
271
272
273
274
275
276
277
278
# File 'lib/lithic/resources/transactions.rb', line 269

def simulate_credit_authorization_advice(params)
  parsed, options = Lithic::TransactionSimulateCreditAuthorizationAdviceParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/simulate/credit_authorization_advice",
    body: parsed,
    model: Lithic::Models::TransactionSimulateCreditAuthorizationAdviceResponse,
    options: options
  )
end

#simulate_return(amount:, descriptor:, pan:, request_options: {}) ⇒ Lithic::Models::TransactionSimulateReturnResponse

Returns, or refunds, an amount back to a card. Returns simulated via this endpoint clear immediately, without prior authorization, and result in a SETTLED transaction status.

Parameters:

  • amount (Integer)

    Amount (in cents) to authorize.

  • descriptor (String)

    Merchant descriptor.

  • pan (String)

    Sixteen digit card number.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



297
298
299
300
301
302
303
304
305
306
# File 'lib/lithic/resources/transactions.rb', line 297

def simulate_return(params)
  parsed, options = Lithic::TransactionSimulateReturnParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/simulate/return",
    body: parsed,
    model: Lithic::Models::TransactionSimulateReturnResponse,
    options: options
  )
end

#simulate_return_reversal(token:, request_options: {}) ⇒ Lithic::Models::TransactionSimulateReturnReversalResponse

Reverses a return, i.e. a credit transaction with a SETTLED status. Returns can be financial credit authorizations, or credit authorizations that have cleared.

Parameters:

  • token (String)

    The transaction token returned from the /v1/simulate/authorize response.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



321
322
323
324
325
326
327
328
329
330
# File 'lib/lithic/resources/transactions.rb', line 321

def simulate_return_reversal(params)
  parsed, options = Lithic::TransactionSimulateReturnReversalParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/simulate/return_reversal",
    body: parsed,
    model: Lithic::Models::TransactionSimulateReturnReversalResponse,
    options: options
  )
end

#simulate_void(token:, amount: nil, type: nil, request_options: {}) ⇒ Lithic::Models::TransactionSimulateVoidResponse

Some parameter documentations has been truncated, see Models::TransactionSimulateVoidParams for more details.

Voids a pending authorization. If amount is not set, the full amount will be voided. Can be used on partially voided transactions but not partially cleared transactions. Simulating an authorization expiry on credit authorizations or credit authorization advice is not currently supported but will be added soon.

Parameters:

  • token (String)

    The transaction token returned from the /v1/simulate/authorize response.

  • amount (Integer)

    Amount (in cents) to void. Typically this will match the amount in the original

  • type (Symbol, Lithic::Models::TransactionSimulateVoidParams::Type)

    Type of event to simulate. Defaults to AUTHORIZATION_REVERSAL.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



353
354
355
356
357
358
359
360
361
362
# File 'lib/lithic/resources/transactions.rb', line 353

def simulate_void(params)
  parsed, options = Lithic::TransactionSimulateVoidParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/simulate/void",
    body: parsed,
    model: Lithic::Models::TransactionSimulateVoidResponse,
    options: options
  )
end