示例#1
0
        public bool ExpressCheckout(string name, string description, string price, string quantity, string currency, ref string token, ref string retMsg)
        {
            bool flag;

            try
            {
                string   str   = "www.paypal.com";
                NVPCodec codec = new NVPCodec {
                    ["METHOD"]    = "SetExpressCheckout",
                    ["RETURNURL"] = this.returnURL,
                    ["CANCELURL"] = this.cancelURL
                };
                double num  = Convert.ToDouble(quantity, CultureInfo.InvariantCulture);
                double num2 = Convert.ToDouble(price, CultureInfo.InvariantCulture);
                double num3 = num * num2;
                codec["L_PAYMENTREQUEST_0_NAME0"]       = name;
                codec["L_PAYMENTREQUEST_0_DESC0"]       = description;
                codec["L_PAYMENTREQUEST_0_AMT0"]        = price;
                codec["L_PAYMENTREQUEST_0_QTY0"]        = quantity;
                codec["PAYMENTREQUEST_0_AMT"]           = num3.ToString();
                codec["PAYMENTREQUEST_0_ITEMAMT"]       = num3.ToString();
                codec["PAYMENTREQUEST_0_PAYMENTACTION"] = "SALE";
                codec["PAYMENTREQUEST_0_CURRENCYCODE"]  = currency;
                string   nvpRequest = codec.Encode();
                string   nvpstring  = this.HttpCall(nvpRequest);
                NVPCodec codec2     = new NVPCodec();
                codec2.Decode(nvpstring);
                string str4 = codec2["ACK"].ToLower();
                if ((str4 != null) && ((str4 == "success") || (str4 == "successwithwarning")))
                {
                    token = codec2["TOKEN"];
                    string str5 = "https://" + str + "/cgi-bin/webscr?cmd=_express-checkout&token=" + token + "&useraction=COMMIT";
                    retMsg = str5;
                    return(true);
                }
                retMsg = "ErrorCode=" + codec2["L_ERRORCODE0"] + "&Desc=" + codec2["L_SHORTMESSAGE0"] + "&Desc2=" + codec2["L_LONGMESSAGE0"];
                flag   = false;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(flag);
        }
示例#2
0
        public bool GetDetails(string token, ref NVPCodec decoder, ref string retMsg)
        {
            string nvpRequest = new NVPCodec {
                ["METHOD"] = "GetExpressCheckoutDetails",
                ["TOKEN"]  = token
            }.Encode();
            string nvpstring = this.HttpCall(nvpRequest);

            decoder = new NVPCodec();
            decoder.Decode(nvpstring);
            string str3 = decoder["ACK"].ToLower();

            if ((str3 != null) && ((str3 == "success") || (str3 == "successwithwarning")))
            {
                return(true);
            }
            retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&Desc=" + decoder["L_SHORTMESSAGE0"] + "&Desc2=" + decoder["L_LONGMESSAGE0"];
            return(false);
        }
示例#3
0
        public bool ConfirmPayment(string finalPaymentAmount, string token, string PayerId, string currency, ref NVPCodec decoder, ref string retMsg)
        {
            string nvpRequest = new NVPCodec {
                ["METHOD"]        = "DoExpressCheckoutPayment",
                ["TOKEN"]         = token,
                ["PAYMENTACTION"] = "Sale",
                ["PAYERID"]       = PayerId,
                ["AMT"]           = finalPaymentAmount,
                ["CURRENCYCODE"]  = currency
            }.Encode();
            string nvpstring = this.HttpCall(nvpRequest);

            decoder = new NVPCodec();
            decoder.Decode(nvpstring);
            string str3 = decoder["ACK"].ToLower();

            if ((str3 != null) && ((str3 == "success") || (str3 == "successwithwarning")))
            {
                return(true);
            }
            retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&Desc=" + decoder["L_SHORTMESSAGE0"] + "&Desc2=" + decoder["L_LONGMESSAGE0"];
            return(false);
        }
示例#4
0
        private string buildCredentialsNVPString()
        {
            NVPCodec codec = new NVPCodec();

            if (!IsEmpty(this.APIUsername))
            {
                codec["USER"] = this.APIUsername;
            }
            if (!IsEmpty(this.APIPassword))
            {
                codec["PWD"] = this.APIPassword;
            }
            if (!IsEmpty(this.APISignature))
            {
                codec["SIGNATURE"] = this.APISignature;
            }
            if (!IsEmpty(this.Subject))
            {
                codec["SUBJECT"] = this.Subject;
            }
            codec["VERSION"] = "84.0";
            return(codec.Encode());
        }