private object SetJsonForBraspag(PaymentMOD payment) { return(new { MerchantOrderId = payment.Customer.Id, Customer = new { Name = payment.Customer.Name }, Payment = new { Capture = true, Type = payment.Type, Amount = payment.Amount, Provider = payment.Provider, Installments = payment.Installments, CreditCard = new { CardNumber = payment.Card.Number, Holder = payment.Card.Name, ExpirationDate = payment.Card.Expiration, SecurityCode = payment.Card.Code, Brand = payment.Card.Flag } } }); }
public async Task <ResponseMOD> PayWithBraspagAsync(PaymentMOD payment) { using (HttpClient httpClient = new HttpClient()) { SetAuthForBraspag(httpClient); return(await SendPaymentToBraspagAsync(httpClient, payment)); } }
public async Task<ResponseMOD> PayWithBraspagAsync(PaymentMOD payment) { using (HttpClient httpClient = new HttpClient()) { SetAuthForBraspag(httpClient); return await SendPaymentToBraspagAsync(httpClient, payment); } }
private async Task<ResponseMOD> SendPaymentToBraspagAsync(HttpClient httpClient, PaymentMOD payment) { try { HttpResponseMessage httpResponseMessage = await httpClient.PostAsJsonAsync(UtilityMOD.API_BRASPAG_URL, SetJsonForBraspag(payment)); ResponseMOD response = await ValidateResponseFromBraspagAsync(httpResponseMessage); return response; } catch (Exception exception) { return SetCurrentException(exception); } }
private async Task <ResponseMOD> SendPaymentToBraspagAsync(HttpClient httpClient, PaymentMOD payment) { try { HttpResponseMessage httpResponseMessage = await httpClient.PostAsJsonAsync(UtilityMOD.API_BRASPAG_URL, SetJsonForBraspag(payment)); ResponseMOD response = await ValidateResponseFromBraspagAsync(httpResponseMessage); return(response); } catch (Exception exception) { return(SetCurrentException(exception)); } }
private object SetJsonForBraspag(PaymentMOD payment) { return new { MerchantOrderId = payment.Customer.Id, Customer = new { Name = payment.Customer.Name }, Payment = new { Capture = true, Type = payment.Type, Amount = payment.Amount, Provider = payment.Provider, Installments = payment.Installments, CreditCard = new { CardNumber = payment.Card.Number, Holder = payment.Card.Name, ExpirationDate = payment.Card.Expiration, SecurityCode = payment.Card.Code, Brand = payment.Card.Flag } } }; }