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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mr-luke/przelewy24

v1.0.1

Published

Universal Przelewy24 driver for JS applications.

Downloads

12

Readme

Przelewy24 javascript driver

Package is build in Typescript with target build set to ES5.

Warning! This is still RC.

Installation

To install through npm, simply put the following lines into package.json

{
    "dependencies": {
        "@mr-luke/przelewy24": "~1.0"
    }
}

or use the following command:

npm i @mr-luke/przelewy24

Getting started

Javasrcript sample:

import createInstance from '@mr-luke/przelewy24'

const przelewy24 = createInstance({
  live: false
  merchant: 12345
  currency: 'PLN'
  country: 'PL'
  salt: 'abcdefghi'
})

przelewy24.test().then(response => {
  if (response.status == 'success') {
    console.log('Test connection succeed.')
  } else {
    console.log('Test connection failed.')
  }
})

Typescript sample:

import createInstance from '@mr-luke/przelewy24'
import { Config, PrzelewyInstance, Response } from '@mr-luke/przelewy24'

const config: Config = {
  live: false
  merchant: 12345
  currency: 'PLN'
  country: 'PL'
  salt: 'abcdefghi'
}
const przelewy24: PrzelewyInstance = createInstance(config)

przelewy24.test().then(response: Response => {
  if (response.status == 'success') {
    console.log('Test connection succeed.')
  } else {
    console.log('Test connection failed.')
  }
})

The following documentation will be written using Typescript notation to be more specify about structure requirements.

Methods

PrzelewyInstance provides 3 methods to interact with Przelewy24 payments provider. You can test connection, register new transaction or verify callback from the provider.

  • przelewy24.test(): Promise<Response>

    test your connection with Przelewy24

  • przelewy24.register(transaction: Transaction, callbacks: Callbacks): Promise<Response>

    register new transaction in Przelewy24 & return redirect transaction Url

  • przelewy24.verify(payload: Verification): Promise<Response>

    verify & confirm transaction from callback call

Przelewy driver Api

Callbacks

Object interface.

interface Config {
  returnUri: string
  statusUri: string
}

Hasher

Hasher class uses to create md5 signature.

Http

Http class uses to call przelewy24 http api.

HttpInstance

Http class interface.

interface Http {
  request(config: HttpRequest): Promise<HttpResponse>
}

HttpRequest

Object interface.

interface HttpRequest {
  url: string
  data: object
}

HttpResponse

Object interface.

interface HttpResponse {
  status: number
  success: boolean
  data?: any
}

Przelewy

Przelewy class uses to prepare & communicate with przelewy24 api.

PrzelewyInstance

Przelewy class interface.

interface Przelewy {
  live: boolean

  register(transaction: Transaction, callbacks: Callbacks): Promise<Response>
  test(): Promise<Response>
  verify(payload: Verification): Promise<Response>
}

Response

Object interface.

{
  url: 'string'
  data: 'object'
}

Transaction

Object interface.

interface Transaction {
  sessionId: string|number
  amount: number
  description: string
  email: string
  client?: string
  address?: string
  zip?: string
  city?: string
  phone?: string
  language?: string
  method?: number
  shouldWait?: number
  channel?: number
  shipping?: number
  transferLabel?: string
  items: Item[]
}

TransactionItem

Object interface

interface TransactionItem {
  name: string
  quantity: number
  price: number
  description?: string
  id?: number
}

Verification

Object interface

interface Verification {
  p24_merchant_id: string|number
  p24_pos_id: string|number
  p24_session_id: string|number
  p24_amount: number
  p24_currency: Currency
  p24_order_id: number
  p24_method: number
  p24_statement: string
  p24_sign: string
}

Version

Version class uses as a base http api configuration.

VersionInstance

Version class interface.

interface Version {
  getTarget(target: Target, isLive: boolean): string
  getVersion(): string
  getUri(isLive: boolean): string
}

Custom instance

You can create custom instance of Przelewy by following requirements from it's interface.

import { Config, Hasher, HttpInstance, Przelewy, PrzelewyInstance, VersionInstance }

const przelewy: PrzelewyInstance = new Przelewy(
  config: Config,
  http: HttpInstance,
  version: VersionInstance
  hasher: Hasher
)