Environment configuration
DOTENV
.env
MIDTRANS_MERCHANT_ID=
MIDTRANS_CLIENT_KEY=
MIDTRANS_SERVER_KEY=
MIDTRANS_IS_PRODUCTION=false
Payment notification webhook
Payment statuses must be updated through an HTTPS endpoint that accepts POST requests from Midtrans. The endpoint must verify the signature and process events idempotently.
Transaction statuses
| Status | Typical action |
|---|---|
| pending | Wait for the payment. |
| capture/settlement | Activate the tokens or transaction benefits exactly once. |
| expire/cancel/deny | Don't add any tokens. |
| refund/chargeback | Reconcile and audit. |
Security
Testing
- Test invalid signatures.
- Test resent webhooks.
- Test the finish, unfinish, and failed redirects.
- Match the order ID, amount, and user.