Class: Airwallex::IssuingTransaction

Inherits:
APIResource show all
Defined in:
lib/airwallex/resources/issuing_transaction.rb

Overview

Represents a card (Issuing) transaction event.

This gem currently only implements the sandbox Simulation endpoints for issuing transactions — creating an authorization, capturing/reversing a PENDING one, refunding a CAPTURED one, and delivering a 3DS delegation notification. It does not yet implement the live Issuing resources (Card, Cardholder) or the live transaction retrieve/list endpoints. See https://www.airwallex.com/docs/api/simulation/issuing-transactions

Examples:

Authorize, then capture in full

txn = Airwallex::IssuingTransaction.simulate_create(
  card_id: "card_123",
  transaction_amount: 25.00,
  transaction_currency: "USD"
)
Airwallex::IssuingTransaction.simulate_capture(txn.transaction_id)

Authorize and clear in a single step

Airwallex::IssuingTransaction.simulate_create(
  card_id: "card_123",
  transaction_amount: 25.00,
  transaction_currency: "USD",
  single_phase: true
)

Instance Attribute Summary

Attributes inherited from APIResource

#attributes, #id

Class Method Summary collapse

Methods inherited from APIResource

#changed_attributes, #dirty?, #initialize, #inspect, #method_missing, #refresh, #refresh_from, resource_name, #respond_to_missing?, symbolized_get, symbolized_post, #to_hash, #to_json, #to_s

Constructor Details

This class inherits a constructor from Airwallex::APIResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Airwallex::APIResource

Class Method Details

.resource_path ⇒ String

Returns API resource path for simulated issuing transactions.

Returns:

  • (String) —

    API resource path for simulated issuing transactions



30
31
32
# File 'lib/airwallex/resources/issuing_transaction.rb', line 30

def self.resource_path
  "/api/v1/simulation/issuing"
end

.simulate_capture(transaction_id, params = {}) ⇒ IssuingTransaction

Simulate capturing a PENDING transaction

Parameters:

  • transaction_id (String) —

    the transaction_id from .simulate_create's response

  • params (Hash) (defaults to: {}) —

    merchant_info:, transaction_amount: (optional — a partial capture if less than the authorized amount, full amount if omitted)

Returns:



56
57
58
59
60
61
# File 'lib/airwallex/resources/issuing_transaction.rb', line 56

def self.simulate_capture(transaction_id, params = {})
  response = Airwallex.client.post(
    "#{resource_path}/card_transaction_lifecycles/#{transaction_id}/capture", params
  )
  new(response)
end

.simulate_create(params = {}) ⇒ IssuingTransaction

Simulate a card authorization (or, with single_phase: true, an authorization cleared in one step)

Parameters:

  • params (Hash) (defaults to: {}) —

    card_id: (or card_number:), transaction_amount:, transaction_currency: (required); single_phase:, auth_code:, merchant_category_code:, merchant_info:, transaction_failure_reason: (optional)

Returns:

  • (IssuingTransaction) —

    the resulting transaction — read its transaction_id to pass to .simulate_capture/.simulate_reverse



43
44
45
46
# File 'lib/airwallex/resources/issuing_transaction.rb', line 43

def self.simulate_create(params = {})
  response = Airwallex.client.post("#{resource_path}/create", params)
  new(response)
end

.simulate_notify_three_ds(params = {}) ⇒ Hash

Simulate a 3DS delegation-mode notification for a card

Parameters:

  • params (Hash) (defaults to: {}) —

    card_number: (required); merchant_info: (object, optional: acquirer_id:, merchant_category_code:, merchant_country_code:, merchant_id:, merchant_name:, merchant_url:)

Returns:

  • (Hash) —

    raw response



96
97
98
# File 'lib/airwallex/resources/issuing_transaction.rb', line 96

def self.simulate_notify_three_ds(params = {})
  Airwallex.client.post("#{resource_path}/threeds/notify", params)
end

.simulate_refund(params = {}) ⇒ IssuingTransaction

Simulate refunding a CAPTURED, not-fully-refunded transaction back to the card

Parameters:

  • params (Hash) (defaults to: {}) —

    card_id: (or card_number:), transaction_amount:, transaction_currency: (required); merchant_category_code:, merchant_info: (optional)

Returns:



85
86
87
88
# File 'lib/airwallex/resources/issuing_transaction.rb', line 85

def self.simulate_refund(params = {})
  response = Airwallex.client.post("#{resource_path}/refund", params)
  new(response)
end

.simulate_reverse(transaction_id, params = {}) ⇒ IssuingTransaction

Simulate reversing a PENDING transaction

Parameters:

  • transaction_id (String) —

    the transaction_id from .simulate_create's response

  • params (Hash) (defaults to: {}) —

    transaction_amount: (optional — a partial reversal if less than the authorized amount, full reversal if omitted)

Returns:



71
72
73
74
75
76
# File 'lib/airwallex/resources/issuing_transaction.rb', line 71

def self.simulate_reverse(transaction_id, params = {})
  response = Airwallex.client.post(
    "#{resource_path}/card_transaction_lifecycles/#{transaction_id}/reverse", params
  )
  new(response)
end