void OnMoneyTransfer(object sender, EventManager.MoneyTransferArgs e)
{
if (!m_active)
return;
IClientAPI user = null;
Scene scene = null;
// Find the user's controlling client.
lock (m_scenes) {
foreach (Scene sc in m_scenes) {
ScenePresence av = sc.GetScenePresence (e.sender);
if ((av != null) && (av.IsChildAgent == false)) {
// Found the client,
// and their root scene.
user = av.ControllingClient;
scene = sc;
}
}
}
if (scene == null || user == null) {
m_log.Warn ("[FreeMoney] Unable to find scene or user! Aborting transaction.");
return;
}
FreeMoneyTransaction txn;
if (e.transactiontype == 5008) {
// Object was paid, find it.
SceneObjectPart sop = scene.GetSceneObjectPart (e.receiver);
if (sop == null) {
m_log.Warn ("[FreeMoney] Unable to find SceneObjectPart that was paid. Aborting transaction.");
return;
}
string email;
if (sop.OwnerID == sop.GroupID) {
if (m_allowGroups) {
if (!GetEmail (scene.RegionInfo.ScopeID, sop.OwnerID, out email)) {
m_log.Warn ("[FreeMoney] Unknown email address of group " + sop.OwnerID);
return;
}
} else {
m_log.Warn ("[FreeMoney] Payments to group owned objects is disabled.");
return;
}
} else {
if (!GetEmail (scene.RegionInfo.ScopeID, sop.OwnerID, out email)) {
m_log.Warn ("[FreeMoney] Unknown email address of user " + sop.OwnerID);
return;
}
}
m_log.Info ("[FreeMoney] Start: " + e.sender + " wants to pay object " + e.receiver + " owned by " +
sop.OwnerID + " with email " + email + " " + m_gridCurrencySmallDenominationText + " " + e.amount);
txn = new FreeMoneyTransaction (e.sender, sop.OwnerID, email, e.amount, scene, e.receiver,
e.description + " T:" + e.transactiontype,
FreeMoneyTransaction.InternalTransactionType.Payment);
} else {
// Payment to a user.
string email;
if (!GetEmail (scene.RegionInfo.ScopeID, e.receiver, out email)) {
m_log.Warn ("[FreeMoney] Unknown email address of user " + e.receiver);
return;
}
m_log.Info ("[FreeMoney] Start: " + e.sender + " wants to pay user " + e.receiver + " with email " +
email + " " + m_gridCurrencySmallDenominationText + " " + e.amount);
txn = new FreeMoneyTransaction (e.sender, e.receiver, email, e.amount, scene, e.description + " T:" +
e.transactiontype, FreeMoneyTransaction.InternalTransactionType.Payment);
}
// Add transaction to queue
lock (m_transactionsInProgress)
m_transactionsInProgress.Add (txn.TxID, txn);
string baseUrl = m_scenes[0].RegionInfo.ExternalHostName + ":" + m_scenes[0].RegionInfo.HttpPort;
// If we're definitely going to use Bitcoin for this transaction, go ahead and initialize it and show the page page.
// Otherwise, show an intermediate page to choose the payment type, and only initialize for Bitcoin if they choose it.
string pageName = "pp";
if (m_directToBitcoin) {
InitializeBitcoinTransaction(txn, baseUrl);
pageName = "btcgo";
}
user.SendLoadURL ("FreeMoney", txn.ObjectID, txn.To, false, "Confirm payment?", "http://" +
baseUrl + "/"+pageName+"/?txn=" + txn.TxID);
}