Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. [HttpPost("submited")]
  2. public async Task<IActionResult> SubmitedPayment(PaymentDTO paymentDTO)
  3. {
  4. paymentDTO.Description = "Invoice Description";
  5. paymentDTO.VendorTxCode = Guid.NewGuid().ToString().ToUpper();
  6. paymentDTO.NotificationURL = $"{_configuration["AppUrl"]}/Payment/RedirectURL";
  7. paymentDTO.Vendor = _configuration["Vendor"];
  8. var client = new HttpClient();
  9. var data = PostData(paymentDTO);
  10. var result = await client.PostAsync(_configuration["SagePayUrl"], new FormUrlEncodedContent(data));
  11. var contentResponse = await result.Content.ReadAsStringAsync();
  12. if (contentResponse.Contains("Status=OK"))
  13. return Redirect(await SaveSuccessResponseData(paymentDTO, contentResponse));
  14. ViewBag.StatusDetail = contentResponse;
  15. return View("Error");
  16. }
  17. private Dictionary<string, string> PostData(PaymentDTO paymentDTO)
  18. {
  19. return new Dictionary<string, string>
  20. {
  21. { "VPSProtocol", "3.00" },
  22. { "TxType", "PAYMENT" },
  23. { "Vendor", _configuration["Vendor"] },
  24. { "Currency", paymentDTO.Currency },
  25. { "Amount", paymentDTO.Amount.ToString() },
  26. { "Description", paymentDTO.Description },
  27. { "VendorTxCode", paymentDTO.VendorTxCode },
  28. { "NotificationURL", paymentDTO.NotificationURL},
  29. { "BillingFirstnames", paymentDTO.BillingFirstnames },
  30. { "BillingSurname", paymentDTO.BillingSurname },
  31. { "BillingAddress1", paymentDTO.BillingAddress1 },
  32. { "BillingAddress2", paymentDTO.BillingAddress2 },
  33. { "BillingCity", paymentDTO.BillingCity },
  34. { "BillingPostCode", paymentDTO.BillingPostCode },
  35. { "BillingCountry", paymentDTO.BillingCountry },
  36. { "DeliveryFirstnames", paymentDTO.DeliveryFirstnames ?? paymentDTO.BillingFirstnames},
  37. { "DeliverySurname", paymentDTO.DeliverySurname ?? paymentDTO.BillingSurname},
  38. { "DeliveryAddress1", paymentDTO.DeliveryAddress1 ?? paymentDTO.BillingAddress1},
  39. { "DeliveryAddress2", paymentDTO.DeliveryAddress2 ?? paymentDTO.BillingAddress2},
  40. { "DeliveryCity", paymentDTO.DeliveryCity ?? paymentDTO.BillingCity},
  41. { "DeliveryPostCode", paymentDTO.DeliveryPostCode ?? paymentDTO.BillingPostCode},
  42. { "DeliveryCountry", paymentDTO.DeliveryCountry ?? paymentDTO.BillingCountry},
  43. { "BillingState", paymentDTO.BillingState },
  44. { "DeliveryState", paymentDTO.DeliveryState ?? paymentDTO.BillingState},
  45. { "CustomerEMail", paymentDTO.CustomerEMail}
  46. };
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement