【问题标题】:How to execute function, after payment was received (Sofort)?收到付款后如何执行功能(Sofort)?
【发布时间】:2019-09-04 22:05:33
【问题描述】:

我正在尝试将 sofort 作为支付选项集成到我的节点 js 应用程序中,到目前为止一切正常。我唯一的问题是,我收到付款后不知道如何执行功能。现在我只被重定向到 sofort,转移我的钱,然后被重定向到成功 URL,但我不知道如何给服务器一个迹象,表明已收到付款。 我以为我可以使用通知 URL 作为与服务器通信的一种方式,但它不发送 GET 或 POST 请求,因此我真的不知道它实际上做了什么

到目前为止,这是我的代码:

router.get('/sofort', function(req, res, next) {
'use strict';
var util = require('util');
var Sofort = new (require('node-sofort'))({
    configKey : '181556:493374:5c3627c5d50e1f77ee0f5824abb46084'
});

try {
    Sofort.createPayment(101.00, 'EUR', ['Demo1'], {
        user_variables: ['variable1','variable2','variable3'],
        success_url: 'http://localhost:3000/',
        success_link_redirect: true,
        notification_urls: 'http://localhost:3000/testo'}, function (err, 
data) {
        console.log(data);
        console.log(data.payment_url);
        res.redirect(data.payment_url)
    });
} catch (e) {
    console.log(e);
}
)}

如果你有什么想法,那就直说吧

【问题讨论】:

  • 你需要正确使用你的success_url,success_url - String (255) Success link, overwrites the default value from the project settings. Is called when your customer successfully executed SOFORT Banking and the transfer has been listed in the customer's online banking. If the transaction ID of SOFORT Banking should be used as part of the URL, the parameter '-TRANSACTION-' can be inserted in the URL String. If no success link is defined in the project settings this parameter becomes mandatory { success_url: 'https://www.example.com/sofort/success' }
  • 您需要在您的节点服务器上创建一个正确的 url,以便能够重定向到并接收数据。

标签: node.js integration payment-gateway


【解决方案1】:

将success_url改为

success_url: 'http://localhost:3000/sofort/success/-TRANSACTION-'

然后创建一条路线(发布或获取我不知道)

router.post('/sofort/success/:transaction', function(req, res) {
    var transactionId = req.body.transaction;

    console.log('transaction succesful for id ' + transactionId);    

    res.end();
});

【讨论】:

  • 感谢工作:) 即使 transactionId 未定义:/
  • 我从未使用过这个库,只是根据文档工作。也许您需要检查 TRANSACTION 参数的格式和/或位置。文档很全面
  • 只要检查你的调试器/网络选项卡是否发送了任何事务 ID。如果是,您可以找出需要放入路由的参数名称。可能像:TRANSACTION:transactionId
  • 好的,我刚刚从 URL 字符串中找出了 transactionId
猜你喜欢
  • 2012-11-28
  • 2017-11-11
  • 2013-12-30
  • 2021-10-30
  • 2017-06-21
  • 1970-01-01
  • 1970-01-01
  • 2020-02-05
  • 2012-06-25
相关资源
最近更新 更多