Exemple #1
0
        /// <summary>
        ///     Executes PayPal's <b>GetExpressCheckoutDetails</b> function in order
        ///     to return PayPal <see cref="CustomerDetails" />.
        /// </summary>
        /// <param name="payload">
        ///     Metadata necessary to facilitate a successful
        ///     <b>GetExpressCheckoutDetails</b> call. Payload will be converted to
        ///     key-value format.
        /// </param>
        /// <param name="expressCheckoutUri">Default PayPal ExpressCheckout HTTP URI.</param>
        /// <returns>
        ///     A <see cref="Task" /> of <see cref="string" />, representing a
        ///     serialised <see cref="CustomerDetails" /> instance.
        /// </returns>
        public string GetExpressCheckoutDetails(
            GetExpressCheckoutDetailsPayload payload, string expressCheckoutUri)
        {
            var queryString =
                ExpressCheckoutMetadataFactory
                .CreateGetExpressCheckoutDetailsQueryString(payload);

            using (var webClient = new WebClient()) {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                return(webClient.DownloadString(
                           new Uri(string.Concat(expressCheckoutUri, "?", queryString))));
            }
        }
Exemple #2
0
        public static string CreateGetExpressCheckoutDetailsQueryString(
            GetExpressCheckoutDetailsPayload payload)
        {
            var getExpressCheckoutDetailsMetadata = new NameValueCollection {
                { "METHOD", payload.Method },
                { "VERSION", payload.Version },
                { "USER", payload.User },
                { "PWD", payload.Password },
                { "SIGNATURE", payload.Signature },
                { "SUBJECT", payload.Subject },
                { "TOKEN", payload.AccessToken },
                { "PAYERID", payload.PayerID },
            };

            return(string.Join("&",
                               getExpressCheckoutDetailsMetadata.AllKeys.Select(
                                   key => string.Concat(key, "=", HttpUtility.UrlEncode(
                                                            getExpressCheckoutDetailsMetadata[key])))));
        }
        public static string CreateGetExpressCheckoutDetailsQueryString(
            GetExpressCheckoutDetailsPayload payload) {

            var getExpressCheckoutDetailsMetadata = new NameValueCollection {
                {"METHOD", payload.Method},
                {"VERSION", payload.Version},
                {"USER", payload.User},
                {"PWD", payload.Password},
                {"SIGNATURE", payload.Signature},
                {"SUBJECT", payload.Subject},
                {"TOKEN", payload.AccessToken},
                {"PAYERID", payload.PayerID},
            };

            return string.Join("&",
                getExpressCheckoutDetailsMetadata.AllKeys.Select(
                    key => string.Concat(key, "=", HttpUtility.UrlEncode(
                        getExpressCheckoutDetailsMetadata[key]))));

        }
        /// <summary>
        ///     Executes PayPal's <b>GetExpressCheckoutDetails</b> function in order
        ///     to return PayPal <see cref="CustomerDetails" />.
        /// </summary>
        /// <param name="payload">
        ///     Metadata necessary to facilitate a successful
        ///     <b>GetExpressCheckoutDetails</b> call. Payload will be converted to
        ///     key-value format.
        /// </param>
        /// <param name="expressCheckoutUri">Default PayPal ExpressCheckout HTTP URI.</param>
        /// <returns>
        ///     A <see cref="Task" /> of <see cref="string" />, representing a
        ///     serialised <see cref="CustomerDetails" /> instance.
        /// </returns>
        public string GetExpressCheckoutDetails(
            GetExpressCheckoutDetailsPayload payload, string expressCheckoutUri) {

            var queryString =
                ExpressCheckoutMetadataFactory
                    .CreateGetExpressCheckoutDetailsQueryString(payload);

            using (var webClient = new WebClient()) {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                return webClient.DownloadString(
                    new Uri(string.Concat(expressCheckoutUri, "?", queryString)));
            }
        }
        /// <summary>
        ///     Executes PayPal's <b>GetExpressCheckoutDetails</b> function in order
        ///     to return PayPal <see cref="CustomerDetails" />.
        /// </summary>
        /// <param name="payload">
        ///     Metadata necessary to facilitate a successful
        ///     <b>GetExpressCheckoutDetails</b> call. Payload will be converted to
        ///     key-value format.
        /// </param>
        /// <param name="expressCheckoutUri">Default PayPal ExpressCheckout HTTP URI.</param>
        /// <returns>
        ///     A <see cref="Task" /> of <see cref="string" />, representing a
        ///     serialised <see cref="CustomerDetails" /> instance.
        /// </returns>
        public string GetExpressCheckoutDetails(
            GetExpressCheckoutDetailsPayload payload, string expressCheckoutUri) {

            var queryString =
                ExpressCheckoutMetadataFactory
                    .CreateGetExpressCheckoutDetailsQueryString(payload);

            using (var webClient = new WebClient()) {

                return webClient.DownloadString(
                    new Uri(string.Concat(expressCheckoutUri, "?", queryString)));
            }
        }