public Response <PaymentResponse, SecureMessage> Send(PaymentCommitRequest paymentRequest) { RestRequest restsharpRequest; RestClient restClient; PrepareRestClient(paymentRequest, out restsharpRequest, out restClient); IRestResponse response = restClient.Execute(restsharpRequest); return(HandleResponse <PaymentResponse, SecureMessage>(response, () => response.Content.Contains("<secure-message"))); }
private void PrepareRestClient(PaymentCommitRequest paymentRequest, out RestRequest restsharpRequest, out RestClient restClient) { restsharpRequest = new RestRequest { Method = Method.POST, Resource = "/api", XmlSerializer = new RestSharp.Serializers.DotNetXmlSerializer(), RequestFormat = DataFormat.Xml }; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11; restsharpRequest.AddBody(paymentRequest.Transaction); restClient = new RestClient(rootUrl); }
public Task <Response <PaymentResponse, SecureMessage> > SendAsync(PaymentCommitRequest paymentRequest) { RestRequest restsharpRequest; RestClient restClient; var taskCompletionSource = new TaskCompletionSource <Response <PaymentResponse, SecureMessage> >(); PrepareRestClient(paymentRequest, out restsharpRequest, out restClient); restClient.ExecuteAsync(restsharpRequest, (r) => taskCompletionSource.SetResult(HandleResponse <PaymentResponse, SecureMessage>(r, () => r.Content.Contains("<secure-message"))) ); return(taskCompletionSource.Task); }
public PaymentCommitRequest Build(Buyer buyer, Order order, Card card, WebPayIntegration integration, TransactionType trancationType, Language language) { Request.PaymentCommitRequest paymentRequest = new PaymentCommitRequest(); var transaction = new Transaction(); //buyer transaction.FullName = buyer.FullName; transaction.Address = buyer.Address; transaction.City = buyer.City; transaction.Country = buyer.Country; transaction.Email = buyer.Email; transaction.ZIP = buyer.ZIP; transaction.Phone = buyer.Phone; //card transaction.Pan = card.Pan; transaction.CVV = card.CVV; transaction.ExpirationDate = card.ExpirationDate; //order transaction.Amount = order.Amount; transaction.OrderNumber = order.OrderNumber; transaction.OrderInfo = order.OrderInfo; transaction.Currency = order.Currency; //processing data transaction.Ip = NetworkHelper.GetIPAddress(); transaction.Language = language; transaction.TransactionType = trancationType; transaction.AuthenticityToken = integration.ConfigurationSettings.AuthenticityToken; transaction.Digest = CreateDigest(integration.ConfigurationSettings.Key, order.OrderNumber, order.Amount, order.Currency); transaction.NumberOfInstallments = 2; transaction.Moto = false; paymentRequest.Transaction = transaction; return(paymentRequest); //} //else //{ // return null;//privremeno //} }
protected Task <TransactionResult> DoTransactionAsync(PaymentCommitRequest paymentRequest, Language language, IPaymentCommitClient paymentClient) { return(DoTransactionInternal(() => paymentClient.SendAsync(paymentRequest), paymentRequest, language, new PaymentCommitRequestValidator())); }
protected TransactionResult DoTransaction(PaymentCommitRequest paymentRequest, Language language, IPaymentCommitClient paymentClient) { return(DoTransactionInternal(() => Task.FromResult(paymentClient.Send(paymentRequest)), paymentRequest, language, new PaymentCommitRequestValidator()).Result); }