private ActionResult ProcessingResult_Uniteller(ProcessingResultModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     PaymentResultContext context = new PaymentResultContext();
     if (model.success == true)
     {
         context.Success = true;
     }
     else
     {
         context.Errors.Add(PaymentStrings.PaymentCancelled);
     }
     return base.View("_ProcessingResult", context);
 }
        private ActionResult ProcessingResult_PayU(ProcessingResultModel model)
        {
            if (model == null)
            {
                throw new System.ArgumentNullException("model");
            }
            PaymentResultContext context = new PaymentResultContext();
            if (model.success == true)
            {
                context.Success = true;
                context.Order = model.order;
                ConfirmInvoiceResult invoiceResult = BookingProvider.ConfirmInvoice(model.invoice);

                Tracing.DataTrace.TraceEvent(TraceEventType.Information, 0, "PAYU transaction: invoice: '{0}', invoice confirmation: '{1}'", new object[]
                {
                    model.invoice,
                    invoiceResult.IsSuccess ? "SUCCESS" : "FAILED"
                });

                if (!invoiceResult.IsSuccess)
                {
                    context.Errors.Add(string.Format("invoice confirmation error: {0}", invoiceResult.ErrorMessage));
                }
                else
                {
                    context.Success = true;
                    BookingProvider.AcceptInvoice(Convert.ToInt32(context.Order));
                }
            }
            else
            {
                context.Errors.Add(PaymentStrings.PaymentCancelled);
            }
            return base.View("_ProcessingResult", context);
        }
        public ActionResult ProcessingResult(string id, ProcessingResultModel model)
        {
            string text = (id ?? "").ToLowerInvariant();

            if (text != null)
            {
                switch (text)
                {
                    case "paypal":
                        return this.ProcessingResult_PayPal(model);

                    case "uniteller":
                        return this.ProcessingResult_Uniteller(model);

                    case "payu":
                        model.success = model.result == "1";
                        return this.ProcessingResult_PayU(model);

                    default:
                        break;
                }
            }
            throw new Exception(string.Format("unsupported processing system '{0}'", id));
        }
        private ActionResult ProcessingResult_PayPal(ProcessingResultModel model)
        {
            if (model == null)
            {
                throw new System.ArgumentNullException("model");
            }
            PaymentResultContext context = new PaymentResultContext();
            context.Order = model.order;
            if (model.success == true)
            {
                if (model.token == null)
                {
                    throw new System.ArgumentNullException("token");
                }
                if (model.payerID == null)
                {
                    throw new System.ArgumentNullException("payerID");
                }
                GetExpressCheckoutDetailsRequestType request = new GetExpressCheckoutDetailsRequestType();
                request.Version = "104.0";
                request.Token = model.token;
                GetExpressCheckoutDetailsReq wrapper = new GetExpressCheckoutDetailsReq();
                wrapper.GetExpressCheckoutDetailsRequest = request;
                System.Collections.Generic.Dictionary<string, string> config = PaymentController.PayPal_CreateConfig();
                PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(config);
                GetExpressCheckoutDetailsResponseType ecResponse = service.GetExpressCheckoutDetails(wrapper);
                if (ecResponse == null)
                {
                    throw new System.Exception("checkout details result is null");
                }
                if (ecResponse.Errors != null && ecResponse.Errors.Count > 0)
                {
                    ecResponse.Errors.ForEach(delegate (ErrorType m)
                    {
                        context.Errors.Add(m.LongMessage);
                    });
                }
                if (ecResponse.Ack == AckCodeType.SUCCESS || ecResponse.Ack == AckCodeType.SUCCESSWITHWARNING)
                {
                    GetExpressCheckoutDetailsResponseDetailsType details = ecResponse.GetExpressCheckoutDetailsResponseDetails;
                    if (details == null)
                    {
                        throw new System.Exception("details object is null");
                    }
                    if (string.IsNullOrEmpty(details.InvoiceID))
                    {
                        throw new System.Exception("invoiceID not found");
                    }
                    if (details.PaymentDetails == null)
                    {
                        throw new System.Exception("payment details is null");
                    }
                    System.Collections.Generic.List<PaymentDetailsType> paymentDetails = new System.Collections.Generic.List<PaymentDetailsType>();
                    foreach (PaymentDetailsType payment in details.PaymentDetails)
                    {
                        paymentDetails.Add(new PaymentDetailsType
                        {
                            NotifyURL = null,
                            PaymentAction = payment.PaymentAction,
                            OrderTotal = payment.OrderTotal
                        });
                    }
                    DoExpressCheckoutPaymentRequestType paymentRequest = new DoExpressCheckoutPaymentRequestType();
                    paymentRequest.Version = "104.0";
                    paymentRequest.DoExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType
                    {
                        PaymentDetails = paymentDetails,
                        Token = model.token,
                        PayerID = model.payerID
                    };
                    DoExpressCheckoutPaymentResponseType doECResponse = service.DoExpressCheckoutPayment(new DoExpressCheckoutPaymentReq
                    {
                        DoExpressCheckoutPaymentRequest = paymentRequest
                    });
                    if (doECResponse == null)
                    {
                        throw new System.Exception("payment result is null");
                    }
                    if (doECResponse.Errors != null && doECResponse.Errors.Count > 0)
                    {
                        doECResponse.Errors.ForEach(delegate (ErrorType m)
                        {
                            context.Errors.Add(m.LongMessage);
                        });
                    }
                    if (doECResponse.Ack == AckCodeType.SUCCESS || doECResponse.Ack == AckCodeType.SUCCESSWITHWARNING)
                    {
                        ConfirmInvoiceResult invoiceResult = BookingProvider.ConfirmInvoice(details.InvoiceID.Trim());
                        Tracing.DataTrace.TraceEvent(TraceEventType.Information, 0, "PAYPAL transaction: invoice: '{0}', invoice confirmation: '{1}'", new object[]
                        {
                            details.InvoiceID,
                            invoiceResult.IsSuccess ? "SUCCESS" : "FAILED"
                        });
                        if (!invoiceResult.IsSuccess)
                        {
                            context.Errors.Add(string.Format("invoice confirmation error: {0}", invoiceResult.ErrorMessage));
                        }
                        else
                        {
                            context.Success = true;

                            BookingProvider.AcceptInvoice(Convert.ToInt32(context.Order));
                        }
                    }
                }
            }
            else
            {
                context.Errors.Add(PaymentStrings.PaymentCancelled);
            }
            return base.View("_ProcessingResult", context);
        }
        public ActionResult ProcessingResult(ProcessingResultModel model)
        {
            string text = (Request["acc"] ?? "").ToLowerInvariant();

            if (text != null)
            {
                switch (text)
                {
                    case "jcc":

                        return this.ProcessingResult_JCC(model);

                    default:
                        break;
                }
            }
            throw new Exception(string.Format("unsupported processing system '{0}'", text));
        }