public async Task <BancardChargeResponse?> Charge(BancardChargeRequest request, CancellationToken cancellationToken = default) { var model = new RequestApiModel <ChargeOperationApiModel> { PublicKey = _configuration.PublicKey, Operation = new ChargeOperationApiModel { Token = HashHelper.Charge(_configuration.PrivateKey, request.ShopProcessId, request.Amount, request.Currency.Value, request.AliasToken), Amount = request.Amount.ToString("F2"), Currency = request.Currency.Value, Description = request.Description, AdditionalData = request.AdditionalData, AliasToken = request.AliasToken, NumberOfPayments = request.NumberOfPayments, ShopProcessId = request.ShopProcessId } }; var response = await _httpClient.Charge(model, cancellationToken); if (!response.IsSuccessStatusCode) { var stuff = MapResponse(await response.Content.ReadAsAsync <ResponseApiModel>(cancellationToken), response.IsSuccessStatusCode); return(new BancardChargeResponse { IsSuccessful = response.IsSuccessStatusCode, BancardResponse = stuff }); } var responseBody = await response.Content.ReadAsAsync <ChargeResponseApiModel>(cancellationToken); var chargeResponse = new BancardChargeResponse { IsSuccessful = true, Amount = responseBody.Confirmation.Amount, Currency = responseBody.Confirmation.Currency, Response = responseBody.Confirmation.Response, Token = responseBody.Confirmation.Token, AuthorizationNumber = responseBody.Confirmation.AuthorizationNumber, ResponseCode = responseBody.Confirmation.ResponseCode, ResponseDescription = responseBody.Confirmation.ResponseDescription, ResponseDetails = responseBody.Confirmation.ResponseDetails, SecurityInformation = new BancardSecurityInformation { Version = responseBody.Confirmation.SecurityInformation.Version, CardCountry = responseBody.Confirmation.SecurityInformation.CardCountry, CardSource = responseBody.Confirmation.SecurityInformation.CardSource, CustomerIp = responseBody.Confirmation.SecurityInformation.CustomerIp, RiskIndex = responseBody.Confirmation.SecurityInformation.RiskIndex, }, TicketNumber = responseBody.Confirmation.TicketNumber, ExtendedResponseDescription = responseBody.Confirmation.ExtendedResponseDescription, ShopProcessId = responseBody.Confirmation.ShopProcessId }; return(chargeResponse); }
public async Task <ActionResult <BancardResponse> > Charge(CancellationToken cancellationToken) { var request = new BancardChargeRequest { Amount = 100000, Currency = BancardCurrency.Guarani, Description = "Prueba de cobro con token", AdditionalData = "", AliasToken = "226ad43de1e686ae554f886308b949bba9ac798a7d7da48f1548ccc9050f101f", NumberOfPayments = 1, ShopProcessId = 52 }; var response = await _vPosService.Charge(request, cancellationToken); return(Ok(response)); }