floranet/api/controller/Payment/redsys-easy.text

37 lines
968 B
Plaintext

const Redsys = require('redsys-easy');
const {
SANDBOX_URLS,
PRODUCTION_URLS,
TRANSACTION_TYPES
} = Redsys
class RedsysProviders {
async New(orderFk, price) {
try {
const redsys = new Redsys({
secretKey: 'sq7HjrUOBfKmC576ILgskD5srU870gJ7',
urls: SANDBOX_URLS, // Also PRODUCTION_URLS
});
const obj = {
amount: price,
currency: 'EUR',
order: orderFk,
merchantName: 'Floraner',
merchantCode: '999008881',
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 form = redsys.redirectPetition(obj)
return true
} catch (error) {
throw error;
}
}
}
module.exports = new RedsysProviders();