private PayfirmaCredentials PopulateMerchantCredentials()
 {
     var credentails = new PayfirmaCredentials()
     {
         APIKey = _payfirmaPaymentSettings.APIKey,
         MerchantID = _payfirmaPaymentSettings.MerchantId
     };
     return credentails;
 }
        protected PayfirmaTransactionResponse ProcessTransaction(String type, PayfirmaCredentials credentials, Double amount, String transactionId, Boolean isTest)
        {
            PayfirmaTransactionResponse payfirmaResponse = new PayfirmaTransactionResponse();
            var webClient = new WebClient();

            NameValueCollection requestData = new NameValueCollection();

            requestData.Add("key", credentials.APIKey);
            requestData.Add("merchant_id", credentials.MerchantID);
            requestData.Add("amount", amount.ToString());
            if (isTest)
            {
                requestData.Add("test_mode", "true");
            }

            if (type.ToLower() != "refund" && type.ToLower() != "capture")
            {
                payfirmaResponse.Error = "Payfirma Invalid Transaction Type : " + type;
                return(payfirmaResponse);
            }

            if (String.IsNullOrEmpty(transactionId))
            {
                payfirmaResponse.Error = "Payfirma Invalid Transaction ID";
                return(payfirmaResponse);
            }

            String url = this.GetPayfirmaURL() + "/" + type.ToLower() + "/" + transactionId;

            try
            {
                var webResponseByte = webClient.UploadValues(url, "POST", requestData);
                var webResponse     = Encoding.ASCII.GetString(webResponseByte);

                if (!String.IsNullOrEmpty(webResponse))
                {
                    payfirmaResponse = this.HandleTransacitonResponse(webResponse);
                }
                else
                {
                    payfirmaResponse.Error = "Payfirma unknown error";
                }
            }
            catch (Exception e)
            {
                payfirmaResponse.Error = "Payfirma Error: " + e.Message;
            }

            return(payfirmaResponse);
        }
        protected PayfirmaTransactionResponse ProcessTransaction(String type, PayfirmaCredentials credentials, PayfirmaCreditCard cc, PayfirmaMetaData metaData, Double amount, Boolean isTest)
        {
            PayfirmaTransactionResponse payfirmaResponse = new PayfirmaTransactionResponse();
            var webClient = new WebClient();

            NameValueCollection requestData = new NameValueCollection();

            this.GenerateMetaData(metaData, requestData);
            requestData.Add("key", credentials.APIKey);
            requestData.Add("merchant_id", credentials.MerchantID);
            requestData.Add("amount", amount.ToString());
            requestData.Add("card_number", cc.Number);
            requestData.Add("card_expiry_month", cc.ExpMonth.ToString());
            requestData.Add("card_expiry_year", cc.ExpYear.ToString());
            requestData.Add("cvv2", cc.CVV2);
            if (isTest)
            {
                requestData.Add("test_mode", "true");
            }

            requestData.Add("do_not_store", "true");

            if (type.ToLower() != "sale" && type.ToLower() != "authorize")
            {
                // Default to sale transaction type.
                type = "sale";
            }
            String url = this.GetPayfirmaURL() + "/" + type.ToLower();;

            try
            {
                var webResponseByte = webClient.UploadValues(url, "POST", requestData);
                var webResponse     = Encoding.ASCII.GetString(webResponseByte);

                if (!String.IsNullOrEmpty(webResponse))
                {
                    payfirmaResponse = this.HandleTransacitonResponse(webResponse);
                }
                else
                {
                    payfirmaResponse.Error = "Payfirma unknown error";
                }
            }
            catch (Exception e)
            {
                payfirmaResponse.Error = "Payfirma Error: " + e.Message;
            }

            return(payfirmaResponse);
        }
        protected PayfirmaTransactionResponse ProcessTransaction(String type, PayfirmaCredentials credentials, Double amount, String transactionId, Boolean isTest)
        {
            PayfirmaTransactionResponse payfirmaResponse = new PayfirmaTransactionResponse();
            var webClient = new WebClient();

            NameValueCollection requestData = new NameValueCollection();
            requestData.Add("key", credentials.APIKey);
            requestData.Add("merchant_id", credentials.MerchantID);
            requestData.Add("amount", amount.ToString());
            requestData.Add("test_mode", isTest.ToString().ToLower());
            requestData.Add("do_not_store", "true");

            if (type.ToLower() != "refund" && type.ToLower() != "capture")
            {
                payfirmaResponse.Error = "Payfirma Invalid Transaction Type : " + type;
                return payfirmaResponse;
            }

            if (String.IsNullOrEmpty(transactionId))
            {
                payfirmaResponse.Error = "Payfirma Invalid Transaction ID";
                return payfirmaResponse;
            }

            String url = this.GetPayfirmaURL() + "/" + type.ToLower() + "/" + transactionId;

            try
            {
                var webResponseByte = webClient.UploadValues(url, "POST", requestData);
                var webResponse = Encoding.ASCII.GetString(webResponseByte);

                if (!String.IsNullOrEmpty(webResponse))
                {
                    payfirmaResponse = this.HandleTransacitonResponse(webResponse);
                }
                else
                {
                    payfirmaResponse.Error = "Payfirma unknown error";
                }
            }
            catch (Exception e)
            {
                payfirmaResponse.Error = "Payfirma Error: " + e.Message;
            }

            return payfirmaResponse;
        }
        protected PayfirmaTransactionResponse ProcessTransaction(String type, PayfirmaCredentials credentials, PayfirmaCreditCard cc, PayfirmaMetaData metaData, Double amount, Boolean isTest)
        {
            PayfirmaTransactionResponse payfirmaResponse = new PayfirmaTransactionResponse();
            var webClient = new WebClient();

            NameValueCollection requestData = new NameValueCollection();
            this.GenerateMetaData(metaData, requestData);
            requestData.Add("key", credentials.APIKey);
            requestData.Add("merchant_id", credentials.MerchantID);
            requestData.Add("amount", amount.ToString());
            requestData.Add("card_number", cc.Number);
            requestData.Add("card_expiry_month", cc.ExpMonth.ToString());
            requestData.Add("card_expiry_year", cc.ExpYear.ToString());
            requestData.Add("cvv2", cc.CVV2);
            if (isTest) { requestData.Add("test_mode", "true"); }

            requestData.Add("do_not_store", "true");

            if (type.ToLower() != "sale" && type.ToLower() != "authorize")
            {
                // Default to sale transaction type.
                type = "sale";
            }
            String url = this.GetPayfirmaURL() + "/" + type.ToLower(); ;

            try
            {
                var webResponseByte = webClient.UploadValues(url, "POST", requestData);
                var webResponse = Encoding.ASCII.GetString(webResponseByte);

                if (!String.IsNullOrEmpty(webResponse))
                {
                    payfirmaResponse = this.HandleTransacitonResponse(webResponse);
                }
                else
                {
                    payfirmaResponse.Error = "Payfirma unknown error";
                }
            }
            catch (Exception e)
            {
                payfirmaResponse.Error = "Payfirma Error: " + e.Message;
            }

            return payfirmaResponse;
        }
Beispiel #6
0
 public PayfirmaTransactionResponse ProcessRefund(PayfirmaCredentials credentials, String transactionId, Double amount, Boolean isTest)
 {
     return(base.ProcessTransaction("refund", credentials, amount, transactionId, isTest));
 }
Beispiel #7
0
 public PayfirmaTransactionResponse ProcessAuthorize(PayfirmaCredentials credentials, PayfirmaCreditCard cc, PayfirmaMetaData metaData, Double amount, Boolean isTest)
 {
     return(base.ProcessTransaction("authorize", credentials, cc, metaData, amount, isTest));
 }
 public PayfirmaTransactionResponse ProcessRefund(PayfirmaCredentials credentials, String transactionId, Double amount, Boolean isTest)
 {
     return base.ProcessTransaction("refund", credentials, amount, transactionId, isTest);
 }
 public PayfirmaTransactionResponse ProcessAuthorize(PayfirmaCredentials credentials, PayfirmaCreditCard cc, PayfirmaMetaData metaData, Double amount, Boolean isTest)
 {
     return base.ProcessTransaction("authorize", credentials, cc, metaData, amount, isTest);
 }