Exemplo n.º 1
0
        public bool DoCheckoutPayment(string finalPaymentAmount, string token, string PayerID, out NVPCodec decoder, out string retMsg)
        {
            if (bSandbox)
            {
                pEndPointURL = pEndPointURL_SB;
            }

            NVPCodec encoder = new NVPCodec();

            encoder["METHOD"]  = "DoExpressCheckoutPayment";
            encoder["TOKEN"]   = token;
            encoder["PAYERID"] = PayerID;
            encoder["PAYMENTREQUEST_0_AMT"]           = finalPaymentAmount;
            encoder["PAYMENTREQUEST_0_CURRENCYCODE"]  = _currency;
            encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";

            string pStrrequestforNvp = encoder.encode();
            string pStresponsenvp    = HttpCall(pStrrequestforNvp);

            decoder = new NVPCodec();
            decoder.decode(pStresponsenvp);

            string strAck = decoder["ACK"].ToLower();

            if (strAck != "" & (strAck == "success" | strAck == "successwithwarning"))
            {
                retMsg = "";
                return(true);
            }
            else
            {
                retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
                         "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
                         "Desc2=" + decoder["L_LONGMESSAGE0"];
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool GetCheckoutDetails(string token, out string PayerID, out NVPCodec decoder, out string retMsg)
        {
            if (bSandbox)
            {
                pEndPointURL = pEndPointURL_SB;
            }


            NVPCodec encoder = new NVPCodec();

            encoder["METHOD"] = "GetExpressCheckoutDetails";
            encoder["TOKEN"]  = token;

            string pStrrequestforNvp = encoder.encode();
            string pStresponsenvp    = HttpCall(pStrrequestforNvp);

            decoder = new NVPCodec();
            decoder.decode(pStresponsenvp);

            string strAck = decoder["ACK"].ToLower();

            if (strAck != "" & (strAck == "success" | strAck == "successwithwarning"))
            {
                PayerID = decoder["PAYERID"];
                retMsg  = "";
                return(true);
            }
            else
            {
                PayerID = "";
                retMsg  = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
                          "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
                          "Desc2=" + decoder["L_LONGMESSAGE0"];
                return(false);
            }
        }
Exemplo n.º 3
0
        public bool ShortcutExpressCheckout(out string token, out string retMsg)
        {
            if (bSandbox)
            {
                pEndPointURL = pEndPointURL_SB;
                host         = host_SB;
            }


            string returnURL = (_baseurl.StartsWith("http") ? "" : "http://") + _baseurl + (_baseurl.EndsWith("/") ? "" : "/") + (_reviewurl.StartsWith("/") ? _reviewurl.Substring(1) : _reviewurl);
            string cancelURL = (_baseurl.StartsWith("http") ? "" : "http://") + _baseurl + (_baseurl.EndsWith("/") ? "" : "/") + (_cancelurl.StartsWith("/") ? _cancelurl.Substring(1) : _cancelurl);

            NVPCodec encoder = new NVPCodec();

            encoder["METHOD"]                         = "SetExpressCheckout";
            encoder["RETURNURL"]                      = returnURL;
            encoder["CANCELURL"]                      = cancelURL;
            encoder["BRANDNAME"]                      = WebSetting.val.ecommercename; // Webutil.impostazioni.gettextvalue("ecommercename");//"Nome della società, sovrascrive il nome di default dell'account paypal"
            encoder["PAYMENTREQUEST_0_AMT"]           = _cart.getTotalAmt();          // totale
            encoder["PAYMENTREQUEST_0_DESC"]          = (paymentdescription == "" ? "Descrizione Pagamento" : paymentdescription);
            encoder["PAYMENTREQUEST_0_ITEMAMT"]       = _cart.getTotalAmt();
            encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
            encoder["PAYMENTREQUEST_0_CURRENCYCODE"]  = _currency.ToUpper();
            encoder["LOCALECODE"]                     = _localeui;
            encoder["NOSHIPPING"]                     = "1";
            if (_useipn)
            {
                encoder["PAYMENTREQUEST_0_NOTIFYURL"] = (_baseurl.StartsWith("http") ? "" : "http://") + _baseurl + (_baseurl.EndsWith("/") ? "" : "/") + _ipnpage; // URL IPN
            }
            //encoder("HDRIMG") = "IT" url immagine custom da far apparire nella pagina paypal
            encoder["LANDINGPAGE"] = _landing; //mostro o meno il login oppure carta di credito
            //encoder("BRANDNAME") = "Nome della società, sovrascrive il nome di default dell'account paypal"

            // se c'è il carrello aggiustare

            foreach (paypalCartItem i in _cart)
            {
                encoder["L_PAYMENTREQUEST_0_NAME" + i.index] = i.name;
                encoder["L_PAYMENTREQUEST_0_DESC" + i.index] = i.description;
                encoder["L_PAYMENTREQUEST_0_AMT" + i.index]  = i.amt;
                encoder["L_PAYMENTREQUEST_0_QTY" + i.index]  = i.qta;
            }

            // stringa formattata con i parametri da inviare a paypal
            string pStrrequestforNvp = encoder.encode();
            // chiamata http e messaggio di ritorno
            string pStresponsenvp = HttpCall(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.decode(pStresponsenvp);

            string strAck = decoder["ACK"].ToLower();

            if (strAck != "" & (strAck == "success" | strAck == "successwithwarning"))
            {
                token = decoder["TOKEN"];
                string ECURL = "https://" + host + "/cgi-bin/webscr?cmd=_express-checkout" + "&token=" + token;
                retMsg = ECURL;
                return(true);
            }
            else
            {
                token  = "";
                retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
                         "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
                         "Desc2=" + decoder["L_LONGMESSAGE0"];
                return(false);
            }
        }