Exemple #1
0
 void TransferSuccess(PayPalTransaction transaction)
 {
     if (transaction.InternalType == PayPalTransaction.InternalTransactionType.Payment)
     {
         if (transaction.ObjectID == UUID.Zero)
         {
             // User 2 User Transaction
             // Probably should notify them somehow.
         }
         else
         {
             if (OnObjectPaid != null)
             {
                 OnObjectPaid(transaction.ObjectID, transaction.From, transaction.Amount);
             }
         }
     }
     else if (transaction.InternalType == PayPalTransaction.InternalTransactionType.Purchase)
     {
         if (transaction.ObjectID == UUID.Zero)
         {
             m_log.Error("[DTL PayPal] Unable to find Object bought! UUID Zero.");
         }
         else
         {
             Scene           s    = LocateSceneClientIn(transaction.From);
             SceneObjectPart part = s.GetSceneObjectPart(transaction.ObjectID);
             if (part == null)
             {
                 m_log.Error("[DTL PayPal] Unable to find Object bought! UUID = " + transaction.ObjectID);
                 return;
             }
             s.PerformObjectBuy(s.SceneContents.GetControllingClient(transaction.From),
                                transaction.InternalPurchaseFolderID, part.LocalId,
                                transaction.InternalPurchaseType);
         }
     }
     else
     {
         m_log.Error("[DTL PayPal] Unknown Internal Transaction Type.");
         return;
     }
     // Cleanup.
     lock (m_transactionsInProgress)
         m_transactionsInProgress.Remove(transaction.TxID);
 }
 void TransferSuccess(PayPalTransaction transaction)
 {
     if (transaction.InternalType == PayPalTransaction.InternalTransactionType.Payment)
     {
         if (transaction.ObjectID == UUID.Zero)
         {
             // User 2 User Transaction
             // Probably should notify them somehow.
         }
         else
         {
             if (OnObjectPaid != null)
             {
                 OnObjectPaid(transaction.ObjectID, transaction.From, transaction.Amount);
             }
         }
     }
     else if (transaction.InternalType == PayPalTransaction.InternalTransactionType.Purchase)
     {
         if (transaction.ObjectID == UUID.Zero)
         {
             m_log.Error("[DTL PayPal] Unable to find Object bought! UUID Zero.");
         }
         else
         {
             Scene s = LocateSceneClientIn(transaction.From);
             SceneObjectPart part = s.GetSceneObjectPart(transaction.ObjectID);
             if (part == null)
             {
                 m_log.Error("[DTL PayPal] Unable to find Object bought! UUID = " + transaction.ObjectID);
                 return;
             }
             s.PerformObjectBuy(s.SceneContents.GetControllingClient(transaction.From),
                                transaction.InternalPurchaseFolderID, part.LocalId,
                                transaction.InternalPurchaseType);
         }
     }
     else
     {
         m_log.Error("[DTL PayPal] Unknown Internal Transaction Type.");
         return;
     }
     // Cleanup.
     lock (m_transactionsInProgress)
         m_transactionsInProgress.Remove(transaction.TxID);
 }
        /// <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);
        }
        public void ObjectBuy(IClientAPI remoteClient, UUID agentID,
                UUID sessionID, UUID groupID, UUID categoryID,
                uint localID, byte saleType, int salePrice)
        {
            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 == agentID && 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;
            }

            SceneObjectPart sop = scene.GetSceneObjectPart(localID);
            if (sop == null)
            {
                m_log.Warn("[DTL PayPal] Unable to find SceneObjectPart that was paid. Aborting transaction.");
                return;
            }

            PayPalTransaction txn = new PayPalTransaction(agentID, sop.OwnerID, m_usersemail[sop.OwnerID], salePrice,
                                                          scene, sop.UUID,
                                                          "Item Purchase - " + sop.Name + " (" + saleType + ")",
                                                          PayPalTransaction.InternalTransactionType.Purchase, categoryID,
                                                          saleType);

            // 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 purchase?",
                             "http://" + baseUrl + "/dtlpp/?txn=" + txn.TxID);
        }
Exemple #5
0
        /// <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);
        }
Exemple #6
0
        public void ObjectBuy(IClientAPI remoteClient, UUID agentID,
                              UUID sessionID, UUID groupID, UUID categoryID,
                              uint localID, byte saleType, int salePrice)
        {
            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 == agentID && 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;
            }

            SceneObjectPart sop = scene.GetSceneObjectPart(localID);

            if (sop == null)
            {
                m_log.Warn("[DTL PayPal] Unable to find SceneObjectPart that was paid. Aborting transaction.");
                return;
            }

            PayPalTransaction txn = new PayPalTransaction(agentID, sop.OwnerID, m_usersemail[sop.OwnerID], salePrice,
                                                          scene, sop.UUID,
                                                          "Item Purchase - " + sop.Name + " (" + saleType + ")",
                                                          PayPalTransaction.InternalTransactionType.Purchase, categoryID,
                                                          saleType);

            // 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 purchase?",
                             "http://" + baseUrl + "/dtlpp/?txn=" + txn.TxID);
        }
Exemple #7
0
        public Hashtable DtlUserPage(Hashtable request)
        {
            UUID txnID = new UUID((string)request["txn"]);

            if (!m_transactionsInProgress.ContainsKey(txnID))
            {
                Hashtable ereply = new Hashtable();

                ereply["int_response_code"]   = 404; // 200 OK
                ereply["str_response_string"] = "<h1>Invalid Transaction</h1>";
                ereply["content_type"]        = "text/html";

                return(ereply);
            }

            PayPalTransaction txn = m_transactionsInProgress[txnID];

            string baseUrl = m_scenes[0].RegionInfo.ExternalHostName + ":" + m_scenes[0].RegionInfo.HttpPort;

            // Ouch. (This is the PayPal Request URL)
            string url = "https://" + m_ppurl + "/cgi-bin/webscr?cmd=_xclick" +
                         "&business=" + HttpUtility.UrlEncode(txn.SellersEmail) +
                         "&item_name=" + HttpUtility.UrlEncode(txn.Description) +
                         "&item_number=" + HttpUtility.UrlEncode(txn.TxID.ToString()) +
                         "&amount=" + HttpUtility.UrlEncode(ConvertAmountToCurrency(txn.Amount).ToString()) +
                         "&page_style=" + HttpUtility.UrlEncode("Paypal") +
                         "&no_shipping=" + HttpUtility.UrlEncode("1") +
                         "&return=" + HttpUtility.UrlEncode("http://" + baseUrl + "/") +        // TODO: Add in a return page
                         "&cancel_return=" + HttpUtility.UrlEncode("http://" + baseUrl + "/") + // TODO: Add in a cancel page
                         "&notify_url=" + HttpUtility.UrlEncode("http://" + baseUrl + "/dtlppipn/") +
                         "&no_note=" + HttpUtility.UrlEncode("1") +
                         "&currency_code=" + HttpUtility.UrlEncode("USD") +
                         "&lc=" + HttpUtility.UrlEncode("US") +
                         "&bn=" + HttpUtility.UrlEncode("PP-BuyNowBF") +
                         "&charset=" + HttpUtility.UrlEncode("UTF-8") +
                         "";

            Dictionary <string, string> replacements = new Dictionary <string, string>();

            replacements.Add("{ITEM}", txn.Description);
            replacements.Add("{AMOUNT}", ConvertAmountToCurrency(txn.Amount).ToString());
            replacements.Add("{AMOUNTOS}", txn.Amount.ToString());
            replacements.Add("{CURRENCYCODE}", "USD");
            replacements.Add("{BILLINGLINK}", url);
            replacements.Add("{OBJECTID}", txn.ObjectID.ToString());
            replacements.Add("{SELLEREMAIL}", txn.SellersEmail);



            string template;

            try
            {
                template = File.ReadAllText("dtl-paypal-template.htm");
            }
            catch (IOException)
            {
                template = "Error: dtl-paypal-template.htm does not exist.";
                m_log.Error("[DTL PayPal] Unable to load template file.");
            }

            foreach (KeyValuePair <string, string> pair in replacements)
            {
                template = template.Replace(pair.Key, pair.Value);
            }

            Hashtable reply = new Hashtable();

            reply["int_response_code"]   = 200; // 200 OK
            reply["str_response_string"] = template;
            reply["content_type"]        = "text/html";

            return(reply);
        }