Открыта бета 1С:ПредприятияОставить заявку
Payu logo

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


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.

MethodEndpointDescription
Processes incoming transaction updates, verifying authenticity using PayU response hashes.

Webhook Validation

  1. Hash Verification: Generates a SHA-512 comparison hash using your and incoming payload variables. It uses to check validity.
  2. 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 .
  3. Replay Guard: Dedupes requests matching the key pattern within a 10-minute window.

Test the Plugin

  1. Set your backend to use mode ().
  2. Implement a checkout page on your storefront that resolves a payment session using the provider ID.
  3. Initiate checkout; you should be redirected to the PayU Sandbox page.
  4. Complete the test transaction using the test card details provided on PayU's developer documentation.
  5. PayU will redirect the client back to your storefront, and call the webhook to complete/authorize the order payment in Medusa.