コード例 #1
0
        private SingleResponse <long> ApproveAttachedCardOrder(AttachCardPaymentApprovalRequest request)
        {
            SingleResponse <long> response = new SingleResponse <long>()
            {
                ResultCode = ResultCodes.normal
            };

            XBS.ActionResult result = new XBS.ActionResult();
            switch (request.Type)
            {
            case OrderType.RATransfer:
            {
                if (request.SubType == 3)
                {
                    PaymentOrder order = _xBService.GetPaymentOrder(request.Id);
                    result = _xBService.ApprovePaymentOrder(order);
                }
                //else if (request.SubType == 6)
                //{
                //    BudgetPaymentOrder order = _xBService.GetBudgetPaymentOrder(request.Id);
                //    result = _xBService.ApprovePaymentOrder(order);
                //}
            }
            break;

            case OrderType.LoanMature:
            {
                MatureOrder order = _xBService.GetMatureOrder(request.Id);
                result = _xBService.ApproveMatureOrder(order);
            }
            break;

            case OrderType.CommunalPayment:
            {
                UtilityPaymentOrder order = _xBService.GetUtilityPaymentOrder(request.Id);
                result = _xBService.ApproveUtilityPaymentOrder(order);
            }
            break;

            default:
                break;
            }
            response.Result      = result.Id;
            response.ResultCode  = ResultCodeFormatter.FromPersonalAccountSecurityService(result.ResultCode);
            response.Description = Utils.GetActionResultErrors(result.Errors);
            return(response);
        }
コード例 #2
0
        public async Task <IActionResult> SaveAndApproveWithAttachedCard([FromBody] AttachCardBindingRequest request)
        {
            if (ModelState.IsValid)
            {
                if (request?.Order == null)
                {
                    return(ResponseExtensions.ToHttpResponse(new Response
                    {
                        ResultCode = ResultCodes.failed,
                        Description = "Տեղի ունեցավ սխալ:"
                    }));
                }
                var orderResult = SaveAttachedCardOrder(request);
                if (orderResult.ResultCode == ResultCodes.normal && orderResult.Result != 0)
                {
                    var authorizedCustomer = _cacheHelper.GetAuthorizedCustomer();
                    var language           = _cacheHelper.GetLanguage();
                    var source             = _cacheHelper.GetSourceType();
                    var response           = await _client.ArcaOrderBindingPaymentAsync(new CardBindingPaymentRequest
                    {
                        BindingId      = request.Order.BindingId,
                        Amount         = request.Order.Amount,
                        Currency       = GetOrderTypeBasedCurrency(request),
                        OrderType      = XbsOrderEnumToProto(request.Order.Type),
                        OrderSubType   = request.Order.SubType,
                        CustomerNumber = authorizedCustomer.CustomerNumber,
                        UserId         = authorizedCustomer.UserId,
                        Language       = language == 1 ? "hy" : "en",
                        PageView       = source == SourceType.AcbaOnline ? "DESKTOP" : "MOBILE"
                    });

                    if (response.Payed)
                    {
                        var saveResponse = await _client.SaveAttachedCardOrderDetailsAsync(new OrderDetailsRequest
                        {
                            DocID   = orderResult.Result,
                            CardId  = response.CardId,
                            MdOrder = response.MdOrder
                        });

                        if (saveResponse.Saved)
                        {
                            var approvalRequest = new AttachCardPaymentApprovalRequest
                            {
                                Id      = orderResult.Result,
                                SubType = request.Order.SubType,
                                Type    = request.Order.Type
                            };
                            var approveResult = ApproveAttachedCardOrder(approvalRequest);
                            if (approveResult.ResultCode == ResultCodes.normal)
                            {
                                return(ResponseExtensions.ToHttpResponse(new Response
                                {
                                    ResultCode = ResultCodes.normal,
                                    Description = "Վճարումը կատարված է:"
                                }));
                            }
                            else
                            {
                                return(ResponseExtensions.ToHttpResponse(new Response
                                {
                                    ResultCode = ResultCodes.failed,
                                    Description = "Վճարման հաստատման ժամանակ տեղի ունեցավ սխալ, խնդրում ենք դիմել բանկ:"
                                }));
                            }
                        }
                        else
                        {
                            return(ResponseExtensions.ToHttpResponse(new Response
                            {
                                ResultCode = ResultCodes.failed,
                                Description = "Հայտի մանրամասների պահպանման տեղի ունեցավ սխալ:"
                            }));
                        }
                    }
                    else
                    {
                        // Quality desclined
                        return(ResponseExtensions.ToHttpResponse(new Response
                        {
                            ResultCode = ResultCodes.failed,
                            Description = "Վճարման ժամանակ տեղի ունեցավ սխալ:"
                        }));
                    }
                }
                else
                {
                    // Quality desclined
                    return(ResponseExtensions.ToHttpResponse(new Response
                    {
                        ResultCode = ResultCodes.failed,
                        Description = "Տեղի ունեցավ սխալ:"
                    }));
                }
            }
            else
            {
                return(ValidationError.GetValidationErrorResponse(ModelState));
            }
        }