Skip to content

A cryptocurrency payment gateway plugin for Vendure that integrates with NOWPayments.io.

License

Notifications You must be signed in to change notification settings

psychomet/vendure-nowpayments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

108 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Vendure NOWPayments Plugin

A Vendure plugin that integrates NOWPayments cryptocurrency payment processing into your e-commerce store.

πŸš€ Features

  • Cryptocurrency Payments: Accept Bitcoin, Ethereum, and 1000+ other cryptocurrencies
  • IPN (Instant Payment Notification): Real-time payment status updates
  • Secure Payment Processing: Built-in signature verification for webhook security
  • Vendure Integration: Seamless integration with Vendure's payment system
  • TypeScript Support: Full TypeScript support with type safety

πŸ“¦ Installation

npm install vendure-plugin-nowpayments

πŸ”§ Configuration

1. Add the plugin to your Vendure config

import { VendureConfig } from '@vendure/core';
import { NOWPaymentsPlugin } from 'vendure-plugin-nowpayments';

export const config: VendureConfig = {
  plugins: [
    NOWPaymentsPlugin.init({
      apiKey: 'your-nowpayments-api-key',
      ipnSecret: 'your-ipn-secret-key',
      sandbox: false, // Set to true for testing
    }),
  ],
  // ... rest of your config
};

2. Environment Variables

# Required
NOWPAYMENTS_API_KEY=your-api-key-here
NOWPAYMENTS_IPN_SECRET=your-ipn-secret-here

# Optional
NOWPAYMENTS_SANDBOX=true  # Set to true for testing

🎯 Usage

Payment Method Setup

  1. Create a Payment Method in your Vendure admin
  2. Configure NOWPayments with your API credentials
  3. Set up IPN endpoint at /nowpayments/ipn

Payment Statuses

The plugin handles the following NOWPayments payment statuses:

  • finished β†’ PaymentSettled (Payment completed successfully)
  • partially_paid β†’ PaymentAuthorized (Partial payment received)
  • confirming β†’ PaymentAuthorized (Payment is being confirmed)
  • confirmed β†’ PaymentAuthorized (Payment confirmed on blockchain)
  • sending β†’ PaymentAuthorized (Payment is being sent)
  • waiting β†’ PaymentAuthorized (Payment is waiting for user action)
  • expired β†’ PaymentDeclined (Payment has expired)
  • failed β†’ PaymentDeclined (Payment failed)

API Endpoints

IPN Webhook

POST /nowpayments/ipn

The plugin automatically handles IPN (Instant Payment Notification) from NOWPayments to update order status.

πŸ” Security

  • Signature Verification: All IPN requests are verified using HMAC-SHA256
  • Request Validation: Comprehensive validation of payment data
  • Error Handling: Secure error responses without exposing sensitive information

πŸ› οΈ Development

Prerequisites

  • Node.js 18+
  • npm/yarn/pnpm
  • Vendure 3.0+

Setup Development Environment

# Clone the repository
git clone https://github.com/psychomet/vendure-nowpayments.git
cd vendure-nowpayments

# Install dependencies
npm install

# Build the plugin
npx nx build vendure-plugin-nowpayments

# Run tests
npx nx test vendure-plugin-nowpayments

Project Structure

packages/vendure-plugin-nowpayments/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ constants.ts          # Plugin constants
β”‚   β”‚   β”œβ”€β”€ nowpayments.controller.ts  # IPN endpoint
β”‚   β”‚   β”œβ”€β”€ nowpayments.service.ts     # Core business logic
β”‚   β”‚   β”œβ”€β”€ nowpayments.plugin.ts      # Plugin definition
β”‚   β”‚   └── types.ts                   # TypeScript types
β”‚   └── index.ts                  # Main entry point
β”œβ”€β”€ package.json
└── tsconfig.json

πŸ§ͺ Testing

# Run unit tests
npx nx test vendure-plugin-nowpayments

# Run with coverage
npx nx test vendure-plugin-nowpayments --coverage

πŸ“¦ Building

# Build the plugin
npx nx build vendure-plugin-nowpayments

# Build with type checking
npx nx typecheck vendure-plugin-nowpayments

πŸš€ Release

The project uses Nx Release for automated versioning and publishing.

Automatic Releases

The plugin automatically releases when you push conventional commits to the main branch:

# Minor version bump
git commit -m "feat: add new payment method"

# Patch version bump
git commit -m "fix: resolve authentication issue"

# No version bump
git commit -m "docs: update README"

Manual Release

# Preview release
npx nx release vendure-plugin-nowpayments --dry-run

# Create release
npx nx release vendure-plugin-nowpayments --yes

πŸ“‹ Supported Cryptocurrencies

NOWPayments supports 1000+ cryptocurrencies including:

  • Bitcoin (BTC)
  • Ethereum (ETH)
  • Litecoin (LTC)
  • Bitcoin Cash (BCH)
  • And many more...

See the NOWPayments supported currencies for the complete list.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Conventional Commits for commit messages
  • Write tests for new features
  • Update documentation as needed
  • Ensure TypeScript compilation passes

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

πŸ™ Acknowledgments

  • Vendure - The amazing e-commerce framework
  • NOWPayments - Cryptocurrency payment processing
  • Nx - Monorepo tooling

Made with ❀️ by the Vendure community

About

A cryptocurrency payment gateway plugin for Vendure that integrates with NOWPayments.io.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published