paytm-node-typescript
v1.0.5
Published
[![npm](https://img.shields.io/npm/v/paytm-node-typescript.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/paytm-node-typescript)
Downloads
1
Readme
Paytm Node SDK
Unofficial nodejs library for Paytm API with typescript support.
Read up here for getting started and understanding the payment flow with Paytm: https://developer.paytm.com/docs
Why this library?
- Typescript support.
- Removed traditional way of adding field inside the object.
- Improved code to make it easy to opt for any future changes.
- Removed deprecated request and shifted to Axios (https://github.com/request/request/issues/3142).
- Standard PaytmError class for handling all the errors.
- Any many more reasons
Installation
npm i paytm-node-typescript
Documentation
Documentation of Paytm's API and their usage is available at 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)
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
// API signature
// {paytmInstance}.{resourceName}.{methodName}(resourceId [, params])
// example
instance.payments.initTransaction(bodyObj);
Every resource method returns a promise.
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
- message:
- "Missing Parameter": If any mandatory key is missing
- "API Error": When the Error comes from the API
- statusCode:
- -1: When Missing Parameter
- HTTP Error code in all other cases
- error:
- This is an object which contains the error message that came from the Paytm API
- In the case of missing parameter, it will be {message: 'parameter which is missing'}
Development
npm install
Testing
npm test
Release
- Switch to the
master
branch. Make sure you have the latest changes in the local master - Update the
CHANGELOG.md
& bump the version inpackage.json
- Commit
- Tag the release & push it to Github
- Create a release on GitHub using the website with more details about the release
- Publish to npm with the
npm publish
command
Licence
MIT Licensed. See LICENSE.txt for more details