UNPKG

xpresspayonline-react-native

Version:

xpresspayonline react native plugin

38 lines (31 loc) 958 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.encrypt = encrypt; var _jsSha = require("js-sha256"); function encrypt(options) { var hashBody = { 'transactionId': options.transactionId, 'amount': options.amount, 'currency': options.currency, 'country': options.country, 'email': options.email, 'phoneNumber': options.phoneNumber ? options.phoneNumber : '', 'firstName': options.firstName ? options.firstName : '', 'lastName': options.lastName ? options.lastName : '', 'callbackUrl': options.callbackUrl }; var hashedPayload = ''; var keys = Object.keys(hashBody).sort(); for (var index in keys) { var key = ''; key = keys[index]; hashedPayload += hashBody[key]; } var hashString = options.publicKey + hashedPayload; var hashSha256 = _jsSha.sha256.create(); hashSha256.update(hashString); var finalHash = hashSha256.hex(); return finalHash; }