Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
amircloner
masterclass-pay
Commits
10ea645f
Commit
10ea645f
authored
Apr 14, 2021
by
amir mohseninia
Browse files
add smsir and google sheet service
parent
ee6a3006
Changes
4
Hide whitespace changes
Inline
Side-by-side
routes/api.js
View file @
10ea645f
...
...
@@ -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
}
`
)
});
...
...
services/cronjob.js
0 → 100644
View file @
10ea645f
const
googlesheet
=
require
(
"
../services/sheet
"
);
const
Order
=
require
(
"
../models/order
"
);
\ No newline at end of file
services/sheet.js
View file @
10ea645f
const
axios
=
require
(
'
axios
'
).
default
;
const
Seller
=
require
(
"
../models/seller
"
);
const
moment
=
require
(
'
jalali-moment
'
);
const
googlesheet
=
async
(
O
bject
)
=>
{
const
googlesheet
=
async
(
o
bject
)
=>
{
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
);
...
...
services/sms.js
View file @
10ea645f
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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment