numerous-room-83979
07/05/2024, 8:27 AM// WhatsApp numarasını al ve temizle
const phoneNumber = (event.payload.sender || "").replace('whatsapp:', '');
function getAreaCode(phoneNumber) {
// WhatsApp formatını ele al
const match = phoneNumber.match(/^(\d{1,3})/);
return match ? match[1] : "";
}
function getCurrencyFromAreaCode(areaCode) {
const currencyMap = {
'1': 'USD', // ABD ve Kanada
'44': 'GBP', // Birleşik Krallık
'49': 'EUR', // Almanya
'33': 'EUR', // Fransa
'90': 'TRY', // Türkiye
// Diğer ülkeleri buraya ekleyebilirsiniz
};
return currencyMap[areaCode] || 'USD';
// Varsayılan olarak USD kullan
}
function getPrice(currency) {
const priceMap = {
'USD': '100 USD',
'EUR': '90 EUR',
'GBP': '80 GBP',
'TRY': '1000 TRY'
};
return priceMap[currency] || '100 USD';
}
const areaCode = getAreaCode(phoneNumber);
const currency = getCurrencyFromAreaCode(areaCode);
// event nesnesine değerleri kaydet
event.phoneNumber = phoneNumber;
event.areaCode = areaCode;
event.currency = currency;
event.price = getPrice(currency);
console.log('Phone Number:', event.phoneNumber);
console.log('Area Code:', event.areaCode);
console.log('Detected Currency:', event.currency);
console.log('Price:', event.price);
// Değerleri döndür (bu, akışın devamında kullanılabilir)
return {
phoneNumber: event.phoneNumber,
areaCode: event.areaCode,
currency: event.currency,
price: event.price
};
https://cdn.discordapp.com/attachments/1121494527727902891/1258700874818129941/11.png?ex=6689000a&is=6687ae8a&hm=1e7d58055edfb459216ca3f23b5d1073ccd21dc34953a829c0af1e3c957d1e0d&