-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
60 lines (54 loc) · 1.57 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const express = require('express')
const bodyParser = require('body-parser')
var SSLCommerzPayment = require('sslcommerz-lts')
const app = express()
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.get('/', (req, res) => {
let data = {
total_amount: 100,
currency: 'BDT',
tran_id: 'tran_id_111',
success_url: 'http://localhost:3000/dump',
fail_url: 'http://localhost:3000/dump',
cancel_url: 'http://localhost:3000/dump',
ipn_url: 'http://your_public_server_address/ipn', // IPN does not work in local PC
shipping_method: 'Courier',
product_name: 'Computer.',
product_category: 'Electronic',
product_profile: 'general',
cus_name: 'Customer Name',
cus_email: '[email protected]',
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',
}
let sslcz = new SSLCommerzPayment('testbox', 'qwerty', false)
sslcz.init(data).then(function (apiResponse) {
let GatewayPageURL = apiResponse.GatewayPageURL
res.redirect(GatewayPageURL)
console.log('Redirecting to: ', GatewayPageURL)
}).catch(function (err) {
console.err(err)
})
})
app.post('/dump', (req, res) => {
console.log('Got Response', req.body)
res.send(req.body)
})
let port = 3000
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})