payu-core-pg-react
Version:
PayU React Native SDK for Seamless Payment Integration
285 lines (284 loc) • 11.1 kB
JavaScript
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { Platform } from 'react-native';
class requestParser {
constructor() {
_defineProperty(this, "platform", Platform.OS);
_defineProperty(this, "requestData", void 0);
}
SetRequestData(data) {
this.requestData = data;
}
GetRequestData() {
return this.requestData;
}
/*
surl
furl
txnId
*/
ParseEsentials() {
if (this.platform === 'ios') {
if (this.StringSanity(this.requestData.surl) == false) {
throw new Error("Invalid Argument 'surl' Passed");
}
if (this.StringSanity(this.requestData.furl) == false) {
throw new Error("Invalid Argument 'furl' Passed");
}
if (this.StringSanity(this.requestData.txnId) == false) {
throw new Error("Invalid Argument 'txnId' Passed");
}
this.requestData.SURL = this.requestData.surl;
this.requestData.FURL = this.requestData.furl;
this.requestData.transactionID = this.requestData.txnId;
if (this.requestData.cvv) {
this.ParseCVV();
}
}
}
ParseAmount() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.amount) == false) {
throw new Error("Invalid Argument 'amount' Passed");
}
this.requestData.var1 = this.requestData.amount;
}
}
ParseCVV() {
if (this.platform === 'ios') {
if (this.StringSanity(this.requestData.cvv) == false) {
throw new Error("Invalid Argument 'cvv' Passed");
}
this.requestData.CVV = this.requestData.cvv;
}
}
ParseBinInfo() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.isSIInfo) == false) {
throw new Error("Invalid Argument 'isSIInfo' Passed");
}
if (this.StringSanity(this.requestData.cardNumber) == false) {
throw new Error("Invalid Argument 'CardNumber' Passed");
}
this.requestData.var1 = this.requestData.isSIInfo;
this.requestData.var2 = this.requestData.cardNumber;
}
}
ParseHash() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.hash) == false) {
throw new Error("Invalid Argument 'hash' Passed");
}
this.requestData.var1 = this.requestData.userCredentials;
}
}
ParseStartAndEndTime() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.startTime) == false) {
throw new Error("Invalid Argument 'startTime' Passed");
}
if (this.StringSanity(this.requestData.endTime) == false) {
throw new Error("Invalid Argument 'endTime' Passed");
}
this.requestData.var1 = this.requestData.startTime;
this.requestData.var2 = this.requestData.endTime;
}
}
ParseTransectionId() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.transectionId) == false) {
throw new Error("Invalid Argument 'transectionId' Passed");
}
this.requestData.var1 = this.requestData.transectionId;
}
}
ParseCardNumber() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.cardNumber) == false) {
throw new Error("Invalid Argument 'cardNumber' Passed");
}
this.requestData.var1 = this.requestData.cardNumber;
}
}
ParseVerifyPayment() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.txnId) == false) {
throw new Error("Invalid Argument 'txnId' Passed");
}
this.requestData.var1 = this.requestData.txnId;
}
if (this.platform === 'ios') {
if (this.StringSanity(this.requestData.txnId) == false) {
throw new Error("Invalid Argument 'txnId' Passed");
}
this.requestData.transactionID = this.requestData.txnId;
}
}
ParseOfferStatus() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.offerKey) == false) {
throw new Error("Invalid Argument 'offerKey' Passed");
}
if (this.StringSanity(this.requestData.amount) == false) {
throw new Error("Invalid Argument 'amount' Passed");
}
this.requestData.var1 = this.requestData.offerKey;
this.requestData.var2 = this.requestData.amount;
this.requestData.var3 = this.requestData.paymentType;
this.requestData.var4 = this.requestData.bankCode;
this.requestData.var5 = this.requestData.cardNumber;
}
}
ParseDeleteUserCard() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.userCredentials) == false) {
throw new Error("Invalid Argument 'userCredentials' Passed");
}
if (this.StringSanity(this.requestData.cardToken) == false) {
throw new Error("Invalid Argument 'cardToken' Passed");
}
this.requestData.var1 = this.requestData.userCredentials;
this.requestData.var2 = this.requestData.cardToken;
}
}
ParseGetUserCard() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.userCredentials) == false) {
throw new Error("Invalid Argument 'userCredentials' Passed");
}
this.requestData.var1 = this.requestData.userCredentials;
}
}
ParseSaveUserCard() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.userCredentials) == false) {
throw new Error("Invalid Argument 'userCredentials' Passed");
}
if (this.StringSanity(this.requestData.cardName) == false) {
throw new Error("Invalid Argument 'cardName' Passed");
}
if (this.StringSanity(this.requestData.cardMode) == false) {
throw new Error("Invalid Argument 'cardMode' Passed");
}
if (this.StringSanity(this.requestData.cardType) == false) {
throw new Error("Invalid Argument 'cardType' Passed");
}
if (this.StringSanity(this.requestData.nameOnCard) == false) {
throw new Error("Invalid Argument 'nameOnCard' Passed");
}
if (this.StringSanity(this.requestData.cardNo) == false) {
throw new Error("Invalid Argument 'cardNo' Passed");
}
if (this.StringSanity(this.requestData.expiryMonth) == false) {
throw new Error("Invalid Argument 'expiryMonth' Passed");
}
if (this.StringSanity(this.requestData.expiryYear) == false) {
throw new Error("Invalid Argument 'expiryYear' Passed");
}
this.requestData.var1 = this.requestData.userCredentials;
this.requestData.var2 = this.requestData.cardName;
this.requestData.var3 = this.requestData.cardMode;
this.requestData.var4 = this.requestData.cardType;
this.requestData.var5 = this.requestData.nameOnCard;
this.requestData.var6 = this.requestData.cardNo;
this.requestData.var7 = this.requestData.expiryMonth;
this.requestData.var8 = this.requestData.expiryYear;
}
}
ParseEditUserCard() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.userCredentials) == false) {
throw new Error("Invalid Argument 'userCredentials' Passed");
}
if (this.StringSanity(this.requestData.cardName) == false) {
throw new Error("Invalid Argument 'cardName' Passed");
}
if (this.StringSanity(this.requestData.cardMode) == false) {
throw new Error("Invalid Argument 'cardMode' Passed");
}
if (this.StringSanity(this.requestData.cardType) == false) {
throw new Error("Invalid Argument 'cardType' Passed");
}
if (this.StringSanity(this.requestData.nameOnCard) == false) {
throw new Error("Invalid Argument 'nameOnCard' Passed");
}
if (this.StringSanity(this.requestData.cardNo) == false) {
throw new Error("Invalid Argument 'cardNo' Passed");
}
if (this.StringSanity(this.requestData.expiryMonth) == false) {
throw new Error("Invalid Argument 'expiryMonth' Passed");
}
if (this.StringSanity(this.requestData.expiryYear) == false) {
throw new Error("Invalid Argument 'expiryYear' Passed");
}
if (this.StringSanity(this.requestData.cardToken) == false) {
throw new Error("Invalid Argument 'cardToken' Passed");
}
this.requestData.var1 = this.requestData.userCredentials;
this.requestData.var2 = this.requestData.cardToken;
this.requestData.var3 = this.requestData.cardName;
this.requestData.var4 = this.requestData.cardMode;
this.requestData.var5 = this.requestData.cardType;
this.requestData.var6 = this.requestData.nameOnCard;
this.requestData.var7 = this.requestData.cardNo;
this.requestData.var8 = this.requestData.expiryMonth;
this.requestData.var9 = this.requestData.expiryYear;
}
}
ParseOferParams() {
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.offerKey) == false) {
throw new Error("Invalid Argument 'offerKey' Passed");
}
if (this.StringSanity(this.requestData.amount) == false) {
throw new Error("Invalid Argument 'amount' Passed");
}
this.requestData.var1 = this.requestData.offerKey;
this.requestData.var2 = this.requestData.amount;
}
}
ParseCheckoutDetails() {
if (this.platform === 'ios') {
if (this.requestData.paymentType === "NB") {
throw new Error(" Evergreen NetBanking is not Available on IOS as of now. ");
}
}
if (this.platform === 'android') {
if (this.StringSanity(this.requestData.offerKey) == false) {
throw new Error("Invalid Argument 'offerKey' Passed");
}
if (this.requestData.paymentType === "Credit / Debit Cards") {
this.requestData.var1 = this.requestData.offerKey;
this.requestData.var2 = "1";
this.requestData.var3 = this.requestData.cardNumber;
this.requestData.var5 = this.requestData.amount;
}
if (this.requestData.paymentType === "Saved Cards") {
this.requestData.var1 = this.requestData.offerKey;
this.requestData.var2 = "2";
this.requestData.var3 = this.requestData.userCredentials;
this.requestData.var4 = this.requestData.cardToken;
this.requestData.var5 = this.requestData.amount;
}
if (this.requestData.paymentType === "NB") {
this.requestData.var1 = this.requestData.offerKey;
this.requestData.var2 = "3";
this.requestData.var3 = 'NB';
this.requestData.var5 = this.requestData.amount;
}
if (this.requestData.paymentType === "Net Banking") {
this.requestData.var1 = this.requestData.offerKey;
this.requestData.var2 = "4";
this.requestData.var3 = this.requestData.bankCode;
this.requestData.var5 = this.requestData.amount;
}
}
}
StringSanity(value) {
if (value.length < 1) {
return false;
}
return true;
}
}
export default new requestParser();
//# sourceMappingURL=request.js.map