/// <summary>
        /// Set express checkout
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="operation"></param>
        /// <returns></returns>
        public static PayPalSetExpressCheckoutResult SetExpressCheckout(this Controller controller, PayPalSetExpressCheckoutOperation operation, [AspMvcAction] string confirmAction, [AspMvcAction] string cancelAction, object routeData = null)
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }

            if (operation == null)
            {
                throw new ArgumentNullException("request");
            }

            var operationToUse = operation;

            if (string.IsNullOrWhiteSpace(operationToUse.CancelURL) || string.IsNullOrWhiteSpace(operationToUse.ReturnURL))
            {
                // Need to clone to avoid side effect on passed object.
                if (operationToUse == operation)
                {
                    operationToUse = operation.Clone();
                }

                SetupExpressCheckoutUrls(controller, operationToUse, confirmAction, cancelAction, routeData);
            }

            // Calling the PayPal API, and returning the result.
            var settings = DependencyResolver.Current.GetService <IPayPalApiSettings>();
            var api      = new PayPalApiConfigurable(settings ?? new PayPalApiSettingsFromConfigurationManager());
            var response = api.SetExpressCheckout(operationToUse);

            return(response);
        }
Beispiel #2
0
        public override PayPalSetExpressCheckoutResult SetExpressCheckout(PayPalSetExpressCheckoutOperation operation)
        {
            var operationToUse = operation;

            SetupCredential(operation, ref operationToUse);

            SetupDefaultCurrencyCode(operation, ref operationToUse);

            // If LocaleCode is undefined then load it from the configuration file.
            if (operationToUse.LocaleCode != LocaleCode.Undefined)
            {
                if (operationToUse != operation)
                {
                    operationToUse = operation.Clone();
                }

                var        locale = this.configurations.LocalCode;
                LocaleCode outValue;
                if (Enum.TryParse(locale, out outValue))
                {
                    operationToUse.LocaleCode = outValue;
                }
            }

            // Calling the API.
            return(base.SetExpressCheckout(operationToUse));
        }