/// <summary> /// THis method gets called when someone pays someone else as a gift. /// </summary> /// <param name="osender"></param> /// <param name="e"></param> private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e) { }
/// <summary> /// /// </summary> /// <remarks>Thanks to Melanie for reminding me about /// EventManager.OnMoneyTransfer being the critical function, /// and not ApplyCharge.</remarks> /// <param name="sender"></param> /// <param name="e"></param> void EventManager_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) { List <ScenePresence> avs = sc.GetAvatars().FindAll( x => (x.UUID == e.sender && x.IsChildAgent == false) ); if (avs.Count > 0) { if (avs.Count > 1) { m_log.Warn("[DTL PayPal] Multiple avatars with same UUID! Aborting transaction."); return; } // Found the client, // and their root scene. user = avs[0].ControllingClient; scene = sc; } } } if (scene == null || user == null) { m_log.Warn("[DTL PayPal] Unable to find scene or user! Aborting transaction."); return; } PayPalTransaction txn; if (e.transactiontype == 5008) { // Object was paid, find it. SceneObjectPart sop = scene.GetSceneObjectPart(e.receiver); if (sop == null) { m_log.Warn("[DTL PayPal] Unable to find SceneObjectPart that was paid. Aborting transaction."); return; } txn = new PayPalTransaction(e.sender, sop.OwnerID, m_usersemail[sop.OwnerID], e.amount, scene, e.receiver, e.description + "T:" + e.transactiontype, PayPalTransaction.InternalTransactionType.Payment); } else { // Payment to a user. txn = new PayPalTransaction(e.sender, e.receiver, m_usersemail[e.receiver], e.amount, scene, e.description + "T:" + e.transactiontype, PayPalTransaction.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; user.SendLoadURL("DTL PayPal", txn.ObjectID, txn.To, false, "Confirm payment?", "http://" + baseUrl + "/dtlpp/?txn=" + txn.TxID); }