Paytrail
Paytrail payment provider plugin for Medusa
Paytrail Payment Provider Plugin
Paytrail payment provider plugin for Medusa v2.
This package is published to NPM as .
Install
Add the package to your Medusa backend:
Register the plugin and payment provider in your :
Configuration
Required and supported environment variables:
- (optional)
- (recommended, must use HTTPS)
- (optional, seconds, 0-900, default )
- (required, comma-separated values; wildcard supported)
- (, , or )
Example:
If is set, the provider sends Paytrail automatically as:
- success:
- cancel:
maps to Paytrail (seconds). According to Paytrail, when callback URLs are provided, callback delay can be to seconds and defaults to .
Paytrail requires HTTPS callback URLs for both success and cancel callbacks. Example uses Paytrail test credentials
When creating payment sessions, and must use or , include only host/path (no query/hash/auth), and the host must match .
supports wildcard host patterns with , for example:
Features
- Payment session initiation via Paytrail API
- Payment status check for authorization flow
- Refund support
- Callback action parsing and HMAC signature verification
- Custom GET callback route for Paytrail redirect and callback query params
Callback Route
The plugin exposes for Paytrail redirect and callback handling.
The route forwards callback payloads into Medusa's payment webhook pipeline by emitting after validating the signature.
Behavior
- Currency support is limited to by Paytrail.
- Payment sessions are created in status until Paytrail authorizes them.
- Cart completion fails before third-party authorization.
- Standard Paytrail flow is treated as auto-captured after authorization.
Payment Flow
- Store creates a payment session with provider .
- Paytrail returns a redirect URL and .
- Customer authorizes the payment in Paytrail checkout.
- Callback updates the payment status to authorized or captured.
- Cart completion succeeds after authorization.
Troubleshooting
No payment providers available in store
- Ensure the Paytrail provider is linked to the region.
Cart completion returns 400 not authorized
- This is expected before the Paytrail authorization callback is processed.
- Complete the payment in Paytrail before completing the cart.
Callback is not triggered
- Verify is configured with an HTTPS URL.
- Paytrail requires HTTPS callback URLs for both success and cancel callbacks.
Contributing
Bug reports and feature requests are welcome.
When submitting an issue, include:
- A clear description of the problem or requested change
- Steps to reproduce, if applicable
- Relevant configuration details, logs, or screenshots
When submitting a pull request:
- Open an issue first for larger changes so the approach can be discussed
- Keep the PR focused on a single fix or feature
- Include tests or updates to existing tests when behavior changes
- Update the README or other documentation if the public behavior changes
Disclaimer
This package is provided as-is, without warranty of any kind. You are responsible for validating the integration, security, and compliance requirements before using it in production.

