Skip to content

Debit the card a session registered

POST
/api/sessions/{sessionId}/debit
curl -s -X POST "https://services.sandbox.payplug-elements.msem.tech/api/sessions/0193f6c1-7a2e-7b4d-9f01-2c3d4e5f6a7b/debit" \
-H "authorization: Bearer $ACCESS_TOKEN" \
-H "idempotency-key: retenue-EP-123456-01" \
-H "content-type: application/json" \
-d '{
"amount": 8000,
"extraData": "retenue-EP-123456-01"
}'

A later debit on the card the session registered (mustCreateAlias, createAlias in subscription mode), without your customer: a deposit withheld, a charge found after the service. Answers 202 with the debit — usually still in flight: its verdict follows in the debit webhook, on your notification URL. Within maximumFutureDebit when the session declared one: per debit, or in total for a guarantee. Tell your customer yourself: the platform does not. Contacts and client_credentials alike.

sessionId
required
string format: uuid
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/

The session, as a search returned it. A lowercase UUID — the ones we mint are v7.

Example
0193f6c1-7a2e-7b4d-9f01-2c3d4e5f6a7b
idempotency-key
string
>= 1 characters <= 64 characters

Makes the gesture replayable: a retry presenting a key already recorded on this session gets the recorded debit back — never a second one. Recommended.

Example
retenue-EP-123456-01
Media typeapplication/json
object
amount
required

Minor units to debit. Within maximumFutureDebit when the session declared one: per debit, or in total for a guarantee.

integer
>= 1
Example
8000
extraData

Your reconciliation tag for THIS debit — sent to the PSP, and back in the debit webhook.

string
>= 1 characters <= 255 characters
Example
retenue-EP-123456-01

The debit this call started, with its attempt and session — read transaction.status.

Media typeapplication/json
object
debit
required

The transaction, with the home that gives it meaning — session, order, attempt.

object
sessionId
required

The session this belongs to.

string format: uuid
merchantId
required

The merchant it belongs to.

string
orderId
required

Their own order reference.

string
attemptId
required

The attempt it belongs to.

string format: uuid
method
required

What the attempt behind this operation was paid with — card, paypal, wero… An operation alone does not say it, and reading a list of PSP operations without it means opening each one.

string
cardScheme

The card network that attempt ran on, when the PSP named one we could place — see the same field on an attempt.

string
cardCode

The card as the PSP masked it — see the same field on an attempt.

string
cardCountry

The country of the card’s issuer — see the same field on an attempt.

string
provider
required

The PSP adapter that served the attempt (D-051) — whose dashboard the references live in.

string
transaction
required

The operation itself.

object
transactionId
required

Our handle for this PSP operation — what a refund door addresses.

string format: uuid
createdAt
required

When the operation was opened — epoch milliseconds (Q13).

integer
updatedAt
required

The last event that touched it — for a terminal transaction, its verdict’s instant.

integer
type
required

What this operation asked the PSP: hold the money, take it in one go, capture a hold, release a hold, send money back, or debit the registered card later.

string
Allowed values: authorization payment capture void refund debit
amount
required

What this operation moved, in minor units.

object
amount
required

Amount in the MINOR unit of the currency — 1000_00 is one thousand euros, never 1000.

integer
currency
required

ISO 4217 code, uppercase. One currency per session.

string
/^[A-Z]{3}$/
providerRef

The PSP’s reference — what their dashboard greps (D-047).

string
status
required

The VERDICT facet: what the PSP finally decided about this operation — as opposed to the ack facet below, which is what the driving call answered on the spot.

object
kind
required

Where the operation stands. pending means the verdict is still due — it always arrives out-of-band.

string
Allowed values: pending succeeded failed cancelled
statusCode

The PSP’s own code, split at the source — successes carry theirs too.

string
statusMessage

The PSP’s own sentence, as they said it — never glued to the code.

string
category

What a refusal means, when the PSP’s answer could be read.

string
Allowed values: bank-refusal insufficient-funds invalid-card-data authentication-failed expired method-unavailable
ackCode

What the driving call answered (the ack facet).

string
ackMessage

What the driving call said — a transport failure’s raw cause included.

string
ackHttpStatus

Absent beside a present ackMessage = no HTTP response ever came.

integer
ackTraceId

The PSP’s own reference for the driving call’s exchange, when it named one — what its support asks for.

string
extraData

The caller’s reconciliation tag, on refunds only (lot 5) — echoed verbatim.

string
replayOf

The refused operation this one replays — asked again by an administrator.

string
refundOf

On a refund: the later debit it gives back — absent, the attempt’s own taking.

string
Example
{
"debit": {
"method": "card",
"cardScheme": "visa",
"cardCode": "497010XXXXXX0007",
"cardCountry": "FR",
"provider": "dalenys",
"transaction": {
"type": "authorization",
"status": {
"kind": "pending",
"category": "bank-refusal"
}
}
}
}

InvalidRequest — the request could not be read: a missing or malformed field, a bad pattern, or a property this door does not declare (the message names it). Every door with a schema can answer this, before any business rule is consulted. Most often here: InvalidRequestedAmount — the domain’s own refusal of an amount that is not a positive number of minor units, raised after validation has passed. Declared because the code can answer it.

Media typeapplication/json
object
code
required

Stable machine-readable code — the one thing to branch on. Never parse the message.

string
message
required

English sentence for logs and operators. Wording may change; the code will not.

string
Example
{
"code": "InvalidRequestedAmount",
"message": "the debit amount must be a positive integer of minor units"
}

Unauthorized — the only code this response carries: no usable access token (absent, malformed, expired). One answer for every failure shape, so nothing can be learned by watching which one comes back.

Media typeapplication/json
object
code
required

Stable machine-readable code — the one thing to branch on. Never parse the message.

string
message
required

English sentence for logs and operators. Wording may change; the code will not.

string
Example
{
"code": "Unauthorized",
"message": "a valid access token is required"
}

NotFound — the only code this response carries: unknown, or belonging to another merchant. The two are deliberately indistinguishable.

Media typeapplication/json
object
code
required

Stable machine-readable code — the one thing to branch on. Never parse the message.

string
message
required

English sentence for logs and operators. Wording may change; the code will not.

string
Example
{
"code": "NotFound",
"message": "no such resource"
}

Not NOW: the session is not paid (DebitRequiresPaidSession), a debit is already in flight (DebitInFlight), the amount goes past the ceiling (DebitExceedsCeiling), or the registration has expired (CardRegistrationExpired).

Media typeapplication/json
object
code
required

Stable machine-readable code — the one thing to branch on. Never parse the message.

string
message
required

English sentence for logs and operators. Wording may change; the code will not.

string
Example
{
"code": "DebitExceedsCeiling",
"message": "the guarantee's ceiling is 15000 in total"
}

Never on this session: no card was registered (NoRegisteredCard), it was registered for the customer to pay again (DebitRequiresSubscription), the PSP cannot (DebitNotSupported) — or the Idempotency-Key already names a debit of a DIFFERENT amount (IdempotencyKeyConflict).

Media typeapplication/json
object
code
required

Stable machine-readable code — the one thing to branch on. Never parse the message.

string
message
required

English sentence for logs and operators. Wording may change; the code will not.

string
Example
{
"code": "DebitRequiresSubscription",
"message": "the card was registered for the payer to pay again"
}