limepay
Version:
LimePay SDK is a node module for simplifying the consumption of LimePay API
32 lines (24 loc) • 1.17 kB
JavaScript
const PaymentsClient = require('./payments-client');
const RelayedSigner = require('../../payment-signers/relayed-signer');
const PAYMENT_ROUTES = require('./../../constants/payment-routes.json');
const ERRORS = require('./../../errors/sdk-errors');
class RelayedPaymentsClient extends PaymentsClient {
async create(creationData, walletConfiguration) {
return super._create(PAYMENT_ROUTES.CREATE_RELAYED, creationData, walletConfiguration);
}
// Implementation of an abstract method
_computeAuthorizationSignature(signatureMetadata, fundTxData, walletConfiguration) {
const { nonce, escrowAddress, shopperAddress } = signatureMetadata;
const gasPrice = signatureMetadata.gasPrice || fundTxData.gasPrice;
if (!fundTxData.weiAmount) {
throw ERRORS.INVALID_WEI_AMOUNT_PROVIDED;
}
try {
const relayedSigner = new RelayedSigner(nonce, escrowAddress, gasPrice, shopperAddress, fundTxData.weiAmount);
return relayedSigner.sign(walletConfiguration);
} catch (error) {
throw ERRORS.SIGNING_ERROR;
}
}
}
module.exports = RelayedPaymentsClient;