Methods
| Method | Description |
|---|---|
create(payment) | Create a new payment |
confirm(paymentId) | Confirm a pending payment |
cancel(paymentId) | Cancel a pending payment |
capture(paymentId) | Capture a payment authorized with capture_method: "manual" |
sandboxPaid(paymentId) | Simulate a paid payment (sandbox only) |
sandboxSettle(paymentId) | Simulate settling a payment (sandbox only) |
Create a payment
Payment requests are provider-specific. Pass theprovider field to select the request shape.
Stripe
PagarMe
PagarMe PIX
MercadoPago
Provider request fields
| Field | Stripe | PagarMe | MercadoPago |
|---|---|---|---|
provider | "stripe" | "pagar_me" | "mercado_pago" |
source.currency | Any string | "BRL" | "COP" |
source.payment_method.id | Card PM ID | Card PM ID or omit | — |
source.payment_method.card_token | — | Required if no id | Required |
source.expiry_date | — | Optional (PIX only) | — |
source.fraud_check | Optional (disabled) | Required (card) | — |
destination | Optional (connected accounts) | — | — |
source.capture_method | "automatic" | "manual" | "automatic" | "manual" | "automatic" | "manual" |
source.fraud_check.config.action_on_fail | — | "RETAIN_AUTH" | "CANCEL_AUTH" | — |
flow | "platform" or "destination" | — | — |
allocations | Optional split payments | — | — |
Confirm a payment
Cancel a payment
Capture a payment
If a payment was created withcapture_method: "manual", you must explicitly capture it to collect funds:
Sandbox test helpers
The SDK provides sandbox-only methods to simulate payment state transitions during development.Simulate a paid payment
Simulate settling a payment
sandboxPaid()andsandboxSettle()are restricted to the sandbox environment. Calling them in production returns anEnvironmentViolationError.
Response type
All three methods returnResult<Payment.Response>. The response data extends the original request with additional fields:
| Field | Type | Description |
|---|---|---|
id | string | Payment ID |
status | string | Payment status (e.g., "created", "confirmed", "cancelled") |
type | string | Transaction type (dynamically set) |
created_at | string | ISO timestamp |
updated_at | string | ISO timestamp |
provider_response | object | Raw provider response data |
To issue a refund on a completed payment, see Refunds.