public ActionResult <RedsysRequest> Get(string orderNumber, [FromServices] Secret secret) { PaymentRequestService paymentRequestService = new PaymentRequestService(); PaymentRequest paymentRequest = new PaymentRequest( Ds_Merchant_ConsumerLanguage: Language.Spanish, Ds_Merchant_MerchantCode: "335088258", Ds_Merchant_Terminal: "1", Ds_Merchant_TransactionType: TransactionType.Authorisation, Ds_Merchant_Amount: 123, Ds_Merchant_Currency: Currency.EUR, Ds_Merchant_Order: orderNumber, Ds_Merchant_MerchantURL: Url.Action("Index", "Response", null, Request.Scheme), Ds_Merchant_UrlOK: $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/Ok", Ds_Merchant_UrlKO: $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/Ko") { Ds_Merchant_Paymethods = PaymentMethod.CreditCard }; PaymentFormData formData = paymentRequestService.GetPaymentRequestFormData( paymentRequest: paymentRequest, merchantKey: secret.Key); RedsysRequest redsysRequest = new RedsysRequest { ConnectionUrl = secret.Url, Request = formData }; return(Ok(redsysRequest)); }
// GET: Request public ActionResult Index(string merchantCode, string merchantOrder, decimal amount) { var paymentRequestService = new PaymentRequestService(); var paymentRequest = new PaymentRequest( Ds_Merchant_ConsumerLanguage: Language.Spanish, Ds_Merchant_MerchantCode: merchantCode, Ds_Merchant_Terminal: "1", Ds_Merchant_TransactionType: TransactionType.Authorization, Ds_Merchant_Amount: amount, Ds_Merchant_Currency: Currency.EUR, Ds_Merchant_Order: merchantOrder, Ds_Merchant_MerchantURL: Url.Action("Index", "Response", null, Request.Scheme), Ds_Merchant_UrlOK: Url.Action("OK", "Result", null, Request.Scheme), Ds_Merchant_UrlKO: Url.Action("KO", "Result", null, Request.Scheme) ); paymentRequest.Ds_Merchant_Paymethods = PaymentMethod.CreditCard; paymentRequest.Ds_Merchant_Titular = "TITULAR"; paymentRequest.Ds_Merchant_MerchantName = "MY COMMERCE"; paymentRequest.Ds_Merchant_ProductDescription = "PRODUCT DESCRIPTION"; paymentRequest.Ds_Merchant_Identifier = "REQUIRED"; var secrets = _configuration.GetSection("Secrets"); var formData = paymentRequestService.GetPaymentRequestFormData( paymentRequest: paymentRequest, merchantKey: secrets["key"]); ViewBag.ConnectionURL = secrets["url"]; return(View(formData)); }
// GET: Request public ActionResult Index(string merchantCode, string merchantOrder, string amount) { var paymentRequestService = new PaymentRequestService(); var paymentRequest = new PaymentRequest( Ds_Merchant_ConsumerLanguage: Language.Spanish, Ds_Merchant_MerchantCode: merchantCode, Ds_Merchant_Terminal: "1", Ds_Merchant_TransactionType: "0", Ds_Merchant_Amount: amount, Ds_Merchant_Currency: "978", Ds_Merchant_Order: merchantOrder, Ds_Merchant_MerchantURL: Url.Action("Index", "Response", null, Request.Url.Scheme), Ds_Merchant_UrlOK: Url.Action("OK", "Result", null, Request.Url.Scheme), Ds_Merchant_UrlKO: Url.Action("KO", "Result", null, Request.Url.Scheme)); paymentRequest.Ds_Merchant_PayMethod = PaymentMethod.CreditCard; var formData = paymentRequestService.GetPaymentRequestFormData( paymentRequest: paymentRequest, merchantKey: ConfigurationManager.AppSettings["MerchantKey"]); ViewBag.ConnectionURL = ConfigurationManager.AppSettings["TPVConnectionURL"]; return(View(formData)); }
public APIController(MerchantConfig merchantConfig) { _logger = LogManager.GetCurrentClassLogger(); Enumerations.ValidateRequestType(merchantConfig.RequestType); Enumerations.SetRequestType(merchantConfig); _paymentRequestService = new PaymentRequestService(merchantConfig); }
public UIPaymentRequestController( UIInvoiceController invoiceController, UserManager <ApplicationUser> userManager, PaymentRequestRepository paymentRequestRepository, PaymentRequestService paymentRequestService, EventAggregator eventAggregator, CurrencyNameTable currencies, InvoiceRepository invoiceRepository, LinkGenerator linkGenerator) { _InvoiceController = invoiceController; _UserManager = userManager; _PaymentRequestRepository = paymentRequestRepository; _PaymentRequestService = paymentRequestService; _EventAggregator = eventAggregator; _Currencies = currencies; _InvoiceRepository = invoiceRepository; _linkGenerator = linkGenerator; }
public PaymentRequestController( InvoiceController invoiceController, UserManager <ApplicationUser> userManager, StoreRepository storeRepository, PaymentRequestRepository paymentRequestRepository, PaymentRequestService paymentRequestService, EventAggregator eventAggregator, CurrencyNameTable currencies, InvoiceRepository invoiceRepository) { _InvoiceController = invoiceController; _UserManager = userManager; _StoreRepository = storeRepository; _PaymentRequestRepository = paymentRequestRepository; _PaymentRequestService = paymentRequestService; _EventAggregator = eventAggregator; _Currencies = currencies; _InvoiceRepository = invoiceRepository; }
public void GetPaymentRequestFormData_ShouldWork() { string merchantKey = "Mk9m98IfEblmPfrpsawt7BmxObt98Jev"; PaymentRequest paymentRequest = new PaymentRequest( "999008881", "871", "0", "145", "978", "19990000000A", "", "", "" ); IPaymentRequestService paymentRequestService = new PaymentRequestService(); var result = paymentRequestService.GetPaymentRequestFormData(paymentRequest, merchantKey); Assert.IsTrue(result.Ds_SignatureVersion == "HMAC_SHA256_V1"); Assert.IsTrue(result.Ds_MerchantParameters == "eyJEc19NZXJjaGFudF9BbW91bnQiOiIxNDUiLCJEc19NZXJjaGFudF9PcmRlciI6IjE5OTkwMDAwMDAwQSIsIkRzX01lcmNoYW50X01lcmNoYW50Q29kZSI6Ijk5OTAwODg4MSIsIkRzX01lcmNoYW50X0N1cnJlbmN5IjoiOTc4IiwiRHNfTWVyY2hhbnRfVHJhbnNhY3Rpb25UeXBlIjoiMCIsIkRzX01lcmNoYW50X1Rlcm1pbmFsIjoiODcxIiwiRHNfTWVyY2hhbnRfTWVyY2hhbnRVUkwiOiIiLCJEc19NZXJjaGFudF9VcmxPSyI6IiIsIkRzX01lcmNoYW50X1VybEtPIjoiIn0="); Assert.IsTrue(result.Ds_Signature == "MAlGASPeuqCw4K4ZMNIR343ljOoEAmH7B5woby1kcbs="); }
public void GetPaymentRequestFormData_ShouldWork() { string merchantKey = "Mk9m98IfEblmPfrpsawt7BmxObt98Jev"; PaymentRequest paymentRequest = new PaymentRequest( "999008881", "871", Enums.TransactionType.Authorisation, 1.45M, Currency.EUR, "19990000000A", "", "", "", Language.Spanish ); IPaymentRequestService paymentRequestService = new PaymentRequestService(); var result = paymentRequestService.GetPaymentRequestFormData(paymentRequest, merchantKey); Assert.IsTrue(result.Ds_SignatureVersion == "HMAC_SHA256_V1"); Assert.IsTrue(result.Ds_MerchantParameters == "ew0KICAiRHNfTWVyY2hhbnRfQW1vdW50IjogIjE0NSIsDQogICJEc19NZXJjaGFudF9Db25zdW1lckxhbmd1YWdlIjogIjAwMSIsDQogICJEc19NZXJjaGFudF9DdXJyZW5jeSI6ICI5NzgiLA0KICAiRHNfTWVyY2hhbnRfTWVyY2hhbnRDb2RlIjogIjk5OTAwODg4MSIsDQogICJEc19NZXJjaGFudF9NZXJjaGFudFVSTCI6ICIiLA0KICAiRHNfTWVyY2hhbnRfT3JkZXIiOiAiMTk5OTAwMDAwMDBBIiwNCiAgIkRzX01lcmNoYW50X1BheW1ldGhvZHMiOiAiQyIsDQogICJEc19NZXJjaGFudF9UZXJtaW5hbCI6ICI4NzEiLA0KICAiRHNfTWVyY2hhbnRfVHJhbnNhY3Rpb25UeXBlIjogIjAiLA0KICAiRHNfTWVyY2hhbnRfVXJsT0siOiAiIiwNCiAgIkRzX01lcmNoYW50X1VybEtPIjogIiINCn0="); Assert.IsTrue(result.Ds_Signature == "RIOJqg6hoE0SodvQqYSoGkHIa98Nkxep1xcRyBRhvSI="); }
public void GetPaymentRequestFormData_ShouldWork() { string merchantKey = "Mk9m98IfEblmPfrpsawt7BmxObt98Jev"; PaymentRequest paymentRequest = new PaymentRequest( "", "999008881", "871", "0", "145", "978", "19990000000A", "", "", Language.Spanish ); IPaymentRequestService paymentRequestService = new PaymentRequestService(); var result = paymentRequestService.GetPaymentRequestFormData(paymentRequest, merchantKey); Assert.IsTrue(result.Ds_SignatureVersion == "HMAC_SHA256_V1"); Assert.IsTrue(result.Ds_MerchantParameters == "eyJEc19NZXJjaGFudF9Db25zdW1lckxhbmd1YWdlIjoiMDAxIiwiRHNfTWVyY2hhbnRfQW1vdW50IjoiMCIsIkRzX01lcmNoYW50X09yZGVyIjoiOTc4IiwiRHNfTWVyY2hhbnRfTWVyY2hhbnRDb2RlIjoiIiwiRHNfTWVyY2hhbnRfQ3VycmVuY3kiOiIxNDUiLCJEc19NZXJjaGFudF9UcmFuc2FjdGlvblR5cGUiOiI4NzEiLCJEc19NZXJjaGFudF9UZXJtaW5hbCI6Ijk5OTAwODg4MSIsIkRzX01lcmNoYW50X01lcmNoYW50VVJMIjoiMTk5OTAwMDAwMDBBIiwiRHNfTWVyY2hhbnRfVXJsT0siOiIiLCJEc19NZXJjaGFudF9VcmxLTyI6IiIsIkRzX01lcmNoYW50X1BheU1ldGhvZCI6IkMifQ=="); Assert.IsTrue(result.Ds_Signature == "n4wE9ctvMwysrh517aDTrhQiNlt0XSXyQPQpSpJmeN8="); }
// GET: Request public ActionResult Index(string merchantCode, string merchantOrder, string amount) { var paymentRequestService = new PaymentRequestService(); var paymentRequest = new PaymentRequest( Ds_Merchant_MerchantCode: merchantCode, Ds_Merchant_Terminal: "1", Ds_Merchant_TransactionType: "0", Ds_Merchant_Amount: amount, Ds_Merchant_Currency: "978", Ds_Merchant_Order: merchantOrder, Ds_Merchant_MerchantURL: Url.Action("Index","Response", null, Request.Url.Scheme), Ds_Merchant_UrlOK: Url.Action("OK", "Result", null, Request.Url.Scheme), Ds_Merchant_UrlKO: Url.Action("KO", "Result", null, Request.Url.Scheme)); var formData = paymentRequestService.GetPaymentRequestFormData( paymentRequest: paymentRequest, merchantKey: ConfigurationManager.AppSettings["MerchantKey"]); ViewBag.ConnectionURL = ConfigurationManager.AppSettings["TPVConnectionURL"]; return View(formData); }
public void Setup() { _paymentRequestRepository = new Mock <IPaymentRequestRepository>(); _target = new PaymentRequestService(_paymentRequestRepository.Object); }