### Install SSLCommerz Node.js Library Source: https://github.com/sslcommerz/sslcommerz-nodejs/blob/master/readme.md This command installs the official SSLCommerz LTS package from npm, making it available for use in your Node.js project. ```bash npm i sslcommerz-lts ``` -------------------------------- ### Query Transaction Status by Transaction ID in Node.js Source: https://github.com/sslcommerz/sslcommerz-nodejs/blob/master/readme.md This example demonstrates an Express.js endpoint to query the status of a transaction using its transaction ID via the sslcommerz-lts library. ```javascript //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 }); }) ``` -------------------------------- ### Validate Transaction after Success or IPN in Node.js Source: https://github.com/sslcommerz/sslcommerz-nodejs/blob/master/readme.md This example shows an Express.js route for validating a transaction using the sslcommerz-lts library. It uses the validation ID received from SSLCommerz to confirm the transaction status. ```javascript //sslcommerz validation app.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 }); }) ``` -------------------------------- ### Initialize a Transaction with SSLCommerz in Node.js Source: https://github.com/sslcommerz/sslcommerz-nodejs/blob/master/readme.md This code snippet demonstrates how to set up an Express.js route to initialize a payment transaction using the sslcommerz-lts library. It configures transaction details and redirects the user to the SSLCommerz payment gateway URL. ```javascript const express = require('express') const app = express() const SSLCommerzPayment = require('sslcommerz-lts') const store_id = '' const store_passwd = '' const is_live = false //true for live, false for sandbox const 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}`) }) ``` -------------------------------- ### Initiate Refund via SSLCommerz API in Node.js Source: https://github.com/sslcommerz/sslcommerz-nodejs/blob/master/readme.md This snippet demonstrates how to create an Express.js endpoint to initiate a refund for a transaction using the sslcommerz-lts library. It requires the refund amount, remarks, bank transaction ID, and reference ID. ```javascript //SSLCommerz initiateRefund app.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 Refund Status via SSLCommerz API in Node.js Source: https://github.com/sslcommerz/sslcommerz-nodejs/blob/master/readme.md This code shows an Express.js route for querying the status of a previously initiated refund request using the sslcommerz-lts library. It requires the refund reference ID. ```javascript //SSLCommerz refundQuery app.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 Transaction Status by Session ID in Node.js Source: https://github.com/sslcommerz/sslcommerz-nodejs/blob/master/readme.md This snippet shows an Express.js route for querying the status of a transaction using its session key via the sslcommerz-lts library. ```javascript //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 }); }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.