npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nestjs-hyperpay-integration

v1.0.1

Published

NestJS HyperPay Integration

Readme

I'll help you create a comprehensive README.md file for the HyperPay payment integration:

# HyperPay Payment Integration

This module provides integration with HyperPay payment gateway for handling online payments in your NestJS application.

## Installation

```bash
npm install nestjs-hyperpay-integration

Environment Variables

Create a .env file in your project root and add the following variables:

HYPERPAY_ACCESS_TOKEN=your_access_token
HYPERPAY_ENTITY_ID=your_entity_id
HYPERPAY_MODE=TEST  # or LIVE for production
HYPERPAY_CURRENCY=SAR  # default currency
HYPERPAY_MADA_ENTITY_ID=your_mada_entity_id  # optional
HYPERPAY_APPLE_ENTITY_ID=your_apple_entity_id  # optional

Module Setup

Import and configure the HyperPayModule in your payment module:

@Module({
  imports: [
    HyperPayModule.register({
      accessToken: process.env.HYPERPAY_ACCESS_TOKEN,
      entityId: process.env.HYPERPAY_ENTITY_ID,
      mode: process.env.HYPERPAY_MODE as 'TEST' | 'LIVE',
      currency: process.env.HYPERPAY_CURRENCY,
      mada: {
        entityId: process.env.HYPERPAY_MADA_ENTITY_ID,
      },
      apple: {
        entityId: process.env.HYPERPAY_APPLE_ENTITY_ID,
      },
    }),
  ],
  // ... other module configuration
})

Usage

1. Direct Card Payment

@Injectable()
export class PaymentService {
  constructor(private hyperPayService: HyperPayService) {}

  async processPayment(paymentData: any) {
    const paymentRequest = {
      amount: 100.00,
      currency: 'SAR',
      paymentType: 'DB',
      customer: {
        email: '[email protected]',
        givenName: 'John Doe',
      },
      billing: {
        street1: 'Sample Street',
        city: 'Sample City',
        country: 'SA',
      },
    };

    const cardData = {
      number: '4200000000000000',  // Test card number
      holder: 'John Doe',
      expiryMonth: '05',
      expiryYear: '2034',
      cvv: '123',
    };

    try {
      const result = await this.hyperPayService.prepareCheckout(
        paymentRequest,
        cardData,
        'VISA'  // or 'MASTER', 'MADA', etc.
      );

      // Check payment status
      const status = await this.hyperPayService.getPaymentStatus(result.id);
      return status;
    } catch (error) {
      throw new BadRequestException('Payment failed');
    }
  }
}

2. Supported Card Types

  • VISA
  • MASTER
  • MADA
  • APPLEPAY

3. Error Handling

The service throws exceptions for various error cases:

try {
  const result = await this.hyperPayService.prepareCheckout(/* ... */);
} catch (error) {
  if (error.response?.data) {
    // Handle HyperPay API error
    console.error('Payment error:', error.response.data);
  } else {
    // Handle connection/other errors
    console.error('Connection error:', error.message);
  }
}

4. Payment Status Codes

Common status codes returned by HyperPay:

  • 000.100.110: Request successfully processed
  • 000.200.000: Transaction successful
  • 800.400.500: Invalid card data
  • 800.400.501: Invalid card number
  • 800.400.502: Invalid CVV
  • 800.400.503: Invalid expiry date

Security Considerations

  1. Never log full card details
  2. Always use HTTPS
  3. Implement rate limiting
  4. Validate all input data
  5. Store card data securely (encrypted)

Support

For HyperPay API documentation and support:


This README provides a comprehensive guide for developers to integrate and use HyperPay in their NestJS applications. Let me know if you need any clarification or additional sections!