Пример имплементации платежного API для приложений Node.js

Команда для установки:

npm install payonline
Пример кода:

var PayOnline = require('payonline');

var payOnlineClient = new PayOnline({
    merchantId: "put your id here",
    privateSecurityKey: "put your security key here"
});

payOnlineClient.getPaymentUrl({
    "OrderId": "TestOrderId",
    "Amount": "2.00",
    "Currency": "RUB"
}, function (err, url) {
    console.log("Payment url: " + url);
});

payOnlineClient.parseCallback(
    "DateTime=2008-12-31 23:59:59&TransactionID=1234567&OrderId=56789&Amount=9.99&Currency=USD&SecurityKey=8e22a392a71f19a0cab54834e5ed062f",
    function (err, result) {
        console.log("Transaction ID: " + result.TransactionID);
        console.log("Order ID: " + result.OrderId);
    }
);

payOnlineClient.void(123, function (err, result) {
    if (result.Result !== "Ok") {
        console.log("Unable to void transaction");
    }
});

payOnlineClient.confirm(124, function (err, result) {
    if (result.Result !== "Ok") {
        console.log("Unable to confirm transaction");
    }
});

payOnlineClient.partialConfirm(125, 1.50, function (err, result) {
    if (result.Result !== "Ok") {
        console.log("Unable to confirm transaction");
    }
});