# paytm-node-typescript

> [![npm](https://img.shields.io/npm/v/paytm-node-typescript.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/paytm-node-typescript)

Latest version **1.0.5** (published 2021-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install paytm-node-typescript
pnpm add paytm-node-typescript
yarn add paytm-node-typescript
bun add paytm-node-typescript
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-09-07 |
| First published | 2021-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 75.3 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vikas |
| Maintainers | vikasrgorg |

## Links

- npm: https://www.npmjs.com/package/paytm-node-typescript
- Repository: https://github.com/vikasg603/paytm-typescript
- Issues: https://github.com/vikasg603/paytm-typescript/issues
- npm.io page: https://npm.io/package/paytm-node-typescript

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.21.1

## Recent versions

- 1.0.5 (latest) — 2021-09-07
- 1.0.4 — 2021-09-07
- 1.0.3 — 2021-08-12
- 1.0.2 — 2021-08-12
- 1.0.1 — 2021-08-12
- 1.0.0 — 2021-08-12

## README

# Paytm Node SDK

[![npm](https://img.shields.io/npm/v/paytm-node-typescript.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/paytm-node-typescript)

Unofficial nodejs library for [Paytm API](https://developer.paytm.com/docs) with typescript support.

Read up here for getting started and understanding the payment flow with Paytm: [https://developer.paytm.com/docs](https://developer.paytm.com/docs)

## Why this library?

1.  Typescript support.
2.  Removed traditional way of adding field inside the object.
3.  Improved code to make it easy to opt for any future changes.
4.  Removed deprecated request and shifted to Axios (https://github.com/request/request/issues/3142).
5.  Standard PaytmError class for handling all the errors.
6.  Any many more reasons

## Installation

```bash
npm i paytm-node-typescript
```

## Documentation

Documentation of Paytm's API and their usage is available at [https://developer.paytm.com/docs](https://developer.paytm.com/docs)

### Basic Usage

Instantiate the paytm instance with `mid`, `key`, `isProduction` & `callbackUrl`. You can obtain the keys from the dashboard app ([https://dashboard.paytm.com/next/apikeys](https://dashboard.paytm.com/next/apikeys))

```js
const instance = new Paytm({
  mid: 'YOUR_MID',
  key: 'YOUR_KEY_SECRET',
  isProduction: true | false,
  callbackUrl: 'YOUR_CALLBACK_URL'
});
```

The resources can be accessed via the instance. All the methods invocations follow the namespaced signature

```js
// API signature
// {paytmInstance}.{resourceName}.{methodName}(resourceId [, params])

// example
instance.payments.initTransaction(bodyObj);
```

Every resource method returns a promise.

```js
instance.payments
  .initTransaction(bodyObj)
  .then(response => {
    // handle success
  })
  .catch(error => {
    // handle error
  });
```

## Error Handling

This library comes with the standard way of handling all the errors originated by Paytm.
The Error object comes with the following keys and value

 1. message:
	 1. "Missing Parameter": If any mandatory key is missing
	 2. "API Error": When the Error comes from the API
 2. statusCode:
	 1. -1: When Missing Parameter
	 2. HTTP Error code in all other cases
3. error:
	1. This is an object which contains the error message that came from the Paytm API
	2. In the case of missing parameter, it will be {message: 'parameter which is missing'} 

---

## Development

```bash
npm install
```

## Testing

```bash
npm test
```

## Release

1. Switch to the `master` branch. Make sure you have the latest changes in the local master
2. Update the `CHANGELOG.md` & bump the version in `package.json`
3. Commit
4. Tag the release & push it to Github
5. Create a release on GitHub using the website with more details about the release
6. Publish to npm with the `npm publish` command

## Licence

MIT Licensed. See [LICENSE.txt](LICENSE.txt) for more details

---
_Source: https://npm.io/package/paytm-node-typescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
