Пример #1
0
            private static IEnumerable <TaxDetail> GetTaxDetails(Hashtable properties, string propertyNamespace, string propertyName)
            {
                IEnumerable <TaxDetail> taxDetails = null;

                PaymentProperty[] taxDetailsPropertyArray;
                if (PaymentProperty.GetPropertyValue(properties, propertyNamespace, propertyName, out taxDetailsPropertyArray))
                {
                    if (taxDetailsPropertyArray.Length > 0)
                    {
                        taxDetails = new List <TaxDetail>();
                        foreach (var taxDetailsProperty in taxDetailsPropertyArray)
                        {
                            PaymentProperty[] taxDetailPropertyArray = taxDetailsProperty.PropertyList;
                            if (taxDetailPropertyArray != null)
                            {
                                Hashtable taxDetailProperties = PaymentProperty.ConvertToHashtable(taxDetailPropertyArray);
                                var       taxDetail           = new TaxDetail();
                                taxDetail.TaxTypeIdentifier = PaymentUtilities.GetPropertyStringValue(taxDetailProperties, GenericNamespace.TaxDetail, TaxDetailProperties.TaxTypeIdentifier);
                                taxDetail.TaxRate           = PaymentUtilities.GetPropertyDecimalValue(taxDetailProperties, GenericNamespace.TaxDetail, TaxDetailProperties.TaxRate);
                                taxDetail.TaxDescription    = PaymentUtilities.GetPropertyStringValue(taxDetailProperties, GenericNamespace.TaxDetail, TaxDetailProperties.TaxDescription);
                                taxDetail.TaxAmount         = PaymentUtilities.GetPropertyDecimalValue(taxDetailProperties, GenericNamespace.TaxDetail, TaxDetailProperties.TaxAmount);
                                (taxDetails as List <TaxDetail>).Add(taxDetail);
                            }
                        }
                    }
                }

                return(taxDetails);
            }
Пример #2
0
            private static IEnumerable <MiscellaneousCharge> GetMiscellaneousCharges(Hashtable properties, string propertyNamespace, string propertyName)
            {
                IEnumerable <MiscellaneousCharge> miscellaneousCharges = null;

                PaymentProperty[] miscellaneousChargesPropertyArray;
                if (PaymentProperty.GetPropertyValue(properties, propertyNamespace, propertyName, out miscellaneousChargesPropertyArray))
                {
                    if (miscellaneousChargesPropertyArray.Length > 0)
                    {
                        miscellaneousCharges = new List <MiscellaneousCharge>();
                        foreach (var miscellaneousChargesProperty in miscellaneousChargesPropertyArray)
                        {
                            PaymentProperty[] miscellaneousChargePropertyArray = miscellaneousChargesProperty.PropertyList;
                            if (miscellaneousChargePropertyArray != null)
                            {
                                Hashtable miscellaneousChargeProperties = PaymentProperty.ConvertToHashtable(miscellaneousChargePropertyArray);
                                var       miscellaneousCharge           = new MiscellaneousCharge();
                                miscellaneousCharge.ChargeType   = PaymentUtilities.GetPropertyStringValue(miscellaneousChargeProperties, GenericNamespace.MiscellaneousCharge, MiscellaneousChargeProperties.ChargeType);
                                miscellaneousCharge.ChargeAmount = PaymentUtilities.GetPropertyDecimalValue(miscellaneousChargeProperties, GenericNamespace.MiscellaneousCharge, MiscellaneousChargeProperties.ChargeAmount);
                                (miscellaneousCharges as List <MiscellaneousCharge>).Add(miscellaneousCharge);
                            }
                        }
                    }
                }

                return(miscellaneousCharges);
            }
        /// <summary>
        /// Processes the service pipeline arguments.
        /// </summary>
        /// <param name="args">The service pipeline arguments.</param>
        public override void Process(ServicePipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentCondition(args.Request is GetPaymentServiceActionResultRequest, "args.Request", "Request must be of type GetPaymentServiceActionResultRequest.");
            Assert.ArgumentCondition(args.Result is GetPaymentServiceActionResultResult, "args.Result", "Result must be of type GetPaymentServiceActionResultResult.");
            var request = (GetPaymentServiceActionResultRequest)args.Request;
            var result  = (GetPaymentServiceActionResultResult)args.Result;

            var serviceRequestProperties = new List <PaymentProperty>();

            serviceRequestProperties.AddRange(this.GetMerchantProperties() ?? Enumerable.Empty <PaymentProperty>());

            serviceRequestProperties.Add(new PaymentProperty(
                                             GenericNamespace.TransactionData,
                                             TransactionDataProperties.PaymentAcceptResultAccessCode,
                                             request.PaymentAcceptResultAccessCode));

            var serviceResponse = this.ExecutePaymentServiceRequest(
                serviceRequestProperties,
                RetrievePaymentAcceptResultRelativeUri,
                request.Locale,
                result.SystemMessages);

            if (serviceResponse != null)
            {
                var serviceResponseProperties = PaymentProperty.ConvertToHashtable(serviceResponse.Properties);

                string token;
                PaymentProperty.GetPropertyValue(
                    serviceResponseProperties,
                    GenericNamespace.PaymentCard,
                    PaymentCardProperties.CardToken,
                    out token);

                var innerAuthorizeResponseProperty = PaymentProperty.GetPropertyFromHashtable(
                    serviceResponseProperties,
                    GenericNamespace.AuthorizationResponse,
                    AuthorizationResponseProperties.Properties);
                var innerAuthorizeResponseProperties = PaymentProperty.ConvertToHashtable(innerAuthorizeResponseProperty.PropertyList);

                string authorizationResult = null;
                PaymentProperty.GetPropertyValue(
                    innerAuthorizeResponseProperties,
                    GenericNamespace.AuthorizationResponse,
                    AuthorizationResponseProperties.AuthorizationResult,
                    out authorizationResult);

                result.AuthorizationResult = authorizationResult;
                result.CardToken           = token;
                result.Success             = true;
            }
            else
            {
                result.Success = false;
            }
        }
Пример #4
0
            /// <summary>
            /// Gets the string value of a payment property.
            /// </summary>
            /// <param name="propertyHashtable">The property hashtable.</param>
            /// <param name="propertyNamespace">The namespace.</param>
            /// <param name="propertyName">The name.</param>
            /// <param name="required">The flag indicating whether the property is required.</param>
            /// <param name="errors">The error list in case the property is required but not found.</param>
            /// <returns>The string value.</returns>
            private static string GetPropertyStringValue(Hashtable propertyHashtable, string propertyNamespace, string propertyName, bool required, List <PaymentError> errors)
            {
                string propertyValue;
                bool   found = PaymentProperty.GetPropertyValue(
                    propertyHashtable,
                    propertyNamespace,
                    propertyName,
                    out propertyValue);

                if (!found && required)
                {
                    var error = new PaymentError(ErrorCode.InvalidRequest, string.Format("Property '{0}' is null or not set", propertyName));
                    errors.Add(error);
                }

                return(propertyValue);
            }
Пример #5
0
            internal static string GetPropertyStringValue(Hashtable properties, string propertyNamespace, string propertyName, List <PaymentError> errors, ErrorCode errorCode)
            {
                if (properties == null)
                {
                    throw new ArgumentNullException("properties");
                }

                string value;

                if (!PaymentProperty.GetPropertyValue(properties, propertyNamespace, propertyName, out value))
                {
                    value = null;
                    if (errors != null)
                    {
                        errors.Add(new PaymentError(errorCode, MissingPropertyMessage(propertyNamespace, propertyName)));
                    }
                }

                return(value);
            }
Пример #6
0
        internal static bool GetPropertyBooleanValue(Dictionary <string, object> properties, string propertyNamespace, string propertyName, bool defaultValue, List <PaymentError> errors, ErrorCode errorCode)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            bool value;

            if (!PaymentProperty.GetPropertyValue(properties, propertyNamespace, propertyName, out value))
            {
                value = defaultValue;
                if (errors != null)
                {
                    errors.Add(new PaymentError(errorCode, MissingPropertyMessage(propertyNamespace, propertyName)));
                }
            }

            return(value);
        }
Пример #7
0
        internal static decimal GetPropertyDecimalValue(Dictionary <string, object> properties, string propertyNamespace, string propertyName, List <PaymentError> errors, ErrorCode errorCode)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            decimal value;

            if (!PaymentProperty.GetPropertyValue(properties, propertyNamespace, propertyName, out value))
            {
                value = DecimalValueNotPresent;
                if (errors != null)
                {
                    errors.Add(new PaymentError(errorCode, MissingPropertyMessage(propertyNamespace, propertyName)));
                }
            }

            return(value);
        }
Пример #8
0
            internal static decimal?GetPropertyDecimalValue(Hashtable properties, string propertyNamespace, string propertyName, List <PaymentError> errors, ErrorCode errorCode)
            {
                if (properties == null)
                {
                    throw new ArgumentNullException("properties");
                }

                decimal value;
                decimal?result = null;

                if (!PaymentProperty.GetPropertyValue(properties, propertyNamespace, propertyName, out value))
                {
                    if (errors != null)
                    {
                        errors.Add(new PaymentError(errorCode, MissingPropertyMessage(propertyNamespace, propertyName)));
                    }
                }
                else
                {
                    result = value;
                }

                return(result);
            }
Пример #9
0
        private string GetBasePaymentServiceUrl(GetPaymentServiceUrlRequest request, GetPaymentServiceUrlResult result, List <PaymentProperty> serviceRequestProperties)
        {
            var getPaymentAcceptPointResponse = this.ExecutePaymentServiceRequest(
                serviceRequestProperties,
                GetPaymentAcceptPointRelativeUri,
                request.Locale,
                result.SystemMessages);

            if (getPaymentAcceptPointResponse != null)
            {
                var getPaymentAcceptPointResponseProperties = PaymentProperty.ConvertToHashtable(getPaymentAcceptPointResponse.Properties);

                var paymentAcceptUrl = string.Empty;
                PaymentProperty.GetPropertyValue(
                    getPaymentAcceptPointResponseProperties,
                    GenericNamespace.TransactionData,
                    TransactionDataProperties.PaymentAcceptUrl,
                    out paymentAcceptUrl);

                return(paymentAcceptUrl);
            }

            return(string.Empty);
        }
Пример #10
0
            internal static IEnumerable <Level3Data> GetLevel3Data(Hashtable properties)
            {
                if (properties == null)
                {
                    throw new ArgumentNullException("properties");
                }

                IEnumerable <Level3Data> level3Data = null;

                PaymentProperty[] level3DataPropertyArray;
                if (PaymentProperty.GetPropertyValue(properties, GenericNamespace.PurchaseLevelData, PurchaseLevelDataProperties.L3Data, out level3DataPropertyArray))
                {
                    if (level3DataPropertyArray.Length > 0)
                    {
                        level3Data = new List <Level3Data>();
                    }

                    foreach (var level3DataProperty in level3DataPropertyArray)
                    {
                        var       level3DataItems           = new Level3Data();
                        Hashtable level3DataItemsProperties = PaymentProperty.ConvertToHashtable(level3DataProperty.PropertyList);

                        level3DataItems.SequenceNumber        = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.SequenceNumber);
                        level3DataItems.CommodityCode         = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.CommodityCode);
                        level3DataItems.ProductCode           = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.ProductCode);
                        level3DataItems.ProductName           = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.ProductName);
                        level3DataItems.ProductSKU            = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.ProductSKU);
                        level3DataItems.Descriptor            = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.Descriptor);
                        level3DataItems.UnitOfMeasure         = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.UnitOfMeasure);
                        level3DataItems.UnitPrice             = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.UnitPrice);
                        level3DataItems.Discount              = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.Discount);
                        level3DataItems.DiscountRate          = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.DiscountRate);
                        level3DataItems.Quantity              = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.Quantity);
                        level3DataItems.MiscCharge            = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.MiscCharge);
                        level3DataItems.NetTotal              = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.NetTotal);
                        level3DataItems.TaxAmount             = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.TaxAmount);
                        level3DataItems.TaxRate               = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.TaxRate);
                        level3DataItems.TotalAmount           = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.TotalAmount);
                        level3DataItems.CostCenter            = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.CostCenter);
                        level3DataItems.FreightAmount         = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.FreightAmount);
                        level3DataItems.HandlingAmount        = PaymentUtilities.GetPropertyDecimalValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.HandlingAmount);
                        level3DataItems.CarrierTrackingNumber = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.CarrierTrackingNumber);
                        level3DataItems.MerchantTaxID         = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.MerchantTaxID);
                        level3DataItems.MerchantCatalogNumber = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.MerchantCatalogNumber);
                        level3DataItems.TaxCategoryApplied    = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.TaxCategoryApplied);
                        level3DataItems.PickupAddress         = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.PickupAddress);
                        level3DataItems.PickupCity            = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.PickupCity);
                        level3DataItems.PickupState           = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.PickupState);
                        level3DataItems.PickupCounty          = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.PickupCounty);
                        level3DataItems.PickupZip             = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.PickupZip);
                        level3DataItems.PickupCountry         = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.PickupCountry);
                        level3DataItems.PickupDateTime        = PaymentUtilities.GetPropertyDateTimeValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.PickupDateTime);
                        level3DataItems.PickupRecordNumber    = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.PickupRecordNumber);
                        level3DataItems.CarrierShipmentNumber = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.CarrierShipmentNumber);
                        level3DataItems.UNSPSCCode            = PaymentUtilities.GetPropertyStringValue(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.UNSPSCCode);

                        level3DataItems.TaxDetails           = PaymentUtilities.GetTaxDetails(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.TaxDetails);
                        level3DataItems.MiscellaneousCharges = PaymentUtilities.GetMiscellaneousCharges(level3DataItemsProperties, GenericNamespace.L3Data, L3DataProperties.MiscellaneousCharges);

                        (level3Data as List <Level3Data>).Add(level3DataItems);
                    }
                }

                return(level3Data);
            }
Пример #11
0
            internal static Level2Data GetLevel2Data(Hashtable properties)
            {
                if (properties == null)
                {
                    throw new ArgumentNullException("properties");
                }

                Level2Data level2Data = null;

                PaymentProperty[] level2DataPropertyArray;
                if (PaymentProperty.GetPropertyValue(properties, GenericNamespace.PurchaseLevelData, PurchaseLevelDataProperties.L2Data, out level2DataPropertyArray))
                {
                    Hashtable level2DataProperties = PaymentProperty.ConvertToHashtable(level2DataPropertyArray);

                    level2Data = new Level2Data();
                    level2Data.OrderDateTime              = PaymentUtilities.GetPropertyDateTimeValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.OrderDateTime);
                    level2Data.OrderNumber                = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.OrderNumber);
                    level2Data.InvoiceDateTime            = PaymentUtilities.GetPropertyDateTimeValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.InvoiceDateTime);
                    level2Data.InvoiceNumber              = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.InvoiceNumber);
                    level2Data.OrderDescription           = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.OrderDescription);
                    level2Data.SummaryCommodityCode       = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.SummaryCommodityCode);
                    level2Data.MerchantContact            = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantContact);
                    level2Data.MerchantTaxId              = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantTaxId);
                    level2Data.MerchantType               = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantType);
                    level2Data.PurchaserId                = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.PurchaserId);
                    level2Data.PurchaserTaxId             = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.PurchaserTaxId);
                    level2Data.ShipToCity                 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToCity);
                    level2Data.ShipToCounty               = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToCounty);
                    level2Data.ShipToState_ProvinceCode   = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToState_ProvinceCode);
                    level2Data.ShipToPostalCode           = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToPostalCode);
                    level2Data.ShipToCountryCode          = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipToCountryCode);
                    level2Data.ShipFromCity               = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromCity);
                    level2Data.ShipFromCounty             = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromCounty);
                    level2Data.ShipFromState_ProvinceCode = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromState_ProvinceCode);
                    level2Data.ShipFromPostalCode         = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromPostalCode);
                    level2Data.ShipFromCountryCode        = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.ShipFromCountryCode);
                    level2Data.DiscountAmount             = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.DiscountAmount);
                    level2Data.MiscCharge                 = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MiscCharge);
                    level2Data.DutyAmount                 = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.DutyAmount);
                    level2Data.FreightAmount              = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.FreightAmount);
                    level2Data.IsTaxable              = PaymentUtilities.GetPropertyBooleanValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.IsTaxable);
                    level2Data.TotalTaxAmount         = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TotalTaxAmount);
                    level2Data.TotalTaxRate           = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TotalTaxRate);
                    level2Data.MerchantName           = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantName);
                    level2Data.MerchantStreet         = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantStreet);
                    level2Data.MerchantCity           = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantCity);
                    level2Data.MerchantState          = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantState);
                    level2Data.MerchantCounty         = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantCounty);
                    level2Data.MerchantCountryCode    = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantCountryCode);
                    level2Data.MerchantZip            = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MerchantZip);
                    level2Data.TaxRate                = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxRate);
                    level2Data.TaxAmount              = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxAmount);
                    level2Data.TaxDescription         = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxDescription);
                    level2Data.TaxTypeIdentifier      = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxTypeIdentifier);
                    level2Data.RequesterName          = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.RequesterName);
                    level2Data.TotalAmount            = PaymentUtilities.GetPropertyDecimalValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TotalAmount);
                    level2Data.PurchaseCardType       = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.PurchaseCardType);
                    level2Data.AmexLegacyDescription1 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.AmexLegacyDescription1);
                    level2Data.AmexLegacyDescription2 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.AmexLegacyDescription2);
                    level2Data.AmexLegacyDescription3 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.AmexLegacyDescription3);
                    level2Data.AmexLegacyDescription4 = PaymentUtilities.GetPropertyStringValue(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.AmexLegacyDescription4);

                    level2Data.TaxDetails           = PaymentUtilities.GetTaxDetails(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.TaxDetails);
                    level2Data.MiscellaneousCharges = PaymentUtilities.GetMiscellaneousCharges(level2DataProperties, GenericNamespace.L2Data, L2DataProperties.MiscellaneousCharges);
                }

                return(level2Data);
            }
Пример #12
0
            private void RetrievePaymentAcceptResult()
            {
                // Get payment processor
                PaymentProcessorManager.Create(new string[] { ConnectorAssembly });
                IPaymentProcessor processor = PaymentProcessorManager.GetPaymentProcessor(ConnectorName);

                // Prepare payment request
                var request = new Request();

                request.Locale = this.requestLocale;

                var properties = new List <PaymentProperty>();

                this.AddMerchantProperties(properties);

                PaymentProperty property;

                property = new PaymentProperty(
                    GenericNamespace.TransactionData,
                    TransactionDataProperties.PaymentAcceptResultAccessCode,
                    this.ResultAccessCodeHiddenField.Value);
                properties.Add(property);

                request.Properties = properties.ToArray();

                // Call
                Response response = processor.RetrievePaymentAcceptResult(request);

                string cardTokenResult     = "N/A";
                string authorizationResult = "N/A";
                string captureResult       = "N/A";
                string voidResult          = "N/A";
                string errors = "None";

                if (response != null && response.Properties != null)
                {
                    Hashtable responseProperties = PaymentProperty.ConvertToHashtable(response.Properties);

                    // Read card token
                    string token;
                    PaymentProperty.GetPropertyValue(
                        responseProperties,
                        GenericNamespace.PaymentCard,
                        PaymentCardProperties.CardToken,
                        out token);

                    if (!string.IsNullOrEmpty(token))
                    {
                        // Store token or use token.
                        // In this sample, we send the token to the next page to display. Do not do this in production.
                        cardTokenResult = token;
                    }

                    // Read authorize result
                    if (this.transactionType == TransactionType.Authorize || this.transactionType == TransactionType.Capture)
                    {
                        PaymentProperty innerAuthorizeResponseProperty = PaymentProperty.GetPropertyFromHashtable(
                            responseProperties,
                            GenericNamespace.AuthorizationResponse,
                            AuthorizationResponseProperties.Properties);

                        if (innerAuthorizeResponseProperty != null)
                        {
                            var innerAuthorizeResponseProperties = PaymentProperty.ConvertToHashtable(innerAuthorizeResponseProperty.PropertyList);

                            string authorizationResultOut = null;
                            PaymentProperty.GetPropertyValue(
                                innerAuthorizeResponseProperties,
                                GenericNamespace.AuthorizationResponse,
                                AuthorizationResponseProperties.AuthorizationResult,
                                out authorizationResultOut);

                            if (!string.IsNullOrEmpty(authorizationResultOut))
                            {
                                authorizationResult = authorizationResultOut;
                            }
                        }
                    }

                    // Read capture result
                    if (this.transactionType == TransactionType.Capture)
                    {
                        PaymentProperty innerCaptureResponseProperty = PaymentProperty.GetPropertyFromHashtable(
                            responseProperties,
                            GenericNamespace.CaptureResponse,
                            CaptureResponseProperties.Properties);

                        if (innerCaptureResponseProperty != null)
                        {
                            var innerCaptureResponseProperties = PaymentProperty.ConvertToHashtable(innerCaptureResponseProperty.PropertyList);

                            string captureResultOut = null;
                            PaymentProperty.GetPropertyValue(
                                innerCaptureResponseProperties,
                                GenericNamespace.CaptureResponse,
                                CaptureResponseProperties.CaptureResult,
                                out captureResultOut);

                            if (!string.IsNullOrEmpty(captureResultOut))
                            {
                                captureResult = captureResultOut;
                            }
                        }
                    }

                    // Read void result
                    if (this.transactionType == TransactionType.Authorize || this.transactionType == TransactionType.Capture)
                    {
                        PaymentProperty innerVoidResponseProperty = PaymentProperty.GetPropertyFromHashtable(
                            responseProperties,
                            GenericNamespace.VoidResponse,
                            VoidResponseProperties.Properties);

                        if (innerVoidResponseProperty != null)
                        {
                            var innerVoidResponseProperties = PaymentProperty.ConvertToHashtable(innerVoidResponseProperty.PropertyList);

                            string voidResultOut = null;
                            PaymentProperty.GetPropertyValue(
                                innerVoidResponseProperties,
                                GenericNamespace.VoidResponse,
                                VoidResponseProperties.VoidResult,
                                out voidResultOut);

                            if (!string.IsNullOrEmpty(voidResultOut))
                            {
                                voidResult = voidResultOut;
                            }
                        }
                    }
                }

                if (response.Errors != null && response.Errors.Length > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var error in response.Errors)
                    {
                        sb.AppendLine(string.Format("{0}: {1}", error.Code, error.Message));
                    }

                    errors = sb.ToString();
                }

                Server.Transfer(
                    string.Format(
                        "ResultPage.aspx?cardTokenResult={0}&authorizationResult={1}&captureResult={2}&voidResult={3}&errors={4}",
                        HttpUtility.UrlEncode(cardTokenResult),
                        HttpUtility.UrlEncode(authorizationResult),
                        HttpUtility.UrlEncode(captureResult),
                        HttpUtility.UrlEncode(voidResult),
                        HttpUtility.UrlEncode(errors)));
            }
Пример #13
0
            private void GetPaymentAcceptPoint()
            {
                // Get payment processor
                PaymentProcessorManager.Create(new string[] { ConnectorAssembly });
                IPaymentProcessor processor = PaymentProcessorManager.GetPaymentProcessor(ConnectorName);

                // Prepare payment request
                var request = new Request();

                request.Locale = this.requestLocale;

                var properties = new List <PaymentProperty>();

                this.AddMerchantProperties(properties);

                PaymentProperty property;

                property = new PaymentProperty(
                    GenericNamespace.PaymentCard,
                    PaymentCardProperties.CardType,
                    "Visa;MasterCard;Amex;Discover;Debit");
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.PaymentCard,
                    PaymentCardProperties.ShowSameAsShippingAddress,
                    this.showSameAsShippingAddress);
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.PaymentCard,
                    PaymentCardProperties.StreetAddress,
                    "1 Microsoft Way");
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.PaymentCard,
                    PaymentCardProperties.City,
                    "Redmond");
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.PaymentCard,
                    PaymentCardProperties.State,
                    "WA");
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.PaymentCard,
                    PaymentCardProperties.PostalCode,
                    "98052");
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.PaymentCard,
                    PaymentCardProperties.Country,
                    "US");
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.TransactionData,
                    TransactionDataProperties.TransactionType,
                    this.transactionType.ToString());
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.TransactionData,
                    TransactionDataProperties.SupportCardSwipe,
                    this.supportCardSwipe);
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.TransactionData,
                    TransactionDataProperties.SupportCardTokenization,
                    this.supportCardTokenization);
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.TransactionData,
                    TransactionDataProperties.HostPageOrigin,
                    HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority));
                properties.Add(property);

                property = new PaymentProperty(
                    GenericNamespace.TransactionData,
                    TransactionDataProperties.IndustryType,
                    this.industryType);
                properties.Add(property);

                if (this.transactionType == TransactionType.Authorize || this.transactionType == TransactionType.Capture)
                {
                    property = new PaymentProperty(
                        GenericNamespace.TransactionData,
                        TransactionDataProperties.PurchaseLevel,
                        PurchaseLevel.Level1.ToString());
                    properties.Add(property);

                    property = new PaymentProperty(
                        GenericNamespace.TransactionData,
                        TransactionDataProperties.AllowPartialAuthorization,
                        "true");
                    properties.Add(property);

                    property = new PaymentProperty(
                        GenericNamespace.TransactionData,
                        TransactionDataProperties.AllowVoiceAuthorization,
                        this.supportVoiceAuthorization);
                    properties.Add(property);

                    property = new PaymentProperty(
                        GenericNamespace.TransactionData,
                        TransactionDataProperties.CurrencyCode,
                        "USD");
                    properties.Add(property);
                }

                request.Properties = properties.ToArray();

                // Call
                Response response = processor.GetPaymentAcceptPoint(request);

                if (response != null && response.Errors == null && response.Properties != null)
                {
                    Hashtable responseProperties = PaymentProperty.ConvertToHashtable(response.Properties);

                    string paymentAcceptUrl;
                    PaymentProperty.GetPropertyValue(
                        responseProperties,
                        GenericNamespace.TransactionData,
                        TransactionDataProperties.PaymentAcceptUrl,
                        out paymentAcceptUrl);

                    if (!string.IsNullOrEmpty(paymentAcceptUrl))
                    {
                        this.PaymentAcceptUrl = string.Format(
                            "{0}&fontsize={1}&fontfamily={2}&labelcolor={3}&textbackgroundcolor={4}&textcolor={5}&disabledtextbackgroundcolor={6}&columnnumber={7}",
                            paymentAcceptUrl,
                            HttpUtility.UrlEncode(this.fontSize),
                            HttpUtility.UrlEncode(this.fontFamily),
                            HttpUtility.UrlEncode(this.labelColor),
                            HttpUtility.UrlEncode(this.textBackgroundColor),
                            HttpUtility.UrlEncode(this.textColor),
                            HttpUtility.UrlEncode(this.disabledTextBackgroundColor),
                            HttpUtility.UrlEncode(this.columnNumber));
                        this.CardPageOriginHiddenField.Value = new Uri(paymentAcceptUrl).GetLeftPart(UriPartial.Authority);
                    }
                    else
                    {
                        throw new InvalidOperationException("Failed to retrieve card page. Payment accepting URL is null or empty.");
                    }
                }
                else
                {
                    string errorMessage = string.Empty;
                    if (response == null)
                    {
                        errorMessage = "Response is null. ";
                    }
                    else
                    {
                        if (response.Properties == null)
                        {
                            errorMessage += "Response properties is null. ";
                        }

                        if (response.Errors != null)
                        {
                            errorMessage += "Response contains error(s). ";
                            foreach (var error in response.Errors)
                            {
                                errorMessage += string.Format("{0}: {1}.", error.Code, error.Message);
                            }
                        }
                    }

                    throw new InvalidOperationException("Failed to retrieve card page. " + errorMessage);
                }
            }