private void PopulateCustomerDetails(PayPalReturn paypalDetails)
        {
            if ((paypalDetails == null) || paypalDetails.PayPalReturnUserInfo == null)
            {
                return;
            }

            if (paypalDetails.PayPalReturnUserInfo.Firstname != null)
            {
                ucUserDetails.FirstName = paypalDetails.PayPalReturnUserInfo.Firstname;
            }

            if (paypalDetails.PayPalReturnUserInfo.Lastname != null)
            {
                ucUserDetails.LastName = paypalDetails.PayPalReturnUserInfo.Lastname;
            }

            if (paypalDetails.PayPalReturnUserInfo.Email != null)
            {
                ucUserDetails.Email = paypalDetails.PayPalReturnUserInfo.Email;
            }

            if (paypalDetails.PayPalReturnUserInfo.AddressInfo == null)
            {
                return;
            }

            if (paypalDetails.PayPalReturnUserInfo.AddressInfo.Street != null)
            {
                ucUserDetails.Address1 = paypalDetails.PayPalReturnUserInfo.AddressInfo.Street;
            }

            if (paypalDetails.PayPalReturnUserInfo.AddressInfo.Street2 != null)
            {
                ucUserDetails.Address2 = paypalDetails.PayPalReturnUserInfo.AddressInfo.Street2;
            }

            if (paypalDetails.PayPalReturnUserInfo.AddressInfo.City != null)
            {
                ucUserDetails.Town = paypalDetails.PayPalReturnUserInfo.AddressInfo.City;
            }

            if (paypalDetails.PayPalReturnUserInfo.AddressInfo.Postcode != null)
            {
                ucUserDetails.PostCode = paypalDetails.PayPalReturnUserInfo.AddressInfo.Postcode;
            }

            if (paypalDetails.PayPalReturnUserInfo.AddressInfo.State != null)
            {
                ucUserDetails.PostCode = paypalDetails.PayPalReturnUserInfo.AddressInfo.State;
            }

            if (paypalDetails.PayPalReturnUserInfo.AddressInfo.CountryCode != null)
            {
                ucUserDetails.Country = paypalDetails.PayPalReturnUserInfo.AddressInfo.CountryCode;
            }
        }
        public PayPalReturn ConfirmCheckoutDetails(string token)
        {
            var encoder = new NvpCodec();

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

            var pStrrequestforNvp = encoder.Encode();
            var pStresponsenvp    = HttpCall(pStrrequestforNvp);
            //_log.Info(string.Concat("ConfirmCheckoutDetails | ", pStresponsenvp));

            var decoder = new NvpCodec();

            decoder.Decode(pStresponsenvp);

            var res = new PayPalReturn
            {
                PayPalReturnUserInfo = new PayPalReturnUserInfo(),
                AUK = decoder["ACK"].ToLower()
            };

            if (res.AUK != null && (res.AUK == "success" || res.AUK == "successwithwarning"))
            {
                res.Token = decoder["TOKEN"];
                res.PayPalReturnUserInfo.Payer_Id    = decoder["PAYERID"];
                res.PayPalReturnUserInfo.CountryCode = decoder["COUNTRYCODE"];
                res.PayPalReturnUserInfo.Firstname   = decoder["FIRSTNAME"];
                res.PayPalReturnUserInfo.Lastname    = decoder["LASTNAME"];
                res.PayPalReturnUserInfo.PayerStatus = decoder["PAYERSTATUS"];
                res.PayPalReturnUserInfo.Email       = decoder["EMAIL"];

                if (string.IsNullOrEmpty(decoder["SHIPTONAME"]))
                {
                    return(res);
                }

                res.PayPalReturnUserInfo.AddressInfo = new PayPalAddressInfo
                {
                    Name        = decoder["SHIPTONAME"],
                    Street      = decoder["SHIPTOSTREET"],
                    Street2     = decoder["SHIPTOSTREET2"],
                    City        = decoder["SHIPTOCITY"],
                    State       = decoder["SHIPTOSTATE"],
                    Postcode    = decoder["SHIPTOZIP"],
                    CountryCode = decoder["SHIPTOCOUNTRYCODE"]
                };
            }
            else
            {
                res.IsError      = true;
                res.ErrorMessage = decoder["L_LONGMESSAGE0"]; //decoder["L_SHORTMESSAGE0"]
                res.ErrorCode    = decoder["L_ERRORCODE0"];
            }

            return(res);
        }
예제 #3
0
    public PayPalReturn GetTransactionDetails(string transactionID)
    {
        //PayPal Return Structure
        PayPalReturn rv = new PayPalReturn();

        rv.IsSucess = false;

        //Requests
        //TransactionID = "6XT85330WL909250J"
        GetTransactionDetailsReq request = new GetTransactionDetailsReq();

        request.GetTransactionDetailsRequest = new GetTransactionDetailsRequestType();
        request.GetTransactionDetailsRequest.TransactionID = transactionID;
        request.GetTransactionDetailsRequest.Version       = "51.0";

        //Headers
        CustomSecurityHeaderType headers = new CustomSecurityHeaderType();

        headers.Credentials           = new UserIdPasswordType();
        headers.Credentials.Username  = ConfigurationManager.AppSettings["PayPalAPIUsername"];
        headers.Credentials.Password  = ConfigurationManager.AppSettings["PayPalAPIPassword"];
        headers.Credentials.Signature = ConfigurationManager.AppSettings["PayPalAPISignature"];

        //Client
        PayPalAPISoapBinding client = new PayPalAPISoapBinding();

        client.RequesterCredentials = headers;
        client.Timeout = 15000;
        GetTransactionDetailsResponseType response = client.GetTransactionDetails(request);

        if (response.Ack == AckCodeType.Success || response.Ack == AckCodeType.SuccessWithWarning)
        {
            rv.IsSucess      = true;
            rv.TransactionID = response.PaymentTransactionDetails.PaymentInfo.TransactionID;
            rv.ObjectValue   = response.PaymentTransactionDetails;
        }
        else
        {
            rv.ErrorMessage = response.Errors[0].LongMessage;
        }
        return(rv);
    }
        public PayPalReturn ConfirmPayment(string finalPaymentAmount, string currencyCode, string token, string PayerId)
        {
            var encoder = new NvpCodec();

            encoder["METHOD"]             = "DoExpressCheckoutPayment";
            encoder["TOKEN"]              = token;
            encoder["PAYMENTACTION"]      = "Sale";
            encoder["PAYERID"]            = PayerId;
            encoder["AMT"]                = finalPaymentAmount;
            encoder["CURRENCYCODE"]       = currencyCode;
            encoder["NOSHIPPING"]         = "1";
            encoder["REQCONFIRMSHIPPING"] = "0";

            var pStrrequestforNvp = encoder.Encode();
            var pStresponsenvp    = HttpCall(pStrrequestforNvp);

            var decoder = new NvpCodec();

            decoder.Decode(pStresponsenvp);

            var res = new PayPalReturn
            {
                PayPalReturnUserInfo = new PayPalReturnUserInfo(),
                AUK = decoder["ACK"].ToLower()
            };

            if (res.AUK != null && (res.AUK == "success" || res.AUK == "successwithwarning"))
            {
                res.Token = decoder["TOKEN"];
                res.PayPalReturnUserInfo.Payer_Id = decoder["PAYERID"];
                res.Transaction_Id = decoder["TRANSACTIONID"];
            }
            else
            {
                res.IsError      = true;
                res.ErrorMessage = decoder["L_LONGMESSAGE0"]; //decoder["L_SHORTMESSAGE0"]
                res.ErrorCode    = decoder["L_ERRORCODE0"];
            }

            return(res);
        }
예제 #5
0
    public PayPalReturn GetTransactionDetails(string transactionID)
    {
        //PayPal Return Structure
        PayPalReturn rv = new PayPalReturn();
        rv.IsSucess = false;

        //Requests
        //TransactionID = "6XT85330WL909250J"
        GetTransactionDetailsReq request = new GetTransactionDetailsReq();
        request.GetTransactionDetailsRequest = new GetTransactionDetailsRequestType();
        request.GetTransactionDetailsRequest.TransactionID = transactionID;
        request.GetTransactionDetailsRequest.Version = "51.0";

        //Headers
        CustomSecurityHeaderType headers = new CustomSecurityHeaderType();
        headers.Credentials = new UserIdPasswordType();
        headers.Credentials.Username = ConfigurationManager.AppSettings["PayPalAPIUsername"];
        headers.Credentials.Password = ConfigurationManager.AppSettings["PayPalAPIPassword"];
        headers.Credentials.Signature = ConfigurationManager.AppSettings["PayPalAPISignature"];

        //Client
        PayPalAPISoapBinding client = new PayPalAPISoapBinding();
        client.RequesterCredentials = headers;
        client.Timeout = 15000;
        GetTransactionDetailsResponseType response = client.GetTransactionDetails(request);

        if (response.Ack == AckCodeType.Success || response.Ack == AckCodeType.SuccessWithWarning)
        {
            rv.IsSucess = true;
            rv.TransactionID = response.PaymentTransactionDetails.PaymentInfo.TransactionID;
            rv.ObjectValue = response.PaymentTransactionDetails;
        }
        else
        {
            rv.ErrorMessage = response.Errors[0].LongMessage;
        }
        return rv;
    }
        /// <summary>
        /// ShortcutExpressCheckout: The method that calls SetExpressCheckout API
        /// </summary>
        public PayPalReturn ShortcutExpressCheckout(string returnUrl, string cancelUrl, string pageStyle, PayPalOrder order, bool commit,
                                                    string solutionType = null)
        {
            var encoder = new NvpCodec();

            encoder["METHOD"]        = "SetExpressCheckout";
            encoder["RETURNURL"]     = returnUrl;
            encoder["CANCELURL"]     = cancelUrl;
            encoder["AMT"]           = order.OrderTotal.ToString("N2");
            encoder["TAXAMT"]        = order.OrderTaxTotal.ToString("N2");
            encoder["ITEMAMT"]       = order.OrderSubTotal.ToString("N2");
            encoder["PAYMENTACTION"] = "Sale";
            encoder["CURRENCYCODE"]  = order.ISOCurrencyCode;

            encoder["NOSHIPPING"]         = "0";
            encoder["LOCALECODE"]         = order.orderLanguage;
            encoder["REQCONFIRMSHIPPING"] = "0";
            if (!string.IsNullOrEmpty(solutionType))
            {
                encoder["SOLUTIONTYPE"] = solutionType;
            }

            if (!string.IsNullOrEmpty(pageStyle))
            {
                encoder["PAGESTYLE"] = pageStyle;
            }

            var c = 0;

            foreach (var item in order.Items)
            {
                encoder[string.Concat("L_NAME", c)]   = item.ProductName;
                encoder[string.Concat("L_AMT", c)]    = item.LineItemPrice.ToString("N2");
                encoder[string.Concat("L_NUMBER", c)] = item.ProductId;
                encoder[string.Concat("L_QTY", c)]    = item.Quantity.ToString();
                encoder[string.Concat("L_TAXAMT", c)] = item.LineItemTax.ToString("N2");
                c++;
            }

            var pStrrequestforNvp = encoder.Encode();
            var pStresponsenvp    = HttpCall(pStrrequestforNvp);

            var decoder = new NvpCodec();

            decoder.Decode(pStresponsenvp);

            var res = new PayPalReturn {
                AUK = decoder["ACK"].ToLower()
            };

            if (res.AUK != null && (res.AUK == "success" || res.AUK == "successwithwarning"))
            {
                res.Token       = decoder["TOKEN"];
                res.RedirectURL = string.Concat(_payPalUrl, "&token=", res.Token, commit ? "&useraction=commit" : string.Empty);
            }
            else
            {
                res.IsError      = true;
                res.ErrorMessage = decoder["L_LONGMESSAGE0"]; //decoder["L_SHORTMESSAGE0"]
                res.ErrorCode    = decoder["L_ERRORCODE0"];
                LoggerService.LogItem(res.ErrorCode + Environment.NewLine + res.ErrorMessage);
            }

            return(res);
        }
예제 #7
0
    public PayPalReturn Pay(string orderNumber, string paymentAmount, string buyerLastName, string buyerFirstName, string buyerAddress, string buyerCity, string buyerStateOrProvince, string buyerCountryCode, string buyerCountryName, string buyerZipCode, string creditCardType, string creditCardNumber, string CVV2, string expMonth, string expYear)
    {
        //PayPal Return Structure
        PayPalReturn rv = new PayPalReturn();

        rv.IsSucess = false;

        DoDirectPaymentRequestDetailsType requestDetails = new DoDirectPaymentRequestDetailsType();

        requestDetails.CreditCard                     = new CreditCardDetailsType();
        requestDetails.CreditCard.CardOwner           = new PayerInfoType();
        requestDetails.CreditCard.CardOwner.Address   = new AddressType();
        requestDetails.PaymentDetails                 = new PaymentDetailsType();
        requestDetails.PaymentDetails.OrderTotal      = new BasicAmountType();
        requestDetails.CreditCard.CardOwner.PayerName = new PersonNameType();

        //Request
        requestDetails.PaymentAction = PaymentActionCodeType.Sale;
        requestDetails.IPAddress     = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

        //Payment
        requestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD;
        requestDetails.PaymentDetails.OrderTotal.Value      = paymentAmount;

        //Credit card
        requestDetails.CreditCard.CreditCardNumber        = creditCardNumber;
        requestDetails.CreditCard.CreditCardType          = (CreditCardTypeType)Enum.Parse(typeof(CreditCardTypeType), creditCardType, true);
        requestDetails.CreditCard.ExpMonth                = Convert.ToInt32(expMonth);
        requestDetails.CreditCard.ExpYear                 = Convert.ToInt32(expYear);
        requestDetails.CreditCard.CVV2                    = CVV2;
        requestDetails.CreditCard.CreditCardTypeSpecified = true;
        requestDetails.CreditCard.ExpMonthSpecified       = true;
        requestDetails.CreditCard.ExpYearSpecified        = true;

        //Card Owner
        requestDetails.CreditCard.CardOwner.PayerName.FirstName      = buyerFirstName;
        requestDetails.CreditCard.CardOwner.PayerName.LastName       = buyerLastName;
        requestDetails.CreditCard.CardOwner.Address.Street1          = buyerAddress;
        requestDetails.CreditCard.CardOwner.Address.CityName         = buyerCity;
        requestDetails.CreditCard.CardOwner.Address.StateOrProvince  = buyerStateOrProvince;
        requestDetails.CreditCard.CardOwner.Address.CountryName      = buyerCountryName;
        requestDetails.CreditCard.CardOwner.Address.Country          = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), buyerCountryCode, true);
        requestDetails.CreditCard.CardOwner.Address.PostalCode       = buyerZipCode;
        requestDetails.CreditCard.CardOwner.Address.CountrySpecified = true;
        requestDetails.CreditCard.CardOwner.PayerCountry             = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), buyerCountryCode, true);
        requestDetails.CreditCard.CardOwner.PayerCountrySpecified    = true;

        DoDirectPaymentReq request = new DoDirectPaymentReq();

        request.DoDirectPaymentRequest = new DoDirectPaymentRequestType();
        request.DoDirectPaymentRequest.DoDirectPaymentRequestDetails = requestDetails;
        request.DoDirectPaymentRequest.Version = "51.0";

        //Headers
        CustomSecurityHeaderType headers = new CustomSecurityHeaderType();

        headers.Credentials           = new UserIdPasswordType();
        headers.Credentials.Username  = ConfigurationManager.AppSettings["PayPalAPIUsername"];
        headers.Credentials.Password  = ConfigurationManager.AppSettings["PayPalAPIPassword"];
        headers.Credentials.Signature = ConfigurationManager.AppSettings["PayPalAPISignature"];

        //Client
        PayPalAPIAASoapBinding client = new PayPalAPIAASoapBinding();

        client.RequesterCredentials = headers;
        client.Timeout = 15000;
        DoDirectPaymentResponseType response = client.DoDirectPayment(request);

        if (response.Ack == AckCodeType.Success || response.Ack == AckCodeType.SuccessWithWarning)
        {
            rv.IsSucess      = true;
            rv.TransactionID = response.TransactionID;
        }
        else
        {
            rv.ErrorMessage = response.Errors[0].LongMessage;
        }
        return(rv);
    }
예제 #8
0
    public PayPalReturn Pay(string orderNumber, string paymentAmount, string buyerLastName, string buyerFirstName, string buyerAddress, string buyerCity, string buyerStateOrProvince, string buyerCountryCode, string buyerCountryName, string buyerZipCode, string creditCardType, string creditCardNumber, string CVV2, string expMonth, string expYear)
    {
        //PayPal Return Structure
        PayPalReturn rv = new PayPalReturn();
        rv.IsSucess = false;

        DoDirectPaymentRequestDetailsType requestDetails = new DoDirectPaymentRequestDetailsType();
        requestDetails.CreditCard = new CreditCardDetailsType();
        requestDetails.CreditCard.CardOwner = new PayerInfoType();
        requestDetails.CreditCard.CardOwner.Address = new AddressType();
        requestDetails.PaymentDetails = new PaymentDetailsType();
        requestDetails.PaymentDetails.OrderTotal = new BasicAmountType();
        requestDetails.CreditCard.CardOwner.PayerName = new PersonNameType();

        //Request
        requestDetails.PaymentAction = PaymentActionCodeType.Sale;
        requestDetails.IPAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

        //Payment
        requestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD;
        requestDetails.PaymentDetails.OrderTotal.Value = paymentAmount;

        //Credit card
        requestDetails.CreditCard.CreditCardNumber = creditCardNumber;
        requestDetails.CreditCard.CreditCardType = (CreditCardTypeType)Enum.Parse(typeof(CreditCardTypeType), creditCardType, true);
        requestDetails.CreditCard.ExpMonth = Convert.ToInt32(expMonth);
        requestDetails.CreditCard.ExpYear = Convert.ToInt32(expYear);
        requestDetails.CreditCard.CVV2 = CVV2;
        requestDetails.CreditCard.CreditCardTypeSpecified = true;
        requestDetails.CreditCard.ExpMonthSpecified = true;
        requestDetails.CreditCard.ExpYearSpecified = true;

        //Card Owner
        requestDetails.CreditCard.CardOwner.PayerName.FirstName = buyerFirstName;
        requestDetails.CreditCard.CardOwner.PayerName.LastName = buyerLastName;
        requestDetails.CreditCard.CardOwner.Address.Street1 = buyerAddress;
        requestDetails.CreditCard.CardOwner.Address.CityName = buyerCity;
        requestDetails.CreditCard.CardOwner.Address.StateOrProvince = buyerStateOrProvince;
        requestDetails.CreditCard.CardOwner.Address.CountryName = buyerCountryName;
        requestDetails.CreditCard.CardOwner.Address.Country = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), buyerCountryCode, true);
        requestDetails.CreditCard.CardOwner.Address.PostalCode = buyerZipCode;
        requestDetails.CreditCard.CardOwner.Address.CountrySpecified = true;
        requestDetails.CreditCard.CardOwner.PayerCountry = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), buyerCountryCode, true);
        requestDetails.CreditCard.CardOwner.PayerCountrySpecified = true;

        DoDirectPaymentReq request = new DoDirectPaymentReq();
        request.DoDirectPaymentRequest = new DoDirectPaymentRequestType();
        request.DoDirectPaymentRequest.DoDirectPaymentRequestDetails = requestDetails;
        request.DoDirectPaymentRequest.Version = "51.0";

        //Headers
        CustomSecurityHeaderType headers = new CustomSecurityHeaderType();
        headers.Credentials = new UserIdPasswordType();
        headers.Credentials.Username = ConfigurationManager.AppSettings["PayPalAPIUsername"];
        headers.Credentials.Password = ConfigurationManager.AppSettings["PayPalAPIPassword"];
        headers.Credentials.Signature = ConfigurationManager.AppSettings["PayPalAPISignature"];

        //Client
        PayPalAPIAASoapBinding client = new PayPalAPIAASoapBinding();
        client.RequesterCredentials = headers;
        client.Timeout = 15000;
        DoDirectPaymentResponseType response = client.DoDirectPayment(request);
        if (response.Ack == AckCodeType.Success || response.Ack == AckCodeType.SuccessWithWarning)
        {
            rv.IsSucess = true;
            rv.TransactionID = response.TransactionID;
        }
        else
        {
            rv.ErrorMessage = response.Errors[0].LongMessage;
        }
        return rv;
    }
        public PayPalReturn Pay(string orderNumber, string paymentAmount, string buyerLastName, string buyerFirstName, string buyerAddress, string buyerCity, string buyerStateOrProvince, string buyerCountryCode, string buyerCountryName, string buyerZipCode, string creditCardType, string creditCardNumber, string CVV2, string expMonth, string expYear)
        {
            //PayPal Return Structure
            PayPalReturn rv = new PayPalReturn();
            rv.IsSucess = false;

            DoDirectPaymentRequestDetailsType requestDetails = new DoDirectPaymentRequestDetailsType();
            requestDetails.CreditCard = new CreditCardDetailsType();
            requestDetails.CreditCard.CardOwner = new PayerInfoType();
            requestDetails.CreditCard.CardOwner.Address = new AddressType();
            requestDetails.PaymentDetails = new PaymentDetailsType();
            requestDetails.PaymentDetails.OrderTotal = new BasicAmountType();
            requestDetails.CreditCard.CardOwner.PayerName = new PersonNameType();

            //Request
            requestDetails.PaymentAction = PaymentActionCodeType.Sale;
            requestDetails.IPAddress = "127.0.0.1"; //HttpContext.Current.Request.UserHostAddress;

            //Payment
            requestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD;
            requestDetails.PaymentDetails.OrderTotal.Value = paymentAmount;
            requestDetails.MerchantSessionId = "Z46G3JU4SEEDC";

            //requestDetails.PaymentDetails.AllowedPaymentMethod = AllowedPaymentMethodType.Default;

            //  requestDetails.PaymentDetails.PaymentAction = PaymentActionCodeType.Sale;

            //Credit card
            requestDetails.CreditCard.CreditCardNumber = creditCardNumber;
            requestDetails.CreditCard.CreditCardType = (CreditCardTypeType)Enum.Parse(typeof(CreditCardTypeType), creditCardType, true);
            requestDetails.CreditCard.ExpMonth = Convert.ToInt32(expMonth);
            requestDetails.CreditCard.ExpYear = Convert.ToInt32(expYear);
            requestDetails.CreditCard.CVV2 = CVV2;
            requestDetails.CreditCard.CreditCardTypeSpecified = true;
            requestDetails.CreditCard.ExpMonthSpecified = true;
            requestDetails.CreditCard.ExpYearSpecified = true;

            //Card Owner
            requestDetails.CreditCard.CardOwner.PayerName.FirstName = buyerFirstName;
            requestDetails.CreditCard.CardOwner.PayerName.LastName = buyerLastName;
            requestDetails.CreditCard.CardOwner.Address.Street1 = buyerAddress;
            requestDetails.CreditCard.CardOwner.Address.CityName = buyerCity;
            requestDetails.CreditCard.CardOwner.Address.StateOrProvince = buyerStateOrProvince;
            requestDetails.CreditCard.CardOwner.Address.CountryName = buyerCountryName;
            requestDetails.CreditCard.CardOwner.Address.Country = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), buyerCountryCode, true);
            requestDetails.CreditCard.CardOwner.Address.PostalCode = buyerZipCode;
            requestDetails.CreditCard.CardOwner.Address.CountrySpecified = true;
            requestDetails.CreditCard.CardOwner.PayerCountry = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), buyerCountryCode, true);
            requestDetails.CreditCard.CardOwner.PayerCountrySpecified = true;

            DoDirectPaymentReq request = new DoDirectPaymentReq();
            request.DoDirectPaymentRequest = new DoDirectPaymentRequestType();
            request.DoDirectPaymentRequest.DoDirectPaymentRequestDetails = requestDetails;
            request.DoDirectPaymentRequest.Version = "63";

            //Headers
            CustomSecurityHeaderType headers = new CustomSecurityHeaderType();

            headers.Credentials = new UserIdPasswordType();
            //"linhdaigia_crista_api1.yahoo.com.vn";
            //"KAM8YZ2ZG6P9GRM5";
            //"A.FSKSXlaJhdHcmij1IXGU62TZ6vAuB5Sq1ZbiMYCO-vRFuWXiSJSfn5";
            //headers.Credentials.Username = "******";
            //headers.Credentials.Password = "******";
            //headers.Credentials.Signature = "A.FSKSXlaJhdHcmij1IXGU62TZ6vAuB5Sq1ZbiMYCO-vRFuWXiSJSfn5";
            //headers.Credentials.Subject = ""; //"*****@*****.**";

            headers.Credentials.Username = ConfigurationManager.AppSettings["PayPalSandboxAPIUserName"];
            headers.Credentials.Password = ConfigurationManager.AppSettings["PayPalSandboxAPIPassword"];
            headers.Credentials.Signature = ConfigurationManager.AppSettings["PayPalSandboxAPISignature"];
            headers.Credentials.Subject = ""; //"*****@*****.**";

            //   headers.DidUnderstand = true;

            //Client

            PayPalAPIAASoapBinding client = new PayPalAPIAASoapBinding();
            //  client.Url = "https://api-3t.sandbox.paypal.com/2.0/";
            client.Url = "https://api-3t.sandbox.paypal.com/nvp";
            //    client.Url="https://api-3t.paypal.com/2.0/";
            //  client.Url = "https://api-aa-3t.paypal.com/2.0/";
            // client.Url = "https://api-aa.sandbox.paypal.com/2.0/";
            client.RequesterCredentials = headers;
            client.Timeout = 15000;
            // client.UseDefaultCredentials = true;

            //   ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

            // allows for validation of SSL conversations
            //    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            DoDirectPaymentResponseType response = client.DoDirectPayment(request);
            if (response.Ack == AckCodeType.Success || response.Ack == AckCodeType.SuccessWithWarning)
            {
                rv.IsSucess = true;
                rv.TransactionID = response.TransactionID;
            }
            else
            {
                rv.ErrorMessage = response.Errors[0].LongMessage;
                rv.errorcode = response.Errors[0].ErrorCode;
            }
            return rv;
        }