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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tax1driver/ts-tpay

v1.0.0

Published

TPay API wrapper for Node.js

Downloads

108

Readme

ts-tpay

npm version License: MIT

Type-safe wrapper for Polish payment processor tpay.

npm / tpay docs / API Reference / tpay Homepage

  • Auto reauth
  • Fully typed API and DTOs
  • Webhook notification validation

Installation

npm install @tax1driver/ts-tpay

Quick Start

import { TPaySDK } from '@tax1driver/ts-tpay';


const tpay = new TPaySDK({
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret',
  sandbox: true  
});


const transaction = await tpay.transactions.createTransaction({
  amount: 100.50,
  description: 'Order #12345',
  payer: {
    email: '[email protected]',
    name: 'John Doe'
  },
  callbacks: {
    payerUrls: {
      success: 'https://yoursite.com/success',
      error: 'https://yoursite.com/error'
    },
    notification: {
      url: 'https://yoursite.com/webhook'
    }
  }
});


console.log('Payment URL:', transaction.transactionPaymentUrl);

Configuration

Basic Configuration

const tpay = new TPaySDK({
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret',
  sandbox: false  
});

Override Axios instance and extend config

const tpay = new TPaySDK({
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret',
  axiosInstance: userInstance,
  axiosConfig: {
    timeout: 10000,
    headers: { 'Custom-Header': 'value' }
  }
});

Configuration Options

| Option | Type | Default | Description | | --------------- | --------------------------------- | ------- | ------------------------------ | | clientId | string | - | tpay client ID | | clientSecret | string | - | tpay client secret | | sandbox | boolean \| undefined | false | sandbox environment | | | axiosInstance | AxiosInstance \| undefined | - | override axios instance | | axiosConfig | AxiosRequestConfig \| undefined | - | additional axios configuration |

API Reference

Typedoc API Reference

Common usage

Modules

Transactions

Create and manage simple merchant transactions.


const transaction = await tpay.transactions.createTransaction({
  amount: 100.50,
  description: 'Order #12345',
  payer: {
    email: '[email protected]',
    name: 'John Doe',
    phone: '+48123456789'
  },
  callbacks: {
    payerUrls: {
      success: 'https://yoursite.com/success',
      error: 'https://yoursite.com/error'
    },
    notification: {
      url: 'https://yoursite.com/webhook'
    }
  }
});


const details = await tpay.transactions.getTransaction('tr123abc');


const transactions = await tpay.transactions.getTransactions({
  pageNumber: 1,
  pageSize: 20
});


const refunds = await tpay.transactions.getRefunds('tr123abc');

BLIK

Manage BLIK aliases for recurring payments.


const alias = await tpay.blik.createAlias({
  value: '123456',  
  type: 'UID',
  label: 'Customer subscription'
});


const aliasDetails = await tpay.blik.getAlias('alias123');


await tpay.blik.deleteAlias({ value: 'alias123' });

Marketplace

Handle multi-merchant transactions with commission splits.


const marketplaceTx = await tpay.marketplace.createMarketplaceTransaction({
  amount: 100,
  description: 'Marketplace order',
  payer: {
    email: '[email protected]'
  },
  merchantTransactionId: 'order-123',
  childMerchants: [
    {
      merchantId: 'merchant1',
      amount: 80,
      commission: 10,
      description: 'Product from Merchant 1'
    },
    {
      merchantId: 'merchant2',
      amount: 20,
      commission: 2,
      description: 'Product from Merchant 2'
    }
  ]
});


const mpTx = await tpay.marketplace.getMarketplaceTransaction('mpt123');

Tokenization

Store and use payment tokens for recurring payments.


const txWithToken = await tpay.tokenization.createTransactionWithToken({
  amount: 50,
  description: 'Subscription payment',
  payer: {
    email: '[email protected]'
  },
  pay: {
    groupId: 150,  
    cardPayment: {
      card: 'token_abc123',  
      save: false
    }
  }
});


const tokens = await tpay.tokenization.getPayerTokens('payer123');

Wallet

Manage wallet balance and operations.


const balance = await tpay.wallet.getBalance();


const account = await tpay.wallet.getAccount();


const walletTx = await tpay.wallet.getTransactions({
  pageNumber: 1,
  pageSize: 50
});

Refunds

Process refunds for transactions.


const refund = await tpay.refunds.createRefund('tr123abc', {
  amount: 50.25,
  description: 'Partial refund for order #12345'
});


const refundDetails = await tpay.refunds.getRefund('refund123');

Accounts

Manage merchant accounts (marketplace functionality).


const accounts = await tpay.accounts.getAccounts({
  pageNumber: 1,
  pageSize: 20
});


const account = await tpay.accounts.getAccount('account123');


await tpay.accounts.updateAccount('account123', {
  email: '[email protected]'
});

Collect

Manage trusted bank accounts for direct debit payments.


const bankAccount = await tpay.collect.addBankAccount({
  accountNumber: 'PL61109010140000071219812874',
  name: 'John Doe'
});


const accounts = await tpay.collect.getBankAccounts();

Auth

Manually manage OAuth2 tokens (usually handled automatically).


const tokenInfo = await tpay.auth.requestToken();


const currentToken = await tpay.auth.getTokenInfo();

Notifications

Validate webhook notifications from TPay.

import express from 'express';

const app = express();

app.post('/webhook', express.raw({ type: 'application/jose' }), async (req, res) => {
  try {
    
    const notification = await tpay.notifications.validateNotification(
      req.body,  
      req.headers['x-jws-signature'] as string
    );
    
    console.log('Valid notification:', notification);
    console.log('Transaction ID:', notification.tr_id);
    console.log('Status:', notification.tr_status);
    
    res.status(200).send('OK');
  } catch (error) {
    console.error('Invalid notification:', error);
    res.status(400).send('Invalid signature');
  }
});

Webhook Notification Handling

TPay sends webhook notifications as JWS-signed tokens. Always validate signatures:


const notification = await tpay.notifications.validateNotification(
  joseToken,
  jwsSignature
);


const notification = await tpay.notifications.validateNotification(
  joseToken,
  jwsSignature,
  {
    trustedCertPath: './custom-cert.pem',  
    issuer: 'api.tpay.com'  
  }
);


switch (notification.tr_status) {
  case 'correct':
    
    break;
  case 'pending':
    
    break;
  case 'error':
    
    break;
}

Environment URLs

  • Sandbox API: https://openapi.sandbox.tpay.com
  • Production API: https://openapi.tpay.com

Links