コード例 #1
0
        public async Task <PaymentAuthorizationGuiResponse> ProcessResponse(
            PaymentProviderConfiguration configuration,
            NameValueCollection paramsCollection,
            ResponseParameters additionalParameters)
        {
            string paramsDesc = PaymentFrameworkUtility.DescribeNameValueCollection(paramsCollection);

            this.Logger.CreateEntry(typeof(CapitaPaymentProvider), LogLevel.Debug, $"ProcessResponse({paramsDesc})");

            string roundTripTransactionReference = paramsCollection[RoundTripTokenKey];

            if (String.IsNullOrEmpty(roundTripTransactionReference))
            {
                throw new InvalidOperationException($"response did not include required field '{RoundTripTokenKey}'");
            }

            Guid pendingPaymentRef = new Guid(roundTripTransactionReference);

            string paymentProviderTransactionReference = additionalParameters.ProviderReference;

            if (String.IsNullOrEmpty(paymentProviderTransactionReference))
            {
                throw new InvalidOperationException("response did not include required field \'PaymentProviderTransactionReference\'");
            }

            var backendResponse = await CheckAuthorizationInternal(configuration, pendingPaymentRef.ToString(), paymentProviderTransactionReference);

            return(new PaymentAuthorizationGuiResponse(backendResponse, null));
        }
コード例 #2
0
        public async Task <PaymentAuthorizationGuiResponse> ProcessResponse(
            PaymentProviderConfiguration configuration,
            NameValueCollection paramsCollection,
            ResponseParameters additionalParameters)
        {
            string paramsDesc = PaymentFrameworkUtility.DescribeNameValueCollection(paramsCollection);

            Logger.CreateEntry(typeof(CivicaPaymentProvider), LogLevel.Debug, $"ProcessResponse({paramsDesc})");

            string responseCode = paramsCollection["ResponseCode"] ?? "-1";

            int  responseCodeParsed = -1;
            bool didParse           = Int32.TryParse(responseCode, out responseCodeParsed);

            if (didParse && (0 == responseCodeParsed))
            {
                string roundTripTransactionReference = paramsCollection["CallingApplicationTransactionReference"];
                if (String.IsNullOrEmpty(roundTripTransactionReference))
                {
                    throw new InvalidOperationException(String.Format("response did not include required field '{0}'",
                                                                      "CallingApplicationTransactionReference"));
                }

                Guid pendingPaymentRef = new Guid(roundTripTransactionReference);

                var backendResponse = await CheckAuthorizationInternal(configuration, pendingPaymentRef.ToString());

                backendResponse.ResponseCode  = responseCode;
                backendResponse.TransactionId = roundTripTransactionReference;
                return(new PaymentAuthorizationGuiResponse(backendResponse, null));
            }
            else
            {
                var backendResponse = new PaymentAuthorizationResponse(false, PaymentAuthorizationResult.Declined,
                                                                       !string.IsNullOrEmpty(paramsCollection["PaymentAmount"]) ? decimal.Parse(paramsCollection["PaymentAmount"]) : 0.00m,
                                                                       paramsCollection["ResponseDescription"],
                                                                       paramsCollection["IncomeManagementReceiptNumber"])
                {
                    ResponseCode  = responseCode,
                    TransactionId = paramsCollection["CallingApplicationTransactionReference"]
                };
                return(new PaymentAuthorizationGuiResponse(backendResponse, null));
            }
        }