Skip to content

Instantly share code, notes, and snippets.

@boraoksuzoglu
Last active February 20, 2025 05:55
Show Gist options
  • Save boraoksuzoglu/8abc0e6fee222d737d467fe95dfb569d to your computer and use it in GitHub Desktop.
Save boraoksuzoglu/8abc0e6fee222d737d467fe95dfb569d to your computer and use it in GitHub Desktop.
Shopier NodeJS Otomatik Sipariş Bildirimi Örnek Kod
/*
Nasıl kurulur?
- En aşağıda verdiğim URL'den kullanıcı adı ve şifrenizi alıp .env dosyanıza aşağıdaki gibi yapıştırın
SHOPIER_OSB_USERNAME=buraya_osb_kullanici_adi
SHOPIER_OSB_PASSWORD=buraya_osb_sifresi
- En aşağıda verdiğim URL'de bildirim URL'si yazan kısma aplikasyonunuzun URL'sini girin.
- Bundan sonra her yeni siparişte girdiğiniz URL'ye POST request gidecektir.
- OSB URL: https://www.shopier.com/m/notificationaccess.php
*/
const crypto = require('crypto')
const orderNotification = async (req, res) => {
const body = req.body
// Gelmesi gereken veriler kontrol edilir.
if (!body[0] || !body[1]) {
res.status(401).json({ message: 'Missing parameter', code: 401 })
}
// Özet kontrolü yapılır
let hash = crypto
.createHmac('sha256', process.env.SHOPIER_OSB_PASSWORD)
.update(body[0].value + process.env.SHOPIER_OSB_USERNAME)
.digest('hex')
if (hash !== body[1].value) {
res.status(401).json({ message: 'Unauthorized', code: 401 })
}
// Veriler alınır
const {
email,
orderid,
currency,
price,
buyername,
buyersurname,
productcount,
productid,
productlist,
chatdetails,
customernote,
istest,
} = JSON.parse(Buffer.from(body[0].value, 'base64').toString('utf8'))
// İşlem başarılı olduğunda success yazılarak OSB'nin başarılı geldiği doğrulanmış olunur.
res.status(200).send('success')
}
module.exports = {
orderNotification,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment