Marqeta.GatewayJIT (marqeta v1.0.0)

Copy Markdown View Source

Utilities for handling Gateway Just-in-Time (JIT) Funding requests.

When using Gateway JIT Funding, Marqeta sends a synchronous funding request to your gateway endpoint for every authorization. Your gateway must respond with an approval or denial within the configured timeout (typically 1.5–3 seconds).

Request Flow

Cardholder swipes card
      
Network sends authorization to Marqeta
      
Marqeta sends JIT request  YOUR GATEWAY (sync, ~1.5s timeout)
      
Your gateway responds approve/deny
      
Marqeta approves/declines the network authorization
      
Marqeta sends async webhook notification (informative)

JIT Methods

Actionable (require a funding response)

  • pgfs.authorization — standard purchase authorization
  • pgfs.authorization.account_verification — zero-dollar card validation
  • pgfs.auth_plus_capture — single-message (PIN debit / ATM)
  • pgfs.balance_inquiry — balance inquiry

Informative (no response needed — just acknowledge)

  • pgfs.authorization.capture — funds captured after authorization
  • pgfs.authorization.capture.chargeback — chargeback processed
  • pgfs.authorization.reversal — authorization reversed
  • pgfs.authorization.clearing — settlement complete
  • pgfs.adjustment.credit — credit adjustment applied
  • pgfs.adjustment.debit — debit adjustment applied

Examples

# In your gateway controller (Plug/Phoenix):
def handle(conn, params) do
  alias Marqeta.GatewayJIT

  response =
    if GatewayJIT.actionable?(params) do
      user_token = GatewayJIT.user_token(params)
      amount     = GatewayJIT.amount(params)
      mcc        = GatewayJIT.mcc(params)

      cond do
        blocked_mcc?(mcc)       -> GatewayJIT.decline(params, reason: "TRANSACTION_NOT_PERMITTED")
        insufficient?(user_token, amount) -> GatewayJIT.decline(params, reason: "INSUFFICIENT_FUNDS")
        true                    -> GatewayJIT.approve(params)
      end
    else
      # Informative — return a minimal acknowledgement
      GatewayJIT.ack(params)
    end

  json(conn, response)
end

Summary

Functions

Returns true if this is a zero-dollar account verification.

Builds an acknowledgement response for informative JIT notifications. Use this when actionable?/1 returns false.

Returns the acting user token (may differ from user_token in hierarchical accounts).

Returns true if the JIT request requires a funding decision response.

Returns the requested funding amount.

Builds an approval response for a JIT funding request.

Returns true if this is an ATM / single-message transaction.

Returns the card token from a JIT request.

Returns the merchant country from a JIT request.

Returns the currency code from a JIT request.

Builds a decline response for a JIT funding request.

List of all valid decline reasons.

Returns the MCC code from a JIT request.

Returns the merchant name from a JIT request.

Returns the JIT method string.

Returns the transaction type (e.g. "gpa.credit").

Returns the user token from a JIT request.

Functions

account_verification?(request)

@spec account_verification?(map()) :: boolean()

Returns true if this is a zero-dollar account verification.

ack(request)

@spec ack(map()) :: map()

Builds an acknowledgement response for informative JIT notifications. Use this when actionable?/1 returns false.

acting_user_token(arg1)

@spec acting_user_token(map()) :: String.t() | nil

Returns the acting user token (may differ from user_token in hierarchical accounts).

actionable?(arg1)

@spec actionable?(map()) :: boolean()

Returns true if the JIT request requires a funding decision response.

amount(arg1)

@spec amount(map()) :: number() | nil

Returns the requested funding amount.

approve(request, opts \\ [])

@spec approve(
  map(),
  keyword()
) :: map()

Builds an approval response for a JIT funding request.

Options

  • :amount — Override the approved amount (partial approval). Defaults to request amount.
  • :memo — Optional memo string (max 99 chars).
  • :metadata — Optional map of metadata (max 20 keys).
  • :tags — Optional tags string.

approve_response(request, opts \\ [])

See Marqeta.GatewayJIT.approve/2.

auth_plus_capture?(request)

@spec auth_plus_capture?(map()) :: boolean()

Returns true if this is an ATM / single-message transaction.

card_token(arg1)

@spec card_token(map()) :: String.t() | nil

Returns the card token from a JIT request.

country(arg1)

@spec country(map()) :: String.t() | nil

Returns the merchant country from a JIT request.

currency(arg1)

@spec currency(map()) :: String.t() | nil

Returns the currency code from a JIT request.

decline(request, opts \\ [])

@spec decline(
  map(),
  keyword()
) :: map()

Builds a decline response for a JIT funding request.

Decline Reasons

  • "INSUFFICIENT_FUNDS"
  • "INVALID_MERCHANT"
  • "TRANSACTION_NOT_PERMITTED"
  • "SUSPECTED_FRAUD"
  • "DO_NOT_HONOR"
  • "CARD_NOT_ACTIVE"
  • "EXCEEDS_LIMIT"

Options

  • :reason — Decline reason string. Defaults to "DO_NOT_HONOR".
  • :memo — Optional memo.

decline_reasons()

@spec decline_reasons() :: [String.t()]

List of all valid decline reasons.

decline_response(request, opts \\ [])

See Marqeta.GatewayJIT.decline/2.

mcc(arg1)

@spec mcc(map()) :: String.t() | nil

Returns the MCC code from a JIT request.

merchant_name(arg1)

@spec merchant_name(map()) :: String.t() | nil

Returns the merchant name from a JIT request.

method(arg1)

@spec method(map()) :: String.t() | nil

Returns the JIT method string.

transaction_type(arg1)

@spec transaction_type(map()) :: String.t() | nil

Returns the transaction type (e.g. "gpa.credit").

user_token(arg1)

@spec user_token(map()) :: String.t() | nil

Returns the user token from a JIT request.