Commit 10ea645f authored by amir mohseninia's avatar amir mohseninia
Browse files

add smsir and google sheet service

parent ee6a3006
......@@ -89,11 +89,13 @@ router.get("/callback", async(req, res) => {
if (response.data.data.code == 100 && response.data.data.message == 'Paid') {
await Order.findOneAndUpdate({ Authority: req.query.Authority }, { isVerifiedPayment: true, TransactionID: response.data.data.ref_id, CardNumber: response.data.data.card_pan }, (err) => {
await Order.findOneAndUpdate({ Authority: req.query.Authority }, { isVerifiedPayment: true, TransactionID: response.data.data.ref_id, CardNumber: response.data.data.card_pan }, (err, order) => {
if (err) {
console.log(err);
return res.redirect("/?status=error");
}
smsir({ "text": `${order.FirstName} ${order.LastName} عزیز \n پرداخت شما با موفقیت انجام شد. \n گروه آموزشی دکتر ایروانی`, "phone": order.Phone });
googlesheet(order);
return res.redirect(`/?status=success&FirstName=${order.FirstName}&LastName=${order.LastName}`)
});
......
const googlesheet = require("../services/sheet");
const Order = require("../models/order");
\ No newline at end of file
const axios = require('axios').default;
const Seller = require("../models/seller");
const moment = require('jalali-moment');
const googlesheet = async(Object) => {
const googlesheet = async(object) => {
const seller = await Seller.findOne({ AffiliateCode: object.AffiliateCode })
const googlesheet_url = "https://script.google.com/macros/s/AKfycbxWrFTMflW_w-PI9JNxXcqNJtgtnBwRI_54YxoL0UoX7rpJ_AI-En3jy0WcA0lPFlJ9ZQ/exec";
let from = encodeURI(req.query.from);
let text = encodeURI(req.query.text);
let time = encodeURI(req.query.time);
let serializeBody = `phone=${from}&text=${text}&time=${time}`;
axios.post(googlesheet_url + '?' + serializeBody)
let serializeBody = `isVerifiedPayment=${"پرداخت شده"}&Date=${moment(object.createdAt,'YYYY-M-D HH:mm:ss').locale('fa').format('YYYY/M/D')}&Time=${moment(object.createdAt,'YYYY-M-D HH:mm:ss').locale('fa').format('HH:mm:ss')}&NationalCode=${object.NationalCode}&FirstName=${object.FirstName}&LastName=${object.LastName}&Province=${object.Province}&City=${object.City}&Address=${object.Address}&PostalCode=${object.PostalCode}&Phone=${object.Phone}&Product=${"دوره مَسترکِلَس موفقیت کنکور"}&Grade=${object.Grade}&Seller=${seller.FullName}&Description=${object.Description}`;
console.log(serializeBody);
axios.post(googlesheet_url + '?' + encodeURI(serializeBody))
.then(function(response) {
console.log(serializeBody + " " + response.status + " " + response.data);
return res.status(response.status).json({
message: response.data
});
console.log(response);
})
.catch(function(error) {
console.log(error);
......
const axios = require('axios').default;
const sms = async(object) => {
axios.post('http://ippanel.com/api/select', {
"op": "pattern",
"user": process.env.IPPANEL_USERNAME,
"pass": process.env.IPPANEL_PASSWORD,
"fromNum": process.env.IPPANEL_NUMBER,
"toNum": object.destination,
"patternCode": object.pattern,
"inputData": object.inputArray
axios.post('https://ip.sms.ir/SendMessage.ashx', {
user: process.env.SMSIR_USERNAME,
pass: process.env.SMSIR_PASSWORD,
text: object.text,
to: object.Phone,
lineNo: process.env.SMSIR_NUMBER,
})
.then(function(response) {
// console.log(response);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment