Exemple #1
0
        public async Task <IActionResult> withdraw([FromBody] WithdrawCommand command)
        {
            var response = new DepositResponse();

            try
            {
                if (command.Amount < 50000 || command.Amount % 50000 != 0)
                {
                    response.Code    = ErrorCode.GetError(ErrorCode.AmountInvalid).Key;
                    response.Message = ErrorCode.GetError(ErrorCode.AmountInvalid).Value;
                    return(Ok(response));
                }

                var walletType      = _context.WalletType.Where(s => s.WalletTypeName == WalletTypeEnum.CHECKING.ToString()).FirstOrDefault();
                var transactionType = _context.TransactionType.Where(s => s.TransactionTypeName == TransactionTypeEnum.WITHDRAW.ToString()).FirstOrDefault();
                command.Fee = transactionType.Fee;
                command.TransactionTypeId = transactionType.TransactionTypeId;
                command.WalletTypeId      = walletType.WalletTypeId;
                response = await _mediator.Send(command);
            }
            catch (Exception ex)
            {
                response.Code    = ErrorCode.GetError(ErrorCode.SystemError).Key;
                response.Message = ErrorCode.GetError(ErrorCode.SystemError).Value;
                Logger.Error($"Exception: {ex} , Method:withdraw");
            }

            return(Ok(response));
        }
Exemple #2
0
    public static void DepositUserFunds(DepositPayload payload, ResponseCallback callback, ResponseFallback fallback)
    {
        HttpClient httpClient = new HttpClient();

        Request request = new Request(HttpClient.Method.POST, Route.DEPOSIT_ROUTE, payload);

        httpClient.Request(
            request,
            (statusCode, response) => {
            DepositResponse depositResponse = Deserialize(response);
            callback(depositResponse);
        },
            (statusCode, error) => {
            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = ErrorDeserilizer.DeserializeValidationErrorData(error);
                fallback(statusCode, validationError);
            }
            else
            {
                GenericError genericError = ErrorDeserilizer.DeserializeGenericErrorData(error);
                fallback(statusCode, genericError);
            }
        }
            );
    }
 private void DepositRequestResp(DepositResponse response)
 {
     Log.Info("Deposit Request Response " + response.ResultStatus.ToString());
     if (response.ResultStatus == ResponseStatus.Success)
         SDTMessages.Instance.ProcessAFTInformation(response.ReturnValue, MonitorConstants.DEPOSITRESPONSE, response.RequestID, true);
     else
         SDTMessages.Instance.ProcessAFTInformation(response.ReturnValue, MonitorConstants.DEPOSITRESPONSE, response.RequestID, false);
 }
Exemple #4
0
 private void DepositRequestResp(DepositResponse response)
 {
     Log.Info("Deposit Request Response " + response.ResultStatus.ToString());
     if (response.ResultStatus == ResponseStatus.Success)
     {
         SDTMessages.Instance.ProcessAFTInformation(response.ReturnValue, MonitorConstants.DEPOSITRESPONSE, response.RequestID, true);
     }
     else
     {
         SDTMessages.Instance.ProcessAFTInformation(response.ReturnValue, MonitorConstants.DEPOSITRESPONSE, response.RequestID, false);
     }
 }
Exemple #5
0
    private static DepositResponse Deserialize(object response)
    {
        var responseJson = (string)response;

        var data = fsJsonParser.Parse(responseJson);

        object deserialized = null;

        serializer.TryDeserialize(data, typeof(DepositResponse), ref deserialized);

        DepositResponse serializedData = deserialized as DepositResponse;

        return(serializedData);
    }
Exemple #6
0
        public Deposit CreateFromResponse(DepositResponse depositResponse)
        {
            var result = new Deposit
            {
                Id       = depositResponse.Id,
                CreateAt = depositResponse.CreateAt,
                Name     = depositResponse.Name,
                Amount   = depositResponse.Amount,
                Category = new Category(),
                Contacts = new List <Contact>()
            };

            return(result);
        }
    public void InitiateDeposit()
    {
        string[] fields = { amount.text };

        Validate.CheckEmptyFields(fields,
                                  (message) => { menuManager.StartCoroutine(menuManager.showPopUpT(message, "error")); },
                                  () =>
        {
            SetLoading(deposit_loading, deposit_form, deposit_back_button, true);
            float_amount = float.Parse(amount.text);

            DepositFunds.DepositUserFunds(
                new DepositPayload(float_amount),
                (response) => {
                DepositResponse depositResponse = (DepositResponse)response;
                Application.OpenURL(depositResponse.url);

                SetLoading(deposit_loading, deposit_form, deposit_back_button, false);
                ResetDeposit();

                DepositPanel.SetActive(false);
                LogoPanel.SetActive(true);
            },
                (statusCode, error) => {
                SetLoading(deposit_loading, deposit_form, deposit_back_button, false);
                if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
                {
                    ValidationError validationError = (ValidationError)error;
                    menuManager.StartCoroutine(menuManager.showPopUpT(validationError.errors.First().Value[0], "error"));
                }
                else
                {
                    GenericError genericError = (GenericError)error;
                    menuManager.StartCoroutine(menuManager.showPopUpT(genericError.message, "error"));
                }
            }
                );
        });
    }
        public async Task <IActionResult> Deposit([FromBody] DepositRequest request)
        {
            int             statusCode = 200;
            DepositResponse result     = null;
            string          error      = null;

            try
            {
                result = await _actionService.Deposit(request.IBAN, request.DepositMoney, request.Remark);
            }
            catch (ArgumentException e)
            {
                Log.Error($"Failed to deposit", e);
                statusCode = 400;
                error      = e.Message;
            }
            catch (Exception e)
            {
                Log.Error($"Failed to deposit", e);
                statusCode = 500;
                error      = e.Message;
            }
            return(CreateResponse(statusCode, result, error));
        }
        public async Task <IActionResult> PostPaywaloAsync(TopupReq value)
        {
            var user = _user.getUser(User.Claims.FirstOrDefault().Value);

            if (user == null)
            {
                return(BadRequest(new { status = "FAILURE", desc = "Not found user from token!" }));
            }

            string address = HttpContext.Connection.RemoteIpAddress.ToString();

            if (_inv.getExistOrder(value.OrderNumber, user.CompCode))
            {
                return(BadRequest(new { status = "FAILURE", desc = "This order number has been used!" }));
            }

            /*ICollection<IFormFile> uploadFile*/
            if (!ModelState.IsValid)
            {
                return(BadRequest("Valid parameter!"));
            }

            if (value.ImageSlip == null && string.IsNullOrEmpty(value.ImageSlipBase64))
            {
                return(BadRequest(new { status = "FAILURE", desc = "Image not found!" }));
            }

            SaveImgResponse saveImg = new SaveImgResponse();

            if (value.ImageSlip != null)
            {
                saveImg = _paywalo.SaveSlipAsync(value.ImageSlip).Result;
            }
            else if (!string.IsNullOrEmpty(value.ImageSlipBase64))
            {
                saveImg = _paywalo.SaveSlip64Async(value.ImageSlipBase64);
            }

            if (saveImg == null || string.IsNullOrEmpty(saveImg.result) || saveImg.success == false)
            {
                return(BadRequest(new { status = "FAILURE", desc = saveImg.result }));
            }

            ///////  create invoice ////////
            var invoice = new Invoice
            {
                //MethodId = Constant.PayWalo.paywaloMethod,
                //TranstypeId = Constant.PayWalo.deposit,
                MethodId     = _constant.BankTransfer,
                TranstypeId  = _constant.Deposit,
                MemberId     = value.member_id,
                CompCode     = user.CompCode,
                OrderNumber  = value.OrderNumber,
                OrderDate    = DateTime.Now,
                CreateDate   = DateTime.Now,
                ModifiedDate = DateTime.Now,
                Amount       = value.Amount,
                Fee          = 0,
                CurrencyCode = "THB",
                ExternalId   = value.test == true ? "TEST-" + Guid.NewGuid().ToString().Substring(0, 30) : Guid.NewGuid().ToString(),
                ImageSlip    = saveImg.result,
                CallbackUrl  = value.CallbackUrl,
                Status       = "pen"
            };

            var newInvoice = _inv.CreateDeposit(invoice);

            if (newInvoice == null)
            {
                return(BadRequest("Cannot create invoice!"));
            }

            var p = new DepositRequestV3()

            {
                Amount              = Convert.ToDecimal(newInvoice.Amount),
                OrderDate           = DateTime.Now,
                OrderNumber         = newInvoice.ExternalId,
                BankAccountId       = value.BankAccountId,
                Currency            = "THB",
                DepositSlipImageURL = _constant.ImgSlipUrl + saveImg.result
            };

            DepositResponse response = await _paywalo.Deposit_v3(p, invoice);

            if (response.Data == null)
            {
                _inv.SetCancel(invoice.InvoiceId);
                var trans = _inv.getInvoiceById(newInvoice.InvoiceId);

                _log.save("Bank transfer deposit", "post api/deposit/paywalo", "Response data is null", address);
                return(BadRequest(new { status = "FAILURE", desc = "Error from paywalo!", transaction = trans }));
            }

            var transaction = _inv.getInvoiceById(newInvoice.InvoiceId);

            if (response.Data != null)
            {
                if (response.Status.Equals("SUCCESS"))
                {
                    _inv.Set_GTransID(newInvoice.InvoiceId, response.Data.TransactionNumber);
                    var jString = JsonConvert.SerializeObject(response.Messages);
                    _log.save("Bank transfer deposit", "post api/deposit/paywalo", jString, address);

                    if (response.Data.Status == 1)
                    {
                        _inv.SetSuccess(newInvoice.InvoiceId);
                        return(Ok(new { status = "SUCCESS", desc = "Transaction has been approved", transaction = transaction }));
                    }
                    else if (response.Data.Status == 0)
                    {
                        return(Ok(new { status = "PENDING", desc = "Transaction has been requested", transaction = transaction }));
                    }
                    else
                    {
                        _inv.SetCancel(newInvoice.InvoiceId);
                        return(BadRequest(new { status = "FAILURE", desc = response.Messages, transaction = transaction }));
                    }
                }
                else
                {
                    _inv.SetCancel(newInvoice.InvoiceId);
                    return(BadRequest(new { status = "FAILURE", desc = response.Messages, transaction = transaction }));
                }
            }
            var jsonString = JsonConvert.SerializeObject(response);

            _log.save("Bank transfer deposit", "post api/deposit/paywalo", jsonString, address);
            _inv.SetCancel(newInvoice.InvoiceId);
            return(BadRequest(new { status = "FAILURE", desc = response.Messages, transaction = transaction }));
        }