Przelewy24 (P24) payment integration plugin for Medusa e-commerce with BLIK, cards, and general P24 support.
A comprehensive payment provider plugin that enables Przelewy24 payments on Medusa V2 projects.
Multiple Payment Methods: Supports a wide range of Przelewy24 payment methods including:
Modular Architecture: Multiple services in a single module provider for easy management.
Webhook Support: Full support for Przelewy24 webhooks for real-time payment status updates.
TypeScript Support: Full TypeScript implementation with proper types.
Sandbox Mode: Built-in sandbox support for testing.
[!WARNING] > This plugin has not been tested on a live store. Please conduct thorough testing before using it in a production environment. GMI Software is not responsible for any missed or failed payments resulting from the use of this plugin. If you encounter any issues, please report them here.
[!NOTE] > You can get your API credentials from your Przelewy24 merchant panel
yarn add p24-medusa-plugin
Add the provider to the module in your file:
1import { Modules } from "@medusajs/framework/utils";23module.exports = defineConfig({4 modules: [5 {6 resolve: "@medusajs/medusa/payment",7 options: {8 providers: [9 {10 resolve:11 "@gmisoftware/przelewy24-payments-medusa/providers/przelewy24",12 id: "przelewy24",13 options: {14 api_key: process.env.P24_API_KEY,15 merchant_id: process.env.P24_MERCHANT_ID,16 pos_id: process.env.P24_POS_ID,17 crc: process.env.P24_CRC,18 sandbox: process.env.P24_IS_SANDBOX,19 frontend_url: process.env.MEDUSA_STORE_URL,20 backend_url: process.env.MEDUSA_BACKEND_URL,21 },22 },23 ],24 },25 },26 ],27 plugins: ["@gmisoftware/przelewy24-payments-medusa"],28});
| Option | Description | Required | Default |
|---|---|---|---|
| P24 Merchant ID | Yes | - | |
| P24 POS ID | Yes | - | |
| P24 API Key | Yes | - | |
| P24 CRC Key for signature verification | Yes | - | |
| Enable sandbox mode | No | ||
| Frontend URL for customer redirects | No | ||
| Backend URL for webhook notifications | No |
Create or update your file with the following variables:
1# P24 Configuration2P24_MERCHANT_ID=your_merchant_id3P24_POS_ID=your_pos_id4P24_API_KEY=your_api_key5P24_CRC=your_crc_key67# URL Configuration8FRONTEND_URL=https://your-frontend-domain.com9BACKEND_URL=https://your-backend-domain.com
Once installed and configured, the Przelewy24 payment methods will be available in your Medusa admin. To enable them, log in to your Medusa Admin, browse to Settings > Regions, add or edit a region and select the desired P24 providers from the dropdown.
Make sure that the selected payment methods are enabled in your Przelewy24 merchant panel as well.
To integrate with your storefront, you'll need to implement the payment flow according to Przelewy24's and Medusa's documentation. Here's a basic example:
BLIK payments use a two-phase flow:
Phase 1: Create Payment Session
1// Create payment session for BLIK2const paymentSession = await medusa.payment.createPaymentSession({3 provider_id: "p24-blik",4 amount: 10000, // 100.00 PLN in grosze5 currency_code: "PLN",6 data: {7 country: "PL", // Country code (defaults to "PL" if not provided)8 language: "pl", // Language code (defaults to "pl" if not provided)9 },10 context: {11 email: "customer@example.com",12 },13});1415// Response includes session_id and token, but no redirect_url16console.log(paymentSession.data.session_id); // Use this for BLIK processing
Phase 2: Process BLIK Code
1// Call internal API to process BLIK code2const blikResponse = await fetch("/admin/plugin/blik", {3 method: "POST",4 headers: {5 "Content-Type": "application/json",6 },7 body: JSON.stringify({8 token: paymentSession.data.token, // Token from payment session9 blikCode: "123456", // 6-digit BLIK code from user10 }),11});
1// Create payment session for cards2const paymentSession = await medusa.payment.createPaymentSession({3 provider_id: "p24-cards",4 amount: 10000, // 100.00 PLN in grosze5 currency_code: "PLN",6 data: {7 country: "PL", // Country code (defaults to "PL" if not provided)8 language: "pl", // Language code (defaults to "pl" if not provided)9 },10 context: {11 email: "customer@example.com",12 billing_address: {13 country_code: "PL",14 },15 },16});1718// Redirect user to payment URL19window.location.href = paymentSession.data.redirect_url;
1// Create payment session for general P242const paymentSession = await medusa.payment.createPaymentSession({3 provider_id: "p24-general",4 amount: 10000,5 currency_code: "PLN",6 data: {7 country: "PL", // Country code (defaults to "PL" if not provided)8 language: "pl", // Language code (defaults to "pl" if not provided)9 },10 context: {11 email: "customer@example.com",12 },13});1415// Redirect user to P24 payment selection16window.location.href = paymentSession.data.redirect_url;
The plugin currently supports the following Przelewy24 payment methods:
| Payment Method | Provider ID |
|---|---|
| BLIK | |
| Cards | |
| General P24 |
Note: BLIK payments don't use redirect URLs. The entire flow happens through API calls.
The plugin provides webhook endpoints for each provider:
Configure these URLs in your P24 merchant panel.
Note: The webhook URLs follow Medusa's pattern: where:
To add support for additional Przelewy24 payment methods, create a new service in that extends the class:
1import P24Base from "../core/p24-base";2import { PaymentOptions } from "../types";34class P24NewMethodService extends P24Base {5 static identifier = "p24-new-method";67 get paymentCreateOptions(): PaymentOptions {8 return {9 method: "new_method",10 };11 }12}1314export default P24NewMethodService;
Make sure to replace with the actual Przelewy24 payment method ID.
Export your new service from . Then add your new service to the list of services in .
In case you want to customize and test the plugin locally, refer to the Medusa Plugin docs.
MIT License