Пример #1
0
        public IPaymentResponse Charge(PaymentRequest request)
        {
            RedirectResponse res = null;

            if (Setting == null)
            {
                return(res);
            }

            var ogoneApi = new OgoneApi(Setting);

            var checkoutRequest = new CreateHostedCheckoutRequest
            {
                Order = new Order
                {
                    AmountOfMoney = new AmountOfMoney
                    {
                        Amount       = (request.TotalAmount * 100).ToString("0"),
                        CurrencyCode = request.Currency
                    },
                    Customer = new Customer
                    {
                        BillingAddress = new Address
                        {
                            CountryCode = request.Country
                        },
                        MerchantCustomerId = Name
                    }
                }
            };
            var result = ogoneApi.Hostedcheckouts(checkoutRequest);

            if (result != null)
            {
                res = new RedirectResponse(string.Format("{0}.{1}", Setting.BaseUrl(), result.PartialRedirectUrl), request.Id);
            }
            return(res);
        }
Пример #2
0
        public IPaymentResponse Charge(PaymentRequest request)
        {
            RedirectResponse res = null;
            var additional       = new Dictionary <string, object>(request.Additional, StringComparer.OrdinalIgnoreCase);

            var variant    = GetValue(additional, "variant", null);
            var locale     = GetValue(additional, "locale", null);
            var paymentIds = GetValue(additional, "paymentIds", null);

            if (Setting == null)
            {
                return(res);
            }

            var ogoneApi = new OgoneApi(Setting);
            PaymentProductFiltersHostedCheckout PaymentProductFilters = null;

            if (paymentIds != null)
            {
                PaymentProductFilters = new PaymentProductFiltersHostedCheckout
                {
                    RestrictTo = new PaymentProductFilter
                    {
                        Products = paymentIds.Split(',').Select(Int32.Parse).ToList()
                    }
                };
            }

            var checkoutRequest = new CreateHostedCheckoutRequest
            {
                Order = new Order
                {
                    AmountOfMoney = new AmountOfMoney
                    {
                        Amount       = (request.TotalAmount * 100).ToString("0"),
                        CurrencyCode = request.Currency
                    },
                    Customer = new Customer
                    {
                        BillingAddress = new Address
                        {
                            CountryCode = request.Country
                        },
                        MerchantCustomerId = Name
                    }
                }
            };

            if (Setting.ReturnUrl != null)
            {
                checkoutRequest.HostedCheckoutSpecificInput = new HostedCheckoutSpecificInput
                {
                    ReturnUrl = Setting.ReturnUrl
                };
            }

            var result = ogoneApi.Hostedcheckouts(checkoutRequest);

            if (result != null)
            {
                res = new RedirectResponse(string.Format("{0}.{1}", Setting.BaseUrl(), result.PartialRedirectUrl), request.Id);
                request.ReferenceId = result.HostedCheckoutId;
            }

            return(res);
        }