TypeError:SSLCommerzPayment不是构造函数

发布于 2025-02-09 13:12:06 字数 1370 浏览 3 评论 0原文

我正在尝试访问SSLCommerz交易API进行付款网关集成,但是在API调用中,我会遇到此错误。

TypeError: SSLCommerzPayment is not a constructor
      at D:\BlockChain\21.06.2022_PaymentGateway\secondPart\src\pages\app.js:58:24
      at Layer.handle [as handle_request] (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\layer.js:95:5)
      at next (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\route.js:144:13)
      at Route.dispatch (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\route.js:114:3)
      at Layer.handle [as handle_request] (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\layer.js:95:5)
      at D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\index.js:284:15
      at Function.process_params (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\index.js:346:12)
      at next (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\index.js:280:10)
      at jsonParser (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\body-parser\lib\types\json.js:110:7)
      at Layer.handle [as handle_request] (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\layer.js:95:5)

如何解决问题?

I am trying to access SSLCommerz transaction api for payment gateway integration, but on api call I am getting this error.

TypeError: SSLCommerzPayment is not a constructor
      at D:\BlockChain\21.06.2022_PaymentGateway\secondPart\src\pages\app.js:58:24
      at Layer.handle [as handle_request] (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\layer.js:95:5)
      at next (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\route.js:144:13)
      at Route.dispatch (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\route.js:114:3)
      at Layer.handle [as handle_request] (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\layer.js:95:5)
      at D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\index.js:284:15
      at Function.process_params (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\index.js:346:12)
      at next (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\index.js:280:10)
      at jsonParser (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\body-parser\lib\types\json.js:110:7)
      at Layer.handle [as handle_request] (D:\BlockChain\21.06.2022_PaymentGateway\secondPart\node_modules\express\lib\router\layer.js:95:5)

How to solve the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仙气飘飘 2025-02-16 13:12:06

我通过更改SSLCommerz的软件包解决了问题。我使用了SSLCommerz-LTS软件包,然后构造函数不显示错误。

npm i sslcommerz-lts

const express = require('express')
const app = express()

const SSLCommerzPayment = require('sslcommerz-lts')
const store_id = '<your_store_id>'
const store_passwd = '<your_store_password>'
const is_live = false //true for live, false for sandbox

const port = 3030

//sslcommerz init
app.get('/create-session', (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',            
        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',
    };
    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}`)
})

然后我在命令提示符“ node index.js'中运行
我得到了输出。

I solved the problem by changing package for SSLCommerz. I used sslcommerz-lts package and then the constructor don't show the error.

npm i sslcommerz-lts

const express = require('express')
const app = express()

const SSLCommerzPayment = require('sslcommerz-lts')
const store_id = '<your_store_id>'
const store_passwd = '<your_store_password>'
const is_live = false //true for live, false for sandbox

const port = 3030

//sslcommerz init
app.get('/create-session', (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',            
        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',
    };
    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}`)
})

Then I run in command prompt 'node index.js'
I got the output.

一个人的旅程 2025-02-16 13:12:06

更改

import {SSLPayment}

import * as SSLCommerzPayment from 'sslcommerz-lts';

,它将起作用

Change the

import {SSLPayment}

to

import * as SSLCommerzPayment from 'sslcommerz-lts';

and it will work

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文