public PaymentFormData GetPaymentRequestFormData(PaymentRequest paymentRequest, string merchantKey)
        {
            PaymentFormData result = new PaymentFormData();

            result.Ds_SignatureVersion = "HMAC_SHA256_V1";
            result.Ds_MerchantParameters = merchantParamentersManager.GetMerchantParameters(paymentRequest);
            result.Ds_Signature = signatureManager.GetSignature(result.Ds_MerchantParameters, paymentRequest.Ds_Merchant_Order, merchantKey);

            return result;
        }
        public void GetMerchantParameters_ShouldWork_2()
        {
            PaymentRequest paymentRequest = new PaymentRequest(
                "999008881",
                "871",
                "0",
                "145",
                "978",
                "999911111111",
                "",
                "",
                ""
                );
            IMerchantParametersManager merchantParamentersManager = new MerchantParametersManager();
            var result = merchantParamentersManager.GetMerchantParameters(paymentRequest);

            Assert.IsTrue(result == "eyJEc19NZXJjaGFudF9BbW91bnQiOiIxNDUiLCJEc19NZXJjaGFudF9PcmRlciI6Ijk5OTkxMTExMTExMSIsIkRzX01lcmNoYW50X01lcmNoYW50Q29kZSI6Ijk5OTAwODg4MSIsIkRzX01lcmNoYW50X0N1cnJlbmN5IjoiOTc4IiwiRHNfTWVyY2hhbnRfVHJhbnNhY3Rpb25UeXBlIjoiMCIsIkRzX01lcmNoYW50X1Rlcm1pbmFsIjoiODcxIiwiRHNfTWVyY2hhbnRfTWVyY2hhbnRVUkwiOiIiLCJEc19NZXJjaGFudF9VcmxPSyI6IiIsIkRzX01lcmNoYW50X1VybEtPIjoiIn0=");
        }
        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=");
        }
        // 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 string GetMerchantParameters(PaymentRequest paymentRequest)
 {
     var json = JsonConvert.SerializeObject(paymentRequest);
     return Base64.EncodeTo64(json);
 }
Exemple #6
0
        public PaymentRequest Clone()
        {
            PaymentRequest temp = (PaymentRequest)this.MemberwiseClone();

            return(temp);
        }