public string ECSetExpressCheckout_PayLaterCode(string returnURL,string cancelURL,string amount,string paymentType,string currencyCode)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment="sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "51.0";
            encoder["METHOD"] =  "SetExpressCheckout";
            encoder["RETURNURL"] =  returnURL;
            encoder["CANCELURL"] =  cancelURL;
            encoder["AMT"] =  amount;
            encoder["PAYMENTACTION"] =  paymentType;
            encoder["CURRENCYCODE"] =  currencyCode;
            encoder["L_PROMOCODE0"] = "101";
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
        public string GetTransactionDetailsCode(string transactionID)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment="sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "51.0";
            encoder["METHOD"] =  "GetTransactionDetails";

            // Add request-specific fields to the request.
            encoder["TRANSACTIONID"] =  transactionID;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
Example #3
0
        public string GetBalanceCode()
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";
            encoder["METHOD"]  = "GetBalance";
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
Example #4
0
        public string GetBalanceCode()
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment="sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "51.0";
            encoder["METHOD"] =  "GetBalance";
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
        public static NVPCallerServices PayPalAPIInitialize(bool isDev)
        {
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();

            if (isDev)
            {
                profile.APIUsername  = DEV_API_USERNAME;
                profile.APIPassword  = DEV_API_PASSWORD;
                profile.Environment  = DEV_ENVIRONMENT;
                profile.Subject      = String.Empty;
                profile.APISignature = DEV_API_SIGNATURE;
            }
            else
            {
                profile.APIUsername  = API_USERNAME;
                profile.APIPassword  = API_PASSWORD;
                profile.Environment  = ENVIRONMENT;
                profile.Subject      = String.Empty;
                profile.APISignature = API_SIGNATURE;
            }


            NVPCallerServices caller = new NVPCallerServices();

            caller.APIProfile = profile;

            return(caller);
        }
    public NVPCodec CancelAuthorization(string transactionID, string note)
    {
        NVPCallerServices caller = new NVPCallerServices();
        IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
        /*
         WARNING: Do not embed plaintext credentials in your application code.
         Doing so is insecure and against best practices.
         Your API credentials must be handled securely. Please consider
         encrypting them for use in any production environment, and ensure
         that only authorized individuals may view or modify them.
         */

        // Set up your API credentials, PayPal end point, API operation and version.
        caller.APIProfile = profile;

        NVPCodec encoder = new NVPCodec();
        encoder["VERSION"] = "51.0";
        encoder["METHOD"] = "DoVoid";

        // Add request-specific fields to the request.
        encoder["AUTHORIZATIONID"] = transactionID;
        encoder["NOTE"] = note;
        encoder["TRXTYPE"] = "V";

        // Execute the API operation and obtain the response.
        string pStrrequestforNvp = encoder.Encode();
        string pStresponsenvp = caller.Call(pStrrequestforNvp);

        NVPCodec decoder = new NVPCodec();
        return decoder;
    }
    public static NVPCallerServices PayPalAPIInitialize()
    {
        NVPCallerServices caller = new NVPCallerServices();

        caller.APIProfile = SetProfile.SessionProfile;
        return(caller);
    }
Example #8
0
        public PayPalResponse ECGetExpressCheckout(string token)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = getProfile();
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] = "84.0";
            encoder["METHOD"] = "GetExpressCheckoutDetails";

            // Add request-specific fields to the request.
            encoder["TOKEN"] = token; // Pass the token returned in SetExpressCheckout.

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            PayPalResponse response = new PayPalResponse {
                token = (decoder["TOKEN"] != null) ? decoder["TOKEN"] : "",
                acknowledgement = decoder["ACK"],
                first = decoder["FIRSTNAME"],
                last = decoder["LASTNAME"],
                email = decoder["EMAIL"],
                amount = decoder["PAYMENTREQUEST_0_AMT"],
                payerID = decoder["PAYERID"]
            };
            return response;
        }
        public NVPCodec ECDoExpressCheckoutCode(string token, string payerID, string amount, string paymentType, string currencyCode)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            if (System.Configuration.ConfigurationManager.AppSettings["ENVIRONMENT"].ToString() == "T")
            {
                profile.APIUsername  = "******";
                profile.APIPassword  = "******";
                profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
                profile.Environment  = "sandbox";
            }
            else if (System.Configuration.ConfigurationManager.AppSettings["ENVIRONMENT"].ToString() == "L")
            {
                profile.APIUsername  = "******";
                profile.APIPassword  = "******";
                profile.APISignature = "AFcWxV21C7fd0v3bYYYRCpSSRl31Ab5GxWPc-1XSb8rJctwNCFHIYb84";
                profile.Environment  = "live";
            }
            else
            {
                profile.APIUsername  = "******";
                profile.APIPassword  = "******";
                profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
                profile.Environment  = "sandbox";
            }
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "65.1";
            encoder["METHOD"]  = "DoExpressCheckoutPayment";

            // Add request-specific fields to the request.
            // Pass the token returned in SetExpressCheckout.
            encoder["TOKEN"]         = token;
            encoder["PAYERID"]       = payerID;
            encoder["AMT"]           = amount;
            encoder["PAYMENTACTION"] = paymentType;
            encoder["CURRENCYCODE"]  = currencyCode;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder);
        }
        public NVPCodec ECSetExpressCheckoutCode(string returnURL, string appName,string appCode, string cancelURL, string appAMT, string paymentType, string currencyCode)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            if (System.Configuration.ConfigurationManager.AppSettings["ENVIRONMENT"].ToString() == "T")
            {
                profile.APIUsername = "******";
                profile.APIPassword = "******";
                profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
                profile.Environment = "sandbox";
            }
            else if (System.Configuration.ConfigurationManager.AppSettings["ENVIRONMENT"].ToString() == "L")
            {

                profile.APIUsername = "******";
                profile.APIPassword = "******";
                profile.APISignature = "AFcWxV21C7fd0v3bYYYRCpSSRl31Ab5GxWPc-1XSb8rJctwNCFHIYb84";
                profile.Environment = "live";
            }
            else
            {
                profile.APIUsername = "******";
                profile.APIPassword = "******";
                profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
                profile.Environment = "sandbox";
            }
            caller.APIProfile = profile;
            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "65.1";
            encoder["METHOD"] =  "SetExpressCheckout";
            // Add request-specific fields to the request.
            encoder["RETURNURL"] =  returnURL;
            encoder["CANCELURL"] =  cancelURL;
            encoder["AMT"] = appAMT;
            encoder["ITEMCATEGORY"] = "Digital";
            encoder["L_NAME0"] = appName;
            encoder["L_NUMBER0"] = appCode;
            encoder["L_AMT0"] = appAMT;
            encoder["L_QTY0"] ="1";
            encoder["PAYMENTACTION"] =  paymentType;
            encoder["CURRENCYCODE"] =  currencyCode;
            encoder["SOLUTIONTYPE"] = "Sole";
            // Execute the API operation and obtain the response.
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder;
        }
        /// <summary>
        /// 初始化支付服务器调用
        /// </summary>
        /// <returns></returns>
        private NVPCallerServices InitializeServices()
        {
            NVPCallerServices service = new NVPCallerServices();
            IAPIProfile       profile = CreateProfile();

            service.APIProfile = profile;
            return(service);
        }
        public Hashtable DoDirectPaymentCode()
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername  = Constants.PayPal_Username;       //"sdk-three_api1.sdk.com";
            profile.APIPassword  = Constants.PayPal_Password;       //"QFZCWN5HZM8VBG7Q";
            profile.APISignature = Constants.PayPal_Signature;      //"AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = Constants.PayPal_PaymentAccount; //"live";// "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";
            encoder["METHOD"]  = "DoDirectPayment";

            // Add request-specific fields to the request.
            encoder["PAYMENTACTION"]  = "Sale"; //paymentAction;
            encoder["AMT"]            = fPaymentOrderTotal.ToString();
            encoder["CREDITCARDTYPE"] = (sCCType.Equals(CreditCardType.AmericanExpress)) ? "Amex" : sCCType.ToString();
            encoder["ACCT"]           = CCNumber;
            encoder["EXPDATE"]        = sCCExpDate;
            encoder["CVV2"]           = sCCVerificationCode;
            encoder["FIRSTNAME"]      = sCCOwnerFirstName;
            encoder["LASTNAME"]       = sCCOwnerLastName;
            encoder["STREET"]         = (sCCOwnerStreet2.Trim().Length > 0) ? string.Concat(sCCOwnerStreet1, ", ", sCCOwnerStreet2) : sCCOwnerStreet1;
            encoder["CITY"]           = sCCOwnerCityName;
            encoder["STATE"]          = sCCOwnerStateOrProvince;
            encoder["ZIP"]            = sCCOwnerPostalCode;
            encoder["COUNTRYCODE"]    = sCCOwnerCountryCode;
            encoder["CURRENCYCODE"]   = "USD";

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);

            Hashtable htResult = new Hashtable();

            foreach (string st in decoder.AllKeys)
            {
                htResult.Add(st, decoder[st]);
            }
            return(htResult);
        }
Example #13
0
        public string MassPayCode(string emailSubject, string receiverType, string currencyCode, string ReceiverEmail0, string amount0, string UniqueID0, string Note0, string ReceiverEmail1, string amount1, string UniqueID1, string Note1)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";
            encoder["METHOD"]  = "MassPay";

            // Add request-specific fields to the request.
            encoder["EMAILSUBJECT"] = emailSubject;
            encoder["RECEIVERTYPE"] = receiverType;
            encoder["CURRENCYCODE"] = currencyCode;

            if (ReceiverEmail0.Length > 0)
            {
                encoder["L_EMAIL0"]    = ReceiverEmail0;
                encoder["L_Amt0"]      = amount0;
                encoder["L_UNIQUEID0"] = UniqueID0;
                encoder["L_NOTE0"]     = Note0;
            }

            if (ReceiverEmail1.Length > 0)
            {
                encoder["L_EMAIL1"]    = ReceiverEmail1;
                encoder["L_Amt1"]      = amount1;
                encoder["L_UNIQUEID1"] = UniqueID1;
                encoder["L_NOTE1"]     = Note1;
            }



            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
        /// <summary>
        /// 发送请求
        /// </summary>
        /// <param name="nvp"></param>
        /// <returns></returns>
        private NVPCodec SendExpressCheckoutCommand(NVPCodec nvp)
        {
            NVPCallerServices service = InitializeServices();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            string   response    = service.Call(nvp.Encode());
            NVPCodec responsenvp = new NVPCodec();

            responsenvp.Decode(response);
            return(responsenvp);
        }
Example #15
0
        public string MassPayCode(string emailSubject,string receiverType,string currencyCode,string ReceiverEmail0,string amount0,string UniqueID0,string Note0,string ReceiverEmail1,string amount1,string UniqueID1,string Note1)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment="sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "51.0";
            encoder["METHOD"] =  "MassPay";

            // Add request-specific fields to the request.
            encoder["EMAILSUBJECT"] =  emailSubject;
            encoder["RECEIVERTYPE"] =  receiverType;
            encoder["CURRENCYCODE"]=currencyCode;

            if(ReceiverEmail0.Length>0)
            {
                encoder["L_EMAIL0"] =  ReceiverEmail0;
                encoder["L_Amt0"] =  amount0;
                encoder["L_UNIQUEID0"] =  UniqueID0;
                encoder["L_NOTE0"] =  Note0;
            }

            if(ReceiverEmail1.Length>0)
            {
                encoder["L_EMAIL1"] =  ReceiverEmail1;
                encoder["L_Amt1"] =  amount1;
                encoder["L_UNIQUEID1"] =  UniqueID1;
                encoder["L_NOTE1"] =  Note1;
            }

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
        public NVPCodec ECGetExpressCheckoutCode(string token)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            if (System.Configuration.ConfigurationManager.AppSettings["ENVIRONMENT"].ToString() == "T")
            {
                profile.APIUsername = "******";
                profile.APIPassword = "******";
                profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
                profile.Environment = "sandbox";
            }
            else if (System.Configuration.ConfigurationManager.AppSettings["ENVIRONMENT"].ToString() == "L")
            {
                profile.APIUsername = "******";
                profile.APIPassword = "******";
                profile.APISignature = "AFcWxV21C7fd0v3bYYYRCpSSRl31Ab5GxWPc-1XSb8rJctwNCFHIYb84";
                profile.Environment = "live";
            }
            else
            {
                profile.APIUsername = "******";
                profile.APIPassword = "******";
                profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
                profile.Environment = "sandbox";
            }
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "65.1";
            encoder["METHOD"] =  "GetExpressCheckoutDetails";

            // Add request-specific fields to the request.
            encoder["TOKEN"] =  token; // Pass the token returned in SetExpressCheckout.

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder;
        }
Example #17
0
        public string DoDirectPaymentCode(string paymentAction, string amount, string creditCardType, string creditCardNumber, string expdate_month, string cvv2Number, string firstName, string lastName, string address1, string city, string state, string zip, string countryCode, string currencyCode)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername  = "******";                //"sdk-three_api1.sdk.com";
            profile.APIPassword  = "******";                                               //"QFZCWN5HZM8VBG7Q";
            profile.APISignature = "Aodyho-T1mAnue23UgKnw1JPD8E9AnPQgwCa26tyq818j5Kv.mh7AdxZ"; //"AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";
            encoder["METHOD"]  = "DoDirectPayment";

            // Add request-specific fields to the request.
            encoder["PAYMENTACTION"]  = paymentAction;
            encoder["AMT"]            = amount;
            encoder["CREDITCARDTYPE"] = creditCardType;
            encoder["ACCT"]           = creditCardNumber;
            encoder["EXPDATE"]        = expdate_month;
            encoder["CVV2"]           = cvv2Number;
            encoder["FIRSTNAME"]      = firstName;
            encoder["LASTNAME"]       = lastName;
            encoder["STREET"]         = address1;
            encoder["CITY"]           = city;
            encoder["STATE"]          = state;
            encoder["ZIP"]            = zip;
            encoder["COUNTRYCODE"]    = countryCode;
            encoder["CURRENCYCODE"]   = currencyCode;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
Example #18
0
        public string ECDoExpressCheckout(string token, string payerID, string amount, Cart cart)
        {
            Settings settings = new Settings();
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = getProfile();
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder.Add("VERSION","84.0");
            encoder.Add("METHOD","DoExpressCheckoutPayment");

            // Add request-specific fields to the request.
            encoder.Add("TOKEN",token);
            encoder.Add("PAYERID",payerID);
            encoder.Add("RETURNURL",getSiteURL() + "Payment/PayPalCheckout");
            encoder.Add("CANCELURL",getSiteURL() + "Payment");
            encoder.Add("PAYMENTREQUEST_0_AMT",amount);
            encoder.Add("PAYMENTREQUEST_0_PAYMENTACTION","Sale");
            encoder.Add("PAYMENTREQUEST_0_CURRENCYCODE","USD");
            encoder.Add("BRANDNAME",settings.Get("SiteName"));
            encoder.Add("LOGIN","Login");
            encoder.Add("HDRIMG",settings.Get("EmailLogo"));
            encoder.Add("CUSTOMERSERVICENUMBER",settings.Get("PhoneNumber"));
            encoder.Add("PAYMENTREQUEST_0_SHIPPINGAMT",cart.shipping_price.ToString());
            encoder.Add("PAYMENTREQUEST_0_DESC","Your " + settings.Get("SiteName") + " Order");
            encoder.Add("ALLOWNOTE","0");
            encoder.Add("NOSHIPPING","1");
            int count = 0;
            decimal total = 0;
            foreach (CartItem item in cart.CartItems) {
                encoder.Add("L_PAYMENTREQUEST_0_NUMBER" + count, item.partID.ToString());
                encoder.Add("L_PAYMENTREQUEST_0_NAME" + count, item.shortDesc);
                encoder.Add("L_PAYMENTREQUEST_0_AMT" + count, String.Format("{0:N2}", item.price));
                encoder.Add("L_PAYMENTREQUEST_0_QTY" + count, item.quantity.ToString());
                encoder.Add("L_PAYMENTREQUEST_0_ITEMCATEGORY" + count, "Physical");
                encoder.Add("L_PAYMENTREQUEST_0_ITEMURL" + count, settings.Get("SiteURL") + "part/" + item.partID);
                total += item.price * item.quantity;
                count++;
            }
            encoder.Add("PAYMENTREQUEST_0_TAXAMT", String.Format("{0:N2}", cart.tax));
            encoder.Add("PAYMENTREQUEST_0_ITEMAMT", String.Format("{0:N2}", total));
            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
Example #19
0
        private NVPCallerServices GetPayPalNVPCaller(PaymentMethod paymentMethod)
        {
            // var callerServices = new com.paypal.sdk.services.CallerServices();
            var caller = new NVPCallerServices();

            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();

            profile.Environment  = paymentMethod.DynamicProperty <bool>().Sandbox ? "sandbox" : "live";
            profile.APIPassword  = paymentMethod.DynamicProperty <string>().ApiPassword;
            profile.APISignature = paymentMethod.DynamicProperty <string>().ApiSignature;
            profile.APIUsername  = paymentMethod.DynamicProperty <string>().ApiUsername;

            caller.APIProfile = profile;
            return(caller);
        }
Example #20
0
        public string DoDirectPaymentCode(string paymentAction,string amount,string creditCardType,string creditCardNumber,string expdate_month,string cvv2Number,string firstName,string lastName,string address1,string city,string state,string zip,string countryCode,string currencyCode)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment="sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "51.0";
            encoder["METHOD"] =  "DoDirectPayment";

            // Add request-specific fields to the request.
            encoder["PAYMENTACTION"] =  paymentAction;
            encoder["AMT"] =  amount;
            encoder["CREDITCARDTYPE"] =  creditCardType;
            encoder["ACCT"] =  creditCardNumber;
            encoder["EXPDATE"] =  expdate_month;
            encoder["CVV2"] =  cvv2Number;
            encoder["FIRSTNAME"] =  firstName;
            encoder["LASTNAME"] =  lastName;
            encoder["STREET"] =  address1;
            encoder["CITY"] =  city;
            encoder["STATE"] =  state;
            encoder["ZIP"] =  zip;
            encoder["COUNTRYCODE"] = countryCode;
            encoder["CURRENCYCODE"] =  currencyCode;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
        public ICreditCardAuthorizationResponse VerifyCreditCardInfo(ICreditCardAuthorizationRequest request)
        {
            var caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AzbQABSL2jEPPHG.eDus2jfMT0xEAUITxvhhUWGmd3DHxaPXx6Zs1MPR";
            profile.Environment = "sandbox";
            caller.APIProfile = profile;

            var encoder = new NVPCodec();

            encoder["SIGNATURE"] = "AzbQABSL2jEPPHG.eDus2jfMT0xEAUITxvhhUWGmd3DHxaPXx6Zs1MPR";
            encoder["USER"] = "******";
            encoder["PWD"] = "1302977698";
            encoder["VERSION"] = "60.0";
            encoder["METHOD"] = "DoDirectPayment";

            // Add request-specific fields to the request.
            encoder["PAYMENTACTION"] = CreditCardPaymentActions.Authorization.ToString();
            encoder["AMT"] = "100";
            encoder["CREDITCARDTYPE"] = request.CreditCardInfo.Type.ToString();
            encoder["IPADDRESS"] = "192.168.0.1";
            encoder["ACCT"] = request.CreditCardInfo.CreditCardNumber;
            encoder["EXPDATE"] = request.CreditCardInfo.ExpirationDate.ToString("MMyyyy");
            encoder["CVV2"] = request.CreditCardInfo.Cvv2Number;
            encoder["FIRSTNAME"] = request.FirstName;
            encoder["LASTNAME"] = request.LastName;
            encoder["STREET"] = request.AddressInfo.Address1;
            encoder["CITY"] = request.AddressInfo.City;
            encoder["STATE"] = request.AddressInfo.State;
            encoder["ZIP"] = request.AddressInfo.ZipCode;
            encoder["COUNTRYCODE"] = request.AddressInfo.Country;
            encoder["CURRENCYCODE"] = "USD";

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp = caller.Call(pStrrequestforNvp);

            var decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return new CreditCardAuthorizationReponse(decoder["ACK"] == "Success");
        }
Example #22
0
        public string RefundTransactionCode(String refundType, String transactionId, String amount, String note, String currencyCode)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";
            encoder["METHOD"]  = "RefundTransaction";

            // Add request-specific fields to the request.
            encoder["TRANSACTIONID"] = transactionId;
            if (refundType != "Full")
            {
                encoder["AMT"]  = amount;
                encoder["NOTE"] = note;
            }
            encoder["REFUNDTYPE"] = refundType;


            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
        public string ECDoExpressCheckoutCode(string token, string payerID, string amount, string paymentType, string currencyCode)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";
            encoder["METHOD"]  = "DoExpressCheckoutPayment";

            // Add request-specific fields to the request.
            // Pass the token returned in SetExpressCheckout.
            encoder["TOKEN"]         = token;
            encoder["PAYERID"]       = payerID;
            encoder["AMT"]           = amount;
            encoder["PAYMENTACTION"] = paymentType;
            encoder["CURRENCYCODE"]  = currencyCode;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
        public string TransactionSearchCode(string startDate, string endDate, string transactionID)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";
            encoder["METHOD"]  = "TransactionSearch";

            // Add request-specific fields to the request.
            encoder["TRXTYPE"]       = "Q";        //Date format from server 2006-9-6T0:0:0
            encoder["STARTDATE"]     = startDate + "T0:0:0";
            encoder["ENDDATE"]       = endDate + "T23:59:59";
            encoder["TRANSACTIONID"] = transactionID;


            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
Example #25
0
        public string CreateRecurringPaymentsProfileCode(string token, string amount, string profileDate, string billingPeriod, string billingFrequency)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */
            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";

            // Add request-specific fields to the request.
            encoder["METHOD"]           = "CreateRecurringPaymentsProfile";
            encoder["TOKEN"]            = token;
            encoder["AMT"]              = amount;
            encoder["PROFILESTARTDATE"] = profileDate;                  //Date format from server expects Ex: 2006-9-6T0:0:0
            encoder["BILLINGPERIOD"]    = billingPeriod;
            encoder["BILLINGFREQUENCY"] = billingFrequency;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
        public string SetCustomerBillingAgreementCode(string returnURL, string cancelURL, string billingDesc)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"] = "51.0";
            encoder["METHOD"]  = "SetCustomerBillingAgreement";

            // Add request-specific fields to the request.
            encoder["RETURNURL"]   = returnURL;
            encoder["CANCELURL"]   = cancelURL;
            encoder["BILLINGTYPE"] = "RecurringPayments";
            encoder["BILLINGAGREEMENTDESCRIPTION"] = billingDesc;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
        public string CreateRecurringPaymentsProfileCode(string token,string amount,string profileDate, string billingPeriod, string billingFrequency)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */
            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment="sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "51.0";

            // Add request-specific fields to the request.
            encoder["METHOD"] =  "CreateRecurringPaymentsProfile";
            encoder["TOKEN"] =  token;
            encoder["AMT"] =  amount;
            encoder["PROFILESTARTDATE"] =  profileDate;	//Date format from server expects Ex: 2006-9-6T0:0:0
            encoder["BILLINGPERIOD"] =  billingPeriod;
            encoder["BILLINGFREQUENCY"] =  billingFrequency;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
        public string SetCustomerBillingAgreementCode(string returnURL,string cancelURL,string billingDesc)
        {
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
            /*
             WARNING: Do not embed plaintext credentials in your application code.
             Doing so is insecure and against best practices.
             Your API credentials must be handled securely. Please consider
             encrypting them for use in any production environment, and ensure
             that only authorized individuals may view or modify them.
             */

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "******";
            profile.APIPassword = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment="sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] =  "51.0";
            encoder["METHOD"] =  "SetCustomerBillingAgreement";

            // Add request-specific fields to the request.
            encoder["RETURNURL"] =  returnURL;
            encoder["CANCELURL"] =  cancelURL;
            encoder["BILLINGTYPE"] =  "RecurringPayments";
            encoder["BILLINGAGREEMENTDESCRIPTION"] =  billingDesc;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp= encoder.Encode();
            string pStresponsenvp=caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];
        }
Example #29
0
        public string ECSetExpressCheckout_PayLaterCode(string returnURL, string cancelURL, string amount, string paymentType, string currencyCode)
        {
            NVPCallerServices caller  = new NVPCallerServices();
            IAPIProfile       profile = ProfileFactory.createSignatureAPIProfile();

            /*
             * WARNING: Do not embed plaintext credentials in your application code.
             * Doing so is insecure and against best practices.
             * Your API credentials must be handled securely. Please consider
             * encrypting them for use in any production environment, and ensure
             * that only authorized individuals may view or modify them.
             */
            profile.APIUsername  = "******";
            profile.APIPassword  = "******";
            profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
            profile.Environment  = "sandbox";
            caller.APIProfile    = profile;

            NVPCodec encoder = new NVPCodec();

            encoder["VERSION"]       = "51.0";
            encoder["METHOD"]        = "SetExpressCheckout";
            encoder["RETURNURL"]     = returnURL;
            encoder["CANCELURL"]     = cancelURL;
            encoder["AMT"]           = amount;
            encoder["PAYMENTACTION"] = paymentType;
            encoder["CURRENCYCODE"]  = currencyCode;
            encoder["L_PROMOCODE0"]  = "101";
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp    = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();

            decoder.Decode(pStresponsenvp);
            return(decoder["ACK"]);
        }
        void placeOrderButton_Click(object sender, EventArgs e)
        {
            // Validate fields

            /*
             * string patternLenient = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
             *
             * string patternStrict = @"^(([^<>()[\]\\.,;:\s@\""]+"
             + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
             + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
             + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
             + @"[a-zA-Z]{2,}))$";
             +
             */

            String creditCardType   = creditCardList.SelectedValue;
            String creditCardNumber = creditCardNumberBox.Text.Trim();

            creditCardNumber = Regex.Replace(creditCardNumber, @"\D", "");
            String verificationNumber = verificationNumberBox.Text.Trim();

            String firstName   = firstNameBox.Text.Trim();
            String lastName    = lastNameBox.Text.Trim();
            String address1    = address1Box.Text.Trim();
            String address2    = address2Box.Text.Trim();
            String city        = cityBox.Text.Trim();
            String stateCode   = stateList.SelectedValue;
            String zipCode     = zipCodeBox.Text.Trim();
            String phoneNumber = phoneNumberBox.Text.Trim();

            if (firstName == String.Empty)
            {
                ErrorMessage = "First Name is required";
                return;
            }
            if (lastName == String.Empty)
            {
                ErrorMessage = "Last Name is required";
                return;
            }
            if (address1 == String.Empty)
            {
                ErrorMessage = "Address is required";
                return;
            }
            if (city == String.Empty)
            {
                ErrorMessage = "City is required";
                return;
            }
            if (stateCode == String.Empty)
            {
                ErrorMessage = "State is required";
                return;
            }
            if (zipCode == String.Empty)
            {
                ErrorMessage = "Zip Code is required";
                return;
            }
            if (phoneNumber == String.Empty)
            {
                ErrorMessage = "Phone Number is required";
                return;
            }
            if (phoneNumber.Length < 10)
            {
                ErrorMessage = "Phone Number must include area code plus 7 digit phone number";
                return;
            }

            if (DsCookie["_c"] == "1")
            {
                DsCookie["_c_ba"] = Cipher.Encrypt2(firstName);
                DsCookie["_c_bb"] = Cipher.Encrypt2(lastName);
                DsCookie["_c_bc"] = Cipher.Encrypt2(address1);
                DsCookie["_c_bd"] = Cipher.Encrypt2(address2);
                DsCookie["_c_be"] = Cipher.Encrypt2(city);
                DsCookie["_c_bf"] = Cipher.Encrypt2(stateCode);
                DsCookie["_c_bg"] = Cipher.Encrypt2(zipCode);
                DsCookie["_c_bh"] = Cipher.Encrypt2(phoneNumber);
            }

            if (creditCardNumber == String.Empty)
            {
                ErrorMessage = "Credit Card Number is required";
                return;
            }
            if (verificationNumber == String.Empty)
            {
                ErrorMessage = "Card Verification Number is required";
                return;
            }

            OrderTableAdapter             orderAdapter         = new OrderTableAdapter();
            CertificateNumberTableAdapter numberAdapter        = new CertificateNumberTableAdapter();
            OrderLineItemTableAdapter     orderLineItemAdapter = new OrderLineItemTableAdapter();


            decimal subtotal = 0.0m;

            foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems)
            {
                int numberAssigned = Convert.ToInt32(numberAdapter.Assign(lineItem.OrderLineItemId));

                if (numberAssigned != lineItem.Quantity)
                {
                    if (numberAssigned == 0)
                    {
                        ErrorMessage = "We're sorry, " + lineItem.Certificate.AdvertiserName + " is no longer available";
                        orderLineItemAdapter.Delete(lineItem.OrderLineItemId);
                    }
                    else
                    {
                        lineItem.Quantity = numberAssigned;
                        orderLineItemAdapter.Update(lineItem);

                        ErrorMessage = "We're sorry, " + lineItem.Certificate.AdvertiserName + " is no longer available in the quantity you requested. Please review your updated order and click on the checkout button if you would like to purchase the new quantity";
                    }

                    Order.LineItemModifiedDate = DateTime.Now;
                    orderAdapter.Update(Order);

                    ResetOrder();
                    Response.Redirect("~/Cart.aspx");
                }


                subtotal += lineItem.Total;
            }


            switch (creditCardType)
            {
            case "Visa":
                Order.PaymentMethodId = (int)PaymentMethod.Visa;
                break;

            case "MasterCard":
                Order.PaymentMethodId = (int)PaymentMethod.MasterCard;
                break;

            case "Discover":
                Order.PaymentMethodId = (int)PaymentMethod.Discover;
                break;

            case "Amex":
                Order.PaymentMethodId = (int)PaymentMethod.Amex;
                break;

            default:

                break;
            }


            Order.SubTotal         = subtotal;
            Order.GrandTotal       = subtotal;
            Order.BillingFirstName = firstName;
            Order.BillingLastName  = lastName;
            Order.BillingAddress1  = address1;
            if (address2 != String.Empty)
            {
                Order.BillingAddress2 = address2;
            }
            else
            {
                Order.SetBillingAddress2Null();
            }
            Order.BillingCity      = city;
            Order.BillingStateCode = stateCode;
            Order.BillingZipCode   = zipCode;
            Order.BillingPhone     = phoneNumber;


            orderAdapter.Update(Order);


            // Check max purchase qty for Deal of the Week
            if (Station.StationSiteType == SiteType.DealOfTheWeek)
            {
                CertificateTableAdapter            certificateAdapter = new CertificateTableAdapter();
                DollarSaverDB.CertificateDataTable certificateTable   = certificateAdapter.GetCurrentDeal(StationId);

                if (certificateTable.Count == 1)
                {
                    DollarSaverDB.CertificateRow deal = certificateTable[0];
                    if (deal.MaxPurchaseQty > 0)
                    {
                        foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems)
                        {
                            if (lineItem.CertificateId == deal.CertificateId)
                            {
                                int pastQty = Convert.ToInt32(orderLineItemAdapter.GetQtyByConsumer(firstName, lastName, null,
                                                                                                    address1, city, stateCode, Order.ShippingEmail, deal.CertificateId));

                                if (pastQty + lineItem.Quantity > deal.MaxPurchaseQty)
                                {
                                    ErrorMessage = "Sorry, the maximum purchase quantity per person for the Deal of the Week is " + deal.MaxPurchaseQty + ".";

                                    if (pastQty >= deal.MaxPurchaseQty)
                                    {
                                        ErrorMessage += "<BR>You have already purchased the maximum allowed.";
                                    }
                                    else
                                    {
                                        int allowedAmount = deal.MaxPurchaseQty - pastQty;
                                        ErrorMessage += "<BR>You may only purchase " + allowedAmount + " more.";
                                    }

                                    ResetOrder();
                                    Response.Redirect("~/Cart.aspx");
                                }
                            }
                        }
                    }
                }
            }

            if (Order.CheckoutStartDate < Order.LineItemModifiedDate)
            {
                ResetOrder();

                ErrorMessage = "Your cart has been updated while checking out, please verify you items and continue the checkout process.";

                Response.Redirect("~/Cart.aspx");
            }

            Order.OrderStatusId = (int)OrderStatus.Processing;
            orderAdapter.Update(Order);


            // charge order...
            NVPCallerServices caller  = PayPalAPI.PayPalAPIInitialize(IsDev);
            NVPCodec          encoder = new NVPCodec();

            encoder["VERSION"]        = "50.0";
            encoder["METHOD"]         = "DoDirectPayment";
            encoder["PAYMENTACTION"]  = "Sale";
            encoder["AMT"]            = subtotal.ToString("0.00");
            encoder["CREDITCARDTYPE"] = creditCardType;
            encoder["ACCT"]           = creditCardNumber;
            encoder["EXPDATE"]        = expirationMonthList.SelectedValue + expirationYearList.SelectedValue;
            encoder["CVV2"]           = verificationNumber;
            encoder["FIRSTNAME"]      = firstName;
            encoder["LASTNAME"]       = lastName;
            encoder["STREET"]         = address1;
            encoder["CITY"]           = city;
            encoder["STATE"]          = stateCode;
            encoder["ZIP"]            = zipCode;
            encoder["COUNTRYCODE"]    = "US";
            encoder["CURRENCYCODE"]   = "USD";

            /*
             * encoder["INVNUM"] = Order.OrderId.ToString();
             * encoder["ITEMAMT"] = Order.LineItems.SubTotal.ToString("0.00");
             * foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems.Rows) {
             *  int itemNumber = lineItem.SeqNo - 1;
             *
             *  encoder["L_NAME" + itemNumber] = lineItem.ShortName;
             *  encoder["L_NUMBER" + itemNumber] = lineItem.CertificateId.ToString();
             *  encoder["L_QTY" + itemNumber] = lineItem.Quantity.ToString();
             *  encoder["L_AMT" + itemNumber] = lineItem.DiscountValue.ToString("0.00");
             * }
             */

            string paypalRequest  = encoder.Encode();
            string paypalResponse = String.Empty;


            try {
                paypalResponse = caller.Call(paypalRequest);
            } catch {
                ResetOrder();
                ErrorMessage = "An error occurred while processing your order, please try submitting it again.";
                return;
            }


            NVPCodec decoder = new NVPCodec();

            decoder.Decode(paypalResponse);

            string strAck = decoder["ACK"];

            if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning"))
            {
                string transactionId = decoder["TRANSACTIONID"];
                Order.TransactionId = transactionId;

                Order.OrderDate     = DateTime.Now;
                Order.OrderStatusId = (int)OrderStatus.Complete;
                orderAdapter.Update(Order);

                InfoMessage = "Successfully processed order";

                if (SendReceipt())
                {
                    InfoMessage += "<BR />Receipt sent to " + Order.ShippingEmail;
                }

                if (Order.AddToMailingList)
                {
                    CustomerContactTableAdapter customerContactAdapter = new CustomerContactTableAdapter();
                    customerContactAdapter.Insert(StationId, DateTime.Now, Order.ShippingEmail, Order.BillingFirstName, Order.BillingLastName);
                }

                Response.Redirect("~/Confirmation.aspx", true);
                return;
            }
            else
            {
                ResetOrder();

                ErrorMessage = "Error! " + decoder["L_LONGMESSAGE0"] + " (" + decoder["L_ERRORCODE0"] + ")";

                return;
            }
        }
Example #31
0
        public string ECSetExpressCheckout(Cart cart)
        {
            Settings settings = new Settings();
            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = getProfile();
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder.Add("VERSION", "84.0");
            encoder.Add("METHOD", "SetExpressCheckout");
            // Add request-specific fields to the request.
            encoder.Add("RETURNURL", getSiteURL() + "Payment/CompletePayPalCheckout");
            encoder.Add("CANCELURL", getSiteURL() + "Payment");
            encoder.Add("PAYMENTREQUEST_0_AMT", String.Format("{0:N2}", cart.getTotal()));
            encoder.Add("PAYMENTREQUEST_0_PAYMENTACTION", "Sale");
            encoder.Add("PAYMENTREQUEST_0_CURRENCYCODE", "USD");
            encoder.Add("BRANDNAME", settings.Get("SiteName") + " eCommerce Platform");
            encoder.Add("LOGIN", "Login");
            encoder.Add("HDRIMG", settings.Get("EmailLogo"));
            encoder.Add("CUSTOMERSERVICENUMBER", "888-894-4824");
            encoder.Add("PAYMENTREQUEST_0_SHIPPINGAMT", String.Format("{0:N2}", cart.shipping_price));
            encoder.Add("PAYMENTREQUEST_0_DESC", "Your " + settings.Get("SiteName") + " Order");
            encoder.Add("ALLOWNOTE", "0");
            encoder.Add("NOSHIPPING", "1");
            int count = 0;
            decimal total = 0;
            foreach (CartItem item in cart.CartItems) {
                encoder.Add("L_PAYMENTREQUEST_0_NUMBER" + count, item.partID.ToString());
                encoder.Add("L_PAYMENTREQUEST_0_NAME" + count, item.shortDesc);
                encoder.Add("L_PAYMENTREQUEST_0_AMT" + count, String.Format("{0:N2}", item.price));
                encoder.Add("L_PAYMENTREQUEST_0_QTY" + count, item.quantity.ToString());
                encoder.Add("L_PAYMENTREQUEST_0_ITEMCATEGORY" + count, "Physical");
                encoder.Add("L_PAYMENTREQUEST_0_ITEMURL" + count, settings.Get("SiteURL") + "part/" + item.partID);
                total += item.price * item.quantity;
                count++;
            }
            encoder.Add("PAYMENTREQUEST_0_TAXAMT", String.Format("{0:N2}", cart.tax));
            encoder.Add("PAYMENTREQUEST_0_ITEMAMT", String.Format("{0:N2}", total));

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            if (decoder["TOKEN"] != null) {
                return decoder["TOKEN"];
            } else {

                string errors = " CorrelationID: " + decoder["CORRELATIONID"] + " error code: " + decoder["L_ERRORCODE0"] + " Messages: " + decoder["L_SHORTMESSAGE0"] + ", " + decoder["L_SHORTMESSAGE2"] + ", " + decoder["L_LONGMESSAGE0"] + ", " + decoder["L_LONGMESSAGE1"];
                return decoder["ACK"] + errors;
            }
        }
Example #32
0
 public static NVPCallerServices PayPalAPIInitialize()
 {
     NVPCallerServices caller = new NVPCallerServices();
     caller.APIProfile = SetProfile.SessionProfile;
     return caller;
 }
    private void SetExpressCheckout()
    {
        string storefrontUrl = String.Empty;

        if (UrlManager.IsMobile())
        {
            storefrontUrl = UrlPath.StorefrontUrl + "Mobile/";
        }
        else
        {
            storefrontUrl = UrlPath.StorefrontUrl;
        }

        string returnURL = storefrontUrl + "Shipping.aspx";
        string cancelURL = storefrontUrl + "ShoppingCart.aspx";

        IList <decimal> discountLines;
        decimal         discount = GetDiscountLine(StoreContext.ShoppingCart.GetCartItems(), out discountLines);

        NVPCallerServices caller  = PayPalProExpressUtilities.Instance.PayPalAPIInitialize();
        NVPCodec          encoder = new NVPCodec();

        encoder["METHOD"]    = "SetExpressCheckout";
        encoder["AMT"]       = Vevo.Domain.Currency.ConvertPriceToUSFormat(GetShoppingCartTotal().ToString("f2"));
        encoder["RETURNURL"] = returnURL;
        encoder["CANCELURL"] = cancelURL;
        if (Request.QueryString["Token"] != null)
        {
            encoder["TOKEN"] = Request.QueryString["Token"];
        }
        encoder["PAYMENTACTION"] = PayPalProExpressUtilities.PaymentType;
        encoder["CURRENCYCODE"]  = DataAccessContext.Configurations.GetValue("PaymentCurrency");
        if (DataAccessContext.Configurations.GetBoolValue("ShippingAddressMode"))
        {
            encoder["NOSHIPPING"] = "0";
        }
        else
        {
            encoder["NOSHIPPING"] = "1";
        }

        encoder["L_NAME0"] = "Payment for " + DataAccessContext.Configurations.GetValue(StoreContext.Culture.CultureID, "SiteName");
        encoder["L_AMT0"]  = Vevo.Domain.Currency.ConvertPriceToUSFormat(GetShoppingCartTotal().ToString("f2"));

        if (!UrlManager.IsMobile())
        {
            encoder["VERSION"] = "65.0";
        }

        string pStrrequestforNvp = encoder.Encode();
        string pStresponsenvp    = caller.Call(pStrrequestforNvp);

        NVPCodec decoder = new NVPCodec();

        decoder.Decode(pStresponsenvp);

        string strAck = decoder["ACK"];

        if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning"))
        {
            PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
                StoreContext.Culture, PaymentOption.PayPalProExpress);
            StoreContext.CheckoutDetails.PaymentMethod = paymentOption.CreatePaymentMethod();
            //PayPalProExpressUtilities.Instance.Token = decoder["TOKEN"];
            StoreContext.CheckoutDetails.CustomParameters[CheckoutDetails.PayPalProExpress_TokenID] = decoder["TOKEN"];
            if (UrlManager.IsFacebook())
            {
                string script = "window.parent.location.href='" + PayPalProExpressUtilities.Instance.UrlSetExpressCheckout(UrlManager.IsMobile()) + "&useraction=commit&token=" + decoder["TOKEN"] + "'";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "startScript", script, true);
            }
            else
            {
                Response.Redirect(PayPalProExpressUtilities.Instance.UrlSetExpressCheckout(UrlManager.IsMobile()) + "&useraction=commit&token=" + decoder["TOKEN"]);
            }
        }
        else
        {
            //PayPalProExpressUtilities.RedirectToErrorPage( decoder );
            CheckoutNotCompletePage.RedirectToPage(
                "Error Message",
                PayPalProExpressUtilities.GetErrorMessage(decoder),
                "ShoppingCart.aspx",
                "Return To Shopping");
        }
    }
    public NVPCodec DoCaptureCode(string authorization_id, string amount, string invoice_Id, string note)
    {
        NVPCallerServices caller = new NVPCallerServices();
        IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
        /*
         WARNING: Do not embed plaintext credentials in your application code.
         Doing so is insecure and against best practices.
         Your API credentials must be handled securely. Please consider
         encrypting them for use in any production environment, and ensure
         that only authorized individuals may view or modify them.
         */

        // Set up your API credentials, PayPal end point, API operation and version.
        profile.APIUsername = apiUserName;
        profile.APIPassword = apiPassword;
        profile.APISignature = apiSignature;
        profile.Environment = apiEnvironment;
        caller.APIProfile = profile;

        NVPCodec encoder = new NVPCodec();
        encoder["VERSION"] = "51.0";
        encoder["METHOD"] = "DoCapture";

        // Add request-specific fields to the request.
        encoder["TRXTYPE"] = "D";
        encoder["AUTHORIZATIONID"] = authorization_id;
        encoder["COMPLETETYPE"] = "Complete";
        encoder["AMT"] = amount;
        encoder["INVNUM"] = invoice_Id;
        encoder["NOTE"] = note;

        // Execute the API operation and obtain the response.
        string pStrrequestforNvp = encoder.Encode();
        string pStresponsenvp = caller.Call(pStrrequestforNvp);

        NVPCodec decoder = new NVPCodec();
        decoder.Decode(pStresponsenvp);
        return decoder;
    }
    public NVPCodec DoPayment(string paymentAction, string amount, string creditCardType, string creditCardNumber,
        string expdate_month, string expdate_year, string cvv2Number, string firstName, string lastName, string address1, string city, string state,
        string countryCode, string zip, string IPAddress)
    {
        NVPCallerServices caller = new NVPCallerServices();
        IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
        /*
         WARNING: Do not embed plaintext credentials in your application code.
         Doing so is insecure and against best practices.
         Your API credentials must be handled securely. Please consider
         encrypting them for use in any production environment, and ensure
         that only authorized individuals may view or modify them.
         */

        // Set up your API credentials, PayPal end point, API operation and version.
        profile.APIUsername = apiUserName;
        profile.APIPassword = apiPassword;
        profile.APISignature = apiSignature;
        profile.Environment = apiEnvironment;
        caller.APIProfile = profile;

        NVPCodec encoder = new NVPCodec();

        encoder["VERSION"] = "51.0";
        encoder["METHOD"] = "DoDirectPayment";

        // Add request-specific fields to the request.
        encoder["PAYMENTACTION"] = paymentAction;
        encoder["AMT"] = amount;
        encoder["CREDITCARDTYPE"] = creditCardType;
        encoder["ACCT"] = creditCardNumber;
        //encoder["EXPMONTH"] = "12";
        //encoder["EXPYEAR"] = "2012";
        if (expdate_month.Length == 1)
            expdate_month = "0" + expdate_month;
        encoder["EXPDATE"] = expdate_month + expdate_year;
        //encoder["ExpMonthSpecified"] = "True";
        //encoder["ExpYearSpecified"] = "True";
        encoder["CVV2"] = cvv2Number;
        encoder["FIRSTNAME"] = firstName;
        encoder["LASTNAME"] = lastName;
        encoder["STREET"] = address1;
        encoder["CITY"] = city;
        encoder["STATE"] = state;
        encoder["ZIP"] = zip;
        encoder["COUNTRYCODE"] = countryCode;
        encoder["CURRENCYCODE"] = "USD";
        encoder["IPADDRESS"] = IPAddress;

        // Execute the API operation and obtain the response.
        string pStrrequestforNvp = encoder.Encode();
        string pStresponsenvp = caller.Call(pStrrequestforNvp);

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

        //string allResults = pStrrequestforNvp + "<br/><br/>" + pStresponsenvp + "<br/><br/>";

        //foreach (string key in decoder.Keys)
        //{
        //    allResults += "key: '" + key + "', value: '" + decoder[key] + "' <br/>";
        //}
        //allResults += "<br/>Encoder:<br/>";
        //foreach (string key in encoder)
        //{
        //    allResults += "key: '" + key + "', value: '" + encoder[key] + "' <br/>";
        //}

        return decoder;
    }