Beispiel #1
0
        public PaymentStatusResponse checkStatus(PaymentRequest request)
        {
            var ogoneApi = new OgoneApi(Setting);
            var resp     = new PaymentStatusResponse();

            var result = ogoneApi.GetHostedcheckouts(request.ReferenceId);

            if (request != null)
            {
                if (string.Equals(result.Status, "PAYMENT_CREATED", StringComparison.OrdinalIgnoreCase))
                {
                    resp.Status = ConvertStatus(result.CreatedPaymentOutput?.Payment.StatusOutput.StatusCategory);
                }
                else
                {
                    resp.Status = PaymentStatus.NotAvailable;
                }
            }
            else
            {
                resp.Status = PaymentStatus.NotAvailable;
            }

            return(resp);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public PaymentCallback Notify(RenderContext context)
        {
            var ogoneApi   = new OgoneApi(Setting);
            var verifyCode = context.Request.Headers.Get("X-GCS-Webhooks-Endpoint-Verification");

            if (!string.IsNullOrEmpty(verifyCode))
            {
                return(new PaymentCallback
                {
                    CallbackResponse = new Callback.CallbackResponse
                    {
                        Content = verifyCode,
                    }
                });
            }

            var webHook = ogoneApi.Unmarshal(context.Request.PostData, context.Request.Headers);
            var request = PaymentManager.GetRequestByReferece(webHook.Payment.HostedCheckoutSpecificOutput?.HostedCheckoutId?.ToString(), context);

            if (request != null)
            {
                var status = ConvertStatus(webHook.Payment.StatusOutput.StatusCategory);

                return(new PaymentCallback
                {
                    RequestId = request.Id,
                    Status = status,
                    RawData = context.Request.Body,
                    CallbackResponse = new Callback.CallbackResponse
                    {
                        Content = verifyCode,
                    }
                });
            }

            return(null);
        }
Beispiel #4
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);
        }