https://github.com/rudrodip/sslcommerz-ts
SSLCOMMERZ is a bangladeshi payment gateway provider. This is Node module for SSLCOMMERZ with typescript support
https://github.com/rudrodip/sslcommerz-ts
javascript sslcommerz typescript
Last synced: about 1 month ago
JSON representation
SSLCOMMERZ is a bangladeshi payment gateway provider. This is Node module for SSLCOMMERZ with typescript support
- Host: GitHub
- URL: https://github.com/rudrodip/sslcommerz-ts
- Owner: rudrodip
- License: mit
- Created: 2023-12-08T08:47:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-01T16:01:04.000Z (almost 2 years ago)
- Last Synced: 2025-03-15T08:55:27.935Z (7 months ago)
- Topics: javascript, sslcommerz, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/sslcommerz-ts
- Size: 78.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# [SSLCommerz - Node.js Library - Typscript](https://www.npmjs.com/package/sslcommerz-ts)
## Installation
```bash
npm i sslcommerz-ts
```## How to use:
### Initialize a Transaction
```js
const express = require('express')
const app = express()const SSLCommerzPayment = require('sslcommerz-ts')
const store_id = ''
const store_passwd = ''
const is_live = false //true for live, false for sandboxconst port = 3030
//sslcommerz init
app.get('/init', (req, res) => {
const data = {
total_amount: 100,
currency: 'BDT',
tran_id: 'REF123', // use unique tran_id for each api call
success_url: 'http://localhost:3030/success',
fail_url: 'http://localhost:3030/fail',
cancel_url: 'http://localhost:3030/cancel',
ipn_url: 'http://localhost:3030/ipn',
shipping_method: 'Courier',
product_name: 'Computer.',
product_category: 'Electronic',
product_profile: 'general',
cus_name: 'Customer Name',
cus_email: 'customer@example.com',
cus_add1: 'Dhaka',
cus_add2: 'Dhaka',
cus_city: 'Dhaka',
cus_state: 'Dhaka',
cus_postcode: '1000',
cus_country: 'Bangladesh',
cus_phone: '01711111111',
cus_fax: '01711111111',
ship_name: 'Customer Name',
ship_add1: 'Dhaka',
ship_add2: 'Dhaka',
ship_city: 'Dhaka',
ship_state: 'Dhaka',
ship_postcode: 1000,
ship_country: 'Bangladesh',
};
const sslcz = new SSLCommerzPayment(store_id, store_passwd, is_live)
sslcz.init(data).then(apiResponse => {
// Redirect the user to payment gateway
let GatewayPageURL = apiResponse.GatewayPageURL
res.redirect(GatewayPageURL)
console.log('Redirecting to: ', GatewayPageURL)
});
})app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
```### Validate after successful transaction (inside success and ipn controller methods)
```js
//sslcommerz validationapp.get('/validate', (req, res) => {
const data = {
val_id:ADGAHHGDAKJ456454 //that you go from sslcommerz response
};
const sslcz = new SSLCommerzPayment(store_id, store_passwd, is_live)
sslcz.validate(data).then(data => {
//process the response that got from sslcommerz
// https://developer.sslcommerz.com/doc/v4/#order-validation-api
});
})
```### To initiate a refund through API
```js
//SSLCommerz initiateRefundapp.get('/initiate-refund', (req, res) => {
const data = {
refund_amount:10,
refund_remarks:'',
bank_tran_id:CB5464321445456456,
refe_id:EASY5645415455,
};
const sslcz = new SSLCommerzPayment(store_id, store_passwd, is_live)
sslcz.initiateRefund(data).then(data => {
//process the response that got from sslcommerz
//https://developer.sslcommerz.com/doc/v4/#initiate-the-refund
});
})
```### Query the status of a refund request
```js
//SSLCommerz refundQueryapp.get('/refund-query', (req, res) => {
const data = {
refund_ref_id:SL4561445410,
};
const sslcz = new SSLCommerzPayment(store_id, store_passwd, is_live)
sslcz.refundQuery(data).then(data => {
//process the response that got from sslcommerz
//https://developer.sslcommerz.com/doc/v4/#initiate-the-refund
});
})
```### Query the status of a transaction (by Transaction ID)
```js
//SSLCommerz transactionQueryByTransactionId
//you also use this as internal method
app.get('/transaction-query-by-transaction-id', (req, res) => {
const data = {
tran_id:AKHLAKJS5456454,
};
const sslcz = new SSLCommerzPayment(store_id, store_passwd, is_live)
sslcz.transactionQueryByTransactionId(data).then(data => {
//process the response that got from sslcommerz
//https://developer.sslcommerz.com/doc/v4/#by-session-id
});
})
```### Query the status of a transaction (by session ID)
```js
//SSLCommerz transactionQueryBySessionId
//you also use this as internal method
app.get('/transaction-query-by-session-id', (req, res) => {
const data = {
sessionkey:AKHLAKJS5456454,
};
const sslcz = new SSLCommerzPayment(store_id, store_passwd, is_live)
sslcz.transactionQueryBySessionId(data).then(data => {
//process the response that got from sslcommerz
//https://developer.sslcommerz.com/doc/v4/#by-session-id
});
})
```- Find more details in [SSLCommerz Developer's Guide](https://developer.sslcommerz.com/)
- For any technical queries: official.rudrodipsarker@gmail.com