first commit
This commit is contained in:
101
lib/taavon-send-data.js
Normal file
101
lib/taavon-send-data.js
Normal file
@@ -0,0 +1,101 @@
|
||||
const taavonSendData = async (saleOrderId, data) => {
|
||||
// let redirectUrl = "";
|
||||
let subDomain = "test";
|
||||
const provinceCode = saleOrderId.toString().substring(0, 2);
|
||||
console.log({ data, provinceCode });
|
||||
|
||||
if (provinceCode === "10") {
|
||||
subDomain = "test";
|
||||
// redirectUrl = `https://mid.rasadyar.net/payment?finalAmount=${finalAmount}&saleOrderId=${saleOrderId}&cardHolderPan=${cardHolderPan}&date=${data.date}&saleReferenceId=${saleReferenceId}`;
|
||||
} else if (provinceCode === "15") {
|
||||
subDomain = "sha";
|
||||
// redirectUrl = `https://sha.rasadyar.net/payment?finalAmount=${finalAmount}&saleOrderId=${saleOrderId}&cardHolderPan=${cardHolderPan}&date=${data.date}&saleReferenceId=${saleReferenceId}`;
|
||||
} else if (provinceCode === "18") {
|
||||
subDomain = "ha";
|
||||
// redirectUrl = `https://ha.rasadyar.net/payment?finalAmount=${finalAmount}&saleOrderId=${saleOrderId}&cardHolderPan=${cardHolderPan}&date=${data.date}&saleReferenceId=${saleReferenceId}`;
|
||||
} else if (provinceCode === "91") {
|
||||
subDomain = "ar";
|
||||
// redirectUrl = `https://ar.rasadyar.net/payment?finalAmount=${finalAmount}&saleOrderId=${saleOrderId}&cardHolderPan=${cardHolderPan}&date=${data.date}&saleReferenceId=${saleReferenceId}`;
|
||||
}
|
||||
|
||||
//save success payment into db
|
||||
const url = `https://${subDomain}backend.rasadyar.com/wage_payment_final_step/`;
|
||||
|
||||
const options = {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
};
|
||||
|
||||
await fetch(url, options);
|
||||
};
|
||||
|
||||
const taavonSendDataZarinPal = async (provinceCode, data) => {
|
||||
// let redirectUrl = "";
|
||||
let subDomain = "test";
|
||||
const province = provinceCode.toString().substring(0, 2);
|
||||
|
||||
if (province === "10") {
|
||||
subDomain = "test";
|
||||
} else if (province === "15") {
|
||||
subDomain = "sha";
|
||||
} else if (province === "18") {
|
||||
subDomain = "ha";
|
||||
} else if (province === "91") {
|
||||
subDomain = "ar";
|
||||
} else if (province === "47") {
|
||||
subDomain = "ma";
|
||||
}
|
||||
|
||||
//save success payment into db
|
||||
const url = `https://${subDomain}backend.rasadyar.com/wage_payment_final_step_zarin_pal/`;
|
||||
|
||||
const options = {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
};
|
||||
|
||||
await fetch(url, options);
|
||||
};
|
||||
|
||||
const taavonSendDataZarinPalLink = async (provinceCode, data) => {
|
||||
// let redirectUrl = "";
|
||||
let subDomain = "test";
|
||||
const province = provinceCode.toString().substring(0, 2);
|
||||
|
||||
if (province === "10") {
|
||||
subDomain = "test";
|
||||
} else if (province === "15") {
|
||||
subDomain = "sha";
|
||||
} else if (province === "18") {
|
||||
subDomain = "ha";
|
||||
} else if (province === "91") {
|
||||
subDomain = "ar";
|
||||
} else if (province === "47") {
|
||||
subDomain = "ma";
|
||||
}
|
||||
|
||||
//save success payment into db
|
||||
const url = `https://${subDomain}backend.rasadyar.com/wage_payment_with_link_final_step/`;
|
||||
|
||||
const options = {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
};
|
||||
|
||||
await fetch(url, options);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
taavonSendData,
|
||||
taavonSendDataZarinPal,
|
||||
taavonSendDataZarinPalLink,
|
||||
};
|
||||
Reference in New Issue
Block a user