comgate-node
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

Comgate Payments API Node.js Library

Comgate Payments API Typescript SDK written in Typescript.

Implemented API Methods:

  • create
  • cancel
  • recurring
  • refund
  • capturePreauth
  • cancelPreauth
  • methods
  • status

Documentation

See official Comgate REST API Documentation.

https://apidoc.comgate.cz

Requirements

Node 18 or higher.

Installation

Install the package with:

npm install comgate-node
# or
yarn add comgate-node

Usage

Setup client

import ComgateClient from "comgate-client"

const comgateClient = new ComgateClient({
    merchant: 12345,
    secret: "abcdefgh",
    test: true
})

Examples

import {
    CreateCountry,
    CreateCurr,
    CreateLanguage
} from "comgate-node/types/endpoints/create";

async function create(
    country: CreateCountry, 
    price: number, 
    curr: CreateCurr, 
    label: string, 
    refId: string, 
    method: string,
    email: string, 
    lang: CreateLanguage, 
    prepareOnly: boolean
) {
    try {
        const response = await comgateClient.create({
            country: country,
            price: price,
            curr: curr,
            label: label,
            refId: refId,
            method: method,
            email: email,
            lang: lang,
            prepareOnly: prepareOnly
        })
        console.log('Payment create response:', response);
    } catch (error) {
        console.error('Error create payment:', error);
    }
}

More examples can be found in tests/ folder.

Testing

Test files are located in tests/ folder.

Examples:

Create payment:

ts-node tests/create.ts "CZ" 10000 "CZK" "Order from eshop" "1244" "ALL" "test@test.com" "cs" true

Cancel payment:

ts-node tests/cancel.ts "ABC-0123-1ABC"

Create recurring payment:

# test not implemented

Refund payment:

ts-node ts-node tests/refund.ts "ABC-0123-1ABC" "1000" "CZK"

Capture preauth:

# test not implemented

Cancel preauth:

# test not implemented

Get Methods:

ts-node tests/methods.ts "json" "cs" "CZK" "CZ"

Get Status:

ts-node tests/status.ts "ABC-0123-1ABC"

Maintenance

If you find a bug, please submit the issue in Github directly.

Package Sidebar

Install

npm i comgate-node

Weekly Downloads

3

Version

1.1.2

License

MIT

Unpacked Size

59.3 kB

Total Files

47

Last publish

Collaborators

  • sebelapetr