Payu
Интеграция платёжного шлюза PayU India для Medusa v2 со сценарием редиректа.
npm install @sam-ael/medusa-plugin-payu
Категория
Создано
Сервис
Версия
0.1.4
Последнее обновление
4 месяца назад
Ежемесячные загрузки
Загрузка данных
@sam-ael/medusa-plugin-payu
A production-focused PayU India payment provider plugin for Medusa v2 featuring redirect checkout flow, callback handling, and fraud-aware verification.
Medusa Website | Medusa Repository
Features
- Redirect-Based Checkout: Integrates seamlessly into Medusa payment sessions to route customers to the official PayU checkout portal.
- Secure Hash Verification: Automated generation of checkout hashes and reverse-hash verification for response validation.
- Robust Webhook Integration: Processes real-time transaction updates from PayU to handle capture and payment events.
- Timing-Attack Protection: Employs constant-time string comparison for webhook payload hash validation.
- Replay Protection: Prevents duplicate transaction/webhook submissions via an in-memory key deduplication store.
- Discrepancy Guards: Compares paid amounts against expected payment session amounts to flag underpayment attempts.
Prerequisites
- Node.js v18 or greater
- A Medusa v2 backend
- A PayU India merchant account with a Merchant Key and Merchant Salt
Installation
Run the following command to install the plugin in your Medusa project:
Configuration
1. Register in
Add the PayU provider under the payment module options in :
2. Environment Variables
Define the required credentials and options in your file:
Webhooks
This plugin exposes an inbound webhook endpoint to handle asynchronous payment updates sent by PayU.
| Method | Endpoint | Description |
|---|---|---|
| Processes incoming transaction updates, verifying authenticity using PayU response hashes. |
Webhook Validation
- Hash Verification: Generates a SHA-512 comparison hash using your and incoming payload variables. It uses to check validity.
- Amount Discrepancy Check: Validates that the amount reported in the webhook matches the expected transaction amount (stored in ). If underpaid, it sets the payment status to .
- Replay Guard: Dedupes requests matching the key pattern within a 10-minute window.
Test the Plugin
- Set your backend to use mode ().
- Implement a checkout page on your storefront that resolves a payment session using the provider ID.
- Initiate checkout; you should be redirected to the PayU Sandbox page.
- Complete the test transaction using the test card details provided on PayU's developer documentation.
- PayU will redirect the client back to your storefront, and call the webhook to complete/authorize the order payment in Medusa.

