Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost("submited")]
- public async Task<IActionResult> SubmitedPayment(PaymentDTO paymentDTO)
- {
- paymentDTO.Description = "Invoice Description";
- paymentDTO.VendorTxCode = Guid.NewGuid().ToString().ToUpper();
- paymentDTO.NotificationURL = $"{_configuration["AppUrl"]}/Payment/RedirectURL";
- paymentDTO.Vendor = _configuration["Vendor"];
- var client = new HttpClient();
- var data = PostData(paymentDTO);
- var result = await client.PostAsync(_configuration["SagePayUrl"], new FormUrlEncodedContent(data));
- var contentResponse = await result.Content.ReadAsStringAsync();
- if (contentResponse.Contains("Status=OK"))
- return Redirect(await SaveSuccessResponseData(paymentDTO, contentResponse));
- ViewBag.StatusDetail = contentResponse;
- return View("Error");
- }
- private Dictionary<string, string> PostData(PaymentDTO paymentDTO)
- {
- return new Dictionary<string, string>
- {
- { "VPSProtocol", "3.00" },
- { "TxType", "PAYMENT" },
- { "Vendor", _configuration["Vendor"] },
- { "Currency", paymentDTO.Currency },
- { "Amount", paymentDTO.Amount.ToString() },
- { "Description", paymentDTO.Description },
- { "VendorTxCode", paymentDTO.VendorTxCode },
- { "NotificationURL", paymentDTO.NotificationURL},
- { "BillingFirstnames", paymentDTO.BillingFirstnames },
- { "BillingSurname", paymentDTO.BillingSurname },
- { "BillingAddress1", paymentDTO.BillingAddress1 },
- { "BillingAddress2", paymentDTO.BillingAddress2 },
- { "BillingCity", paymentDTO.BillingCity },
- { "BillingPostCode", paymentDTO.BillingPostCode },
- { "BillingCountry", paymentDTO.BillingCountry },
- { "DeliveryFirstnames", paymentDTO.DeliveryFirstnames ?? paymentDTO.BillingFirstnames},
- { "DeliverySurname", paymentDTO.DeliverySurname ?? paymentDTO.BillingSurname},
- { "DeliveryAddress1", paymentDTO.DeliveryAddress1 ?? paymentDTO.BillingAddress1},
- { "DeliveryAddress2", paymentDTO.DeliveryAddress2 ?? paymentDTO.BillingAddress2},
- { "DeliveryCity", paymentDTO.DeliveryCity ?? paymentDTO.BillingCity},
- { "DeliveryPostCode", paymentDTO.DeliveryPostCode ?? paymentDTO.BillingPostCode},
- { "DeliveryCountry", paymentDTO.DeliveryCountry ?? paymentDTO.BillingCountry},
- { "BillingState", paymentDTO.BillingState },
- { "DeliveryState", paymentDTO.DeliveryState ?? paymentDTO.BillingState},
- { "CustomerEMail", paymentDTO.CustomerEMail}
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement