public static string CreateDoExpressCheckoutPaymentQueryString(
            DoExpressCheckoutPaymentPayload payload) {

            var doExpressCheckoutPaymentMetadata = 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}, {
                    "PAYMENTREQUEST_0_PAYMENTACTION",
                    payload.PaymentRequestPaymentAction
                },
                {"PAYMENTREQUEST_0_AMT", payload.PaymentRequestAmt}, {
                    "PAYMENTREQUEST_0_CURRENCYCODE",
                    payload.PaymentRequestCurrencyCode
                },
                {"PAYMENTREQUEST_0_NOTIFYURL", payload.PaymentRequestNotifyUrl},
            };

            return string.Join("&",
                doExpressCheckoutPaymentMetadata.AllKeys.Select(
                    key => string.Concat(key, "=", HttpUtility.UrlEncode(
                        doExpressCheckoutPaymentMetadata[key]))));
        }
Пример #2
0
        public static string CreateDoExpressCheckoutPaymentQueryString(
            DoExpressCheckoutPaymentPayload payload)
        {
            var doExpressCheckoutPaymentMetadata = 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 }, {
                    "PAYMENTREQUEST_0_PAYMENTACTION",
                    payload.PaymentRequestPaymentAction
                },
                { "PAYMENTREQUEST_0_AMT", payload.PaymentRequestAmt }, {
                    "PAYMENTREQUEST_0_CURRENCYCODE",
                    payload.PaymentRequestCurrencyCode
                },
                { "PAYMENTREQUEST_0_NOTIFYURL", payload.PaymentRequestNotifyUrl },
            };

            return(string.Join("&",
                               doExpressCheckoutPaymentMetadata.AllKeys.Select(
                                   key => string.Concat(key, "=", HttpUtility.UrlEncode(
                                                            doExpressCheckoutPaymentMetadata[key])))));
        }
Пример #3
0
        /// <summary>
        ///     <see cref="DoExpressCheckoutPayment" /> asynchronous equivalent.
        ///     <seealso cref="DoExpressCheckoutPayment" />
        /// </summary>
        /// <param name="payload">
        ///     Metadata necessary to facilitate a successful
        ///     <b>DoExpressCheckoutPayment</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="TransactionResults" /> instance.
        /// </returns>
        public async Task <string> DoExpressCheckoutPaymentAsync(
            DoExpressCheckoutPaymentPayload payload,
            string expressCheckoutUri)
        {
            var queryString =
                ExpressCheckoutMetadataFactory
                .CreateDoExpressCheckoutPaymentQueryString(payload);

            using (var webClient = new WebClient()) {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                return(await webClient.DownloadStringTaskAsync(
                           new Uri(string.Concat(expressCheckoutUri, "?", queryString))));
            }
        }
        /// <summary>
        ///     <see cref="DoExpressCheckoutPayment" /> asynchronous equivalent.
        ///     <seealso cref="DoExpressCheckoutPayment" />
        /// </summary>
        /// <param name="payload">
        ///     Metadata necessary to facilitate a successful
        ///     <b>DoExpressCheckoutPayment</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="TransactionResults" /> instance.
        /// </returns>
        public async Task<string> DoExpressCheckoutPaymentAsync(
            DoExpressCheckoutPaymentPayload payload,
            string expressCheckoutUri) {

            var queryString =
                ExpressCheckoutMetadataFactory
                    .CreateDoExpressCheckoutPaymentQueryString(payload);

            using (var webClient = new WebClient()) {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                return await webClient.DownloadStringTaskAsync(
                    new Uri(string.Concat(expressCheckoutUri, "?", queryString)));
            }

        }
Пример #5
0
        /// <summary>
        ///     <see cref="DoExpressCheckoutPayment" /> asynchronous equivalent.
        ///     <seealso cref="DoExpressCheckoutPayment" />
        /// </summary>
        /// <param name="payload">
        ///     Metadata necessary to facilitate a successful
        ///     <b>DoExpressCheckoutPayment</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="TransactionResults" /> instance.
        /// </returns>
        public async Task<string> DoExpressCheckoutPaymentAsync(
            DoExpressCheckoutPaymentPayload payload,
            string expressCheckoutUri) {

            var queryString =
                ExpressCheckoutMetadataFactory
                    .CreateDoExpressCheckoutPaymentQueryString(payload);

            using (var webClient = new WebClient()) {

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

        }