Real-time decisions with webhook responses
We recommend first reading our Webhooks guide for background.
Overview
When a card network asks us to authorize a transaction, add a card to a digital wallet, or complete a similar request, the network expects an answer within a fixed deadline. A real-time decision is how your application takes part in that answer. We create a Real-Time Decision describing the request, send it to you in a webhook, and read your decision from the body of your HTTP response to that webhook. We then respond to the network based on what you returned.
Setting up
Real-time webhooks are delivered to a single Event Subscription. Its selected_event_categories should contain the one real-time category it handles, such as real_time_decision.card_authorization_requested. Only one active Event Subscription can handle a given real-time category, so each category you handle gets its own subscription.
The decision is carried in the HTTP response, so anything between Increase and your handler, such as a proxy or an API gateway, has to pass your handler’s response body through unchanged.
The webhook
The webhook body is the Real-Time Decision, rendered the same way GET /real_time_decisions/{id} renders it. Its category says what is being asked. For a card authorization, the card_authorization object describes the amount, the merchant, the type of transaction, the verification results, and the network’s risk score. The other categories each have their own object: card_balance_inquiry, card_authentication, card_authentication_challenge, digital_wallet_token, or digital_wallet_authentication.
Each decision has a timeout_at timestamp, which is the deadline for your response. The time available depends on the category, because it comes from the deadline the network gives us for the underlying request. The real-time decisions guide lists the time allowed for each category. Reading timeout_at from the decision is more reliable than assuming a fixed budget.
The webhook body also includes a card object with the Card’s id and the idempotency_key you chose when creating the Card. Because you choose the idempotency key, you can use it to carry an identifier from your own system, such as the cardholder or budget the card belongs to, and look up what your handler needs without first retrieving the Card.
Responding
Return HTTP 200 with a JSON object in the response body. The object has a key named after the decision’s category, whose value is your decision. These objects have the same shape as the parameters of the action endpoint in the API reference, which describes each category’s fields.
For a card authorization, an approval looks like this:
{
"card_authorization": {
"decision": "approve"
}
}
A partial approval authorizes less than the merchant requested. It applies when the merchant supports it, which the request indicates through partial_approval_capability, and the merchant can then collect the remainder another way. The amount is in the minor unit of the settlement currency and must be positive and less than the requested amount. This response authorizes $60 of a $100 request:
{
"card_authorization": {
"decision": "approve",
"approval": {
"partial_amount": 6000
}
}
}
A decline carries a reason, which we translate into a network response code so that the merchant and cardholder can distinguish a funding problem from suspected fraud:
{
"card_authorization": {
"decision": "decline",
"decline": {
"reason": "insufficient_funds"
}
}
}
An approval can also include an address verification result, which is advisory to the acquirer. Address Verification System codes and overrides describes how addresses are evaluated and how your result is used.
Any response can also include an annotation, a string of up to 1,000 characters that we store on the decision without interpreting it. You can use it to link the decision to your own records, for example by serializing a JSON object with your internal identifier for the decision and the rule that applied:
{
"card_authorization": {
"decision": "decline",
"decline": {
"reason": "insufficient_funds"
}
},
"annotation": "{\"authorization_id\":\"auth_8f2c41\",\"rule\":\"travel_budget_exhausted\"}"
}
We check the card’s account balance after reading your response rather than when we send the webhook. If your handler funds an authorization as part of approving it, for example by creating an Account Transfer into the card’s account, the transfer needs to have completed before the response is returned.
How outcomes are recorded
A valid response leaves the decision responded, and the category object on the decision then includes your answer: card_authorization.decision, card_authorization.approval, and so on. If your response included an annotation, the decision’s annotation field returns it.
If your handler does not return a 2xx response before the deadline, or the request fails, the decision is timed_out. By default we decline the authorization, and the resulting Declined Transaction records webhook_timed_out at source.card_decline.reason. Approving under specific conditions when your handler times out is possible; contact support@increase.com to configure it.
Testing in sandbox
Create an active card with enough available balance for the authorizations you will approve. Create an Event Subscription in sandbox selecting real_time_decision.card_authorization_requested, pointing at a handler that returns its decision in the webhook response. Replace the example card identifier below with your card’s identifier.
Simulate a card authorization to request a $100 purchase authorization:
curl -X "POST" \
--url "https://sandbox.increase.com/simulations/card_authorizations" \
-H "Authorization: Bearer ${INCREASE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"card_id": "card_oubs0hwk5rn6knuecxg2",
"amount": 10000,
"merchant_descriptor": "OFFICE SUPPLIES",
"merchant_category_code": "5943",
"merchant_country": "US",
"network_risk_score": 10
}'
Run a new simulation for each response you want to test, then retrieve the decision and check its status. Simulated authorizations support partial approval. They create initial authorizations and omit address and card verification data, so verification results are not_checked.