rocketfuel-node-sdk
Version:
JS SDK for RocketFuel Payment Method
23 lines (19 loc) • 579 B
JavaScript
import CustomError from '../../CustomError';
import { STRING_CONST } from '../const';
export default function auth(api) {
return async (clientId, encryptedPayload) => {
if (!clientId) {
throw new Error('ClientId is required');
}
if (!encryptedPayload) {
throw new Error('Encrypted Payload is required');
}
const url = STRING_CONST.route.auth;
try {
const { data } = await api.post(url, { clientId, encryptedPayload });
return data;
} catch (err) {
throw new CustomError(err.message, err.response.data);
}
};
}