private string BuildResponseDebug(CreditCardResponse response)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("\r\nParadata PayGateway.CreditCardResponse Object\r\n");
            sb.Append("AuthorizedAmount=" + response.getAuthorizedAmount() + "\r\n");
            sb.Append("AvsCode=" + response.getAvsCode() + "\r\n");
            sb.Append("BankApprovalCode=" + response.getBankApprovalCode() + "\r\n");
            sb.Append("BankTransactionId=" + response.getBankTransactionId() + "\r\n");
            sb.Append("BatchId=" + response.getBatchId() + "\r\n");
            sb.Append("CapturedAmount=" + response.getCapturedAmount() + "\r\n");
            sb.Append("CaptureReferenceId=" + response.getCaptureReferenceId() + "\r\n");
            sb.Append("CreditCardVerificationResponse=" + response.getCreditCardVerificationResponse() + "\r\n");
            sb.Append("CreditedAmount=" + response.getCreditedAmount() + "\r\n");
            sb.Append("OrderId=" + response.getOrderId() + "\r\n");
            sb.Append("OriginalAuthorizedAmount=" + response.getOriginalAuthorizedAmount() + "\r\n");
            sb.Append("PayerAuthenticationResponse=" + response.getPayerAuthenticationResponse() + "\r\n");
            sb.Append("ReferenceId=" + response.getReferenceId() + "\r\n");
            sb.Append("ResponseCode=" + response.getResponseCode() + "\r\n");
            sb.Append("ResponseCodeText=" + response.getResponseCodeText() + "\r\n");
            sb.Append("RetryRecommended=" + response.getRetryRecommended() + "\r\n");
            sb.Append("SecondaryResponseCode=" + response.getSecondaryResponseCode() + "\r\n");
            sb.Append("State=" + response.getState() + "\r\n");
            sb.Append("TimeStamp=" + response.getTimeStamp() + "\r\n");

            return(sb.ToString());
        }
        private Transaction ProcessResponse(Payment payment, CreditCardResponse response, TransactionType transactionType, LSDecimal transAmount)
        {
            //CREATE THE TRANSACTION OBJECT
            Transaction transaction = new Transaction();

            transaction.PaymentGatewayId = this.PaymentGatewayId;
            transaction.TransactionType  = transactionType;
            transaction.Amount           = transAmount;

            if (response.getResponseCode() != 1)
            {
                transaction.TransactionStatus = TransactionStatus.Failed;
                transaction.ResponseCode      = response.getResponseCode().ToString();
                transaction.ResponseMessage   = response.getResponseCodeText();
            }
            else
            {
                transaction.TransactionStatus     = TransactionStatus.Successful;
                transaction.ProviderTransactionId = response.getReferenceId(); // getBankTransactionId();
                transaction.TransactionDate       = response.getTimeStamp();   // DateTime.UtcNow;
                transaction.ResponseCode          = response.getResponseCode().ToString();
                transaction.ResponseMessage       = response.getResponseCodeText();
                transaction.AuthorizationCode     = response.getBankApprovalCode();
                transaction.AVSResultCode         = response.getAvsCode();
                //if (transaction.AVSResultCode.Equals("P") || transaction.AVSResultCode.Equals("B")) transaction.AVSResultCode = "U";
                transaction.CVVResultCode = response.getCreditCardVerificationResponse();
                //payment.ReferenceNumber = response.getReferenceId();

                HttpContext context = HttpContext.Current;
                if (context != null)
                {
                    transaction.RemoteIP = context.Request.ServerVariables["REMOTE_ADDR"];
                    transaction.Referrer = context.Request.ServerVariables["HTTP_REFERER"];
                }
            }

            return(transaction);
        }
示例#3
0
        public PayPros Initiate(PayPros payment, string cardNumber)
        {
            #region CREATE REQUEST
            CreditCardRequest request = new CreditCardRequest();
            try
            {
                request.setCreditCardNumber(cardNumber);
                if (!string.IsNullOrEmpty(payment.CCV))
                {
                    request.setCreditCardVerificationNumber(payment.CCV);
                }
                request.setExpireMonth(payment.CCExpireMonth);
                request.setExpireYear(payment.CCExpireYear);
                request.setChargeType(CreditCardRequest.SALE);
                request.setPurchaseOrderNumber(payment.PaymentAccount);
                request.setChargeTotal((double)payment.PaymentAmount);

                request.setPartialApprovalFlag(false);

                if (!string.IsNullOrEmpty(payment.RequestingOrigin))
                {
                    request.setCustomerIpAddress(payment.RequestingOrigin);
                }

                switch (_account)
                {
                case PaymentAccounts.UBO:
                    request.setIndustry("DIRECT_MARKETING");
                    break;

                case PaymentAccounts.Judicial:
                    break;

                default:
                    break;
                }

                switch (_method)
                {
                case PaymentMethods.Web:
                    request.setTransactionConditionCode(5);
                    break;

                case PaymentMethods.Phone:
                    request.setTransactionConditionCode(2);
                    break;

                default:
                    break;
                }
            }
            catch (Exception)
            {
                throw new ArgumentException("Unable to create request");
            }
            #endregion

            #region PROCESS REQUEST
            string             payprosToken = (payment.IsTest ? testTokens[_account] : accountTokens[_account]);
            CreditCardResponse response     = (CreditCardResponse)TransactionClient.doTransaction(request, payprosToken);
            payment.responseCode     = (payment.IsTest ? (-1 * response.getResponseCode()) : response.getResponseCode());//flip sign of response code for test payments (keeps it from being written for processing)
            payment.responseText     = response.getResponseCodeText();
            payment.retryRecommended = response.getRetryRecommended();
            payment.timestamp        = response.getTimeStamp();
            #endregion

            #region RECORD RESPONSE
            double authorizedAmount = 0;
            if (double.TryParse(response.getAuthorizedAmount(), out authorizedAmount))
            {
                payment.PaymentAmount = (decimal)authorizedAmount;
            }

            long orderID;
            if (long.TryParse(response.getOrderId(), out orderID))
            {
                payment.orderID = orderID;
            }

            long batchID;
            if (long.TryParse(response.getBatchId(), out batchID))
            {
                payment.batchID = batchID;
            }

            long bankApprovalCode;
            if (long.TryParse(response.getBankApprovalCode(), out bankApprovalCode))
            {
                payment.bankApprovalCode = bankApprovalCode;
            }

            long bankTransactionId;
            if (long.TryParse(response.getBankTransactionId(), out bankTransactionId))
            {
                payment.bankTransactionId = bankTransactionId;
            }

            int creditCardVerification;
            if (int.TryParse(response.getCreditCardVerificationResponse(), out creditCardVerification))
            {
                payment.creditCardVerificationResponse = creditCardVerification;
            }
            #endregion

            return(payment);
        }