32 lines
964 B
Plaintext
32 lines
964 B
Plaintext
const RedsysPos = require('redsys-pos');
|
|
const {
|
|
CURRENCIES, TRANSACTION_TYPES
|
|
} = RedsysPos;
|
|
|
|
class RedsysProviders {
|
|
async New(orderFk, price) {
|
|
try {
|
|
const MERCHANT_KEY = "sq7HjrUOBfKmC576ILgskD5srU870gJ7";
|
|
const redsys = new RedsysPos(MERCHANT_KEY);
|
|
const obj = JSON.stringify({
|
|
amount: 100, // 100 euros
|
|
orderReference: orderFk,
|
|
merchantName: "Floranet",
|
|
merchantCode: "999008881",
|
|
currency: CURRENCIES.EUR,
|
|
transactionType: TRANSACTION_TYPES.AUTHORIZATION, // '0'
|
|
terminal: "001",
|
|
merchantURL: `${process.env.BASE_URL}/payments/redsys/notification`,
|
|
successURL: `${process.env.BASE_URL}/checkout/success?orderId=${orderFk}`,
|
|
errorURL: `${process.env.BASE_URL}/checkout/error`
|
|
});
|
|
|
|
const result = redsys.makePaymentParameters(obj);
|
|
return ""
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = new RedsysProviders(); |