/// <summary>
            /// Gets the change.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>
            /// A response containing the change tender line.
            /// </returns>
            private static GetChangePaymentServiceResponse GetChange(GetChangePaymentServiceRequest request)
            {
                if (request == null)
                {
                    throw new ArgumentNullException("request");
                }

                if (string.IsNullOrWhiteSpace(request.PaymentTenderTypeId))
                {
                    throw new PaymentException(PaymentErrors.Microsoft_Dynamics_Commerce_Runtime_InvalidPaymentRequest, "request.TenderTypeId is null or empty.");
                }

                TenderType overtenderTenderType = GetTenderType(request.RequestContext, request.PaymentTenderTypeId);

                if (overtenderTenderType == null)
                {
                    throw new DataValidationException(
                              DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_ObjectNotFound,
                              string.Format("Tender type with id '{0}' not found", request.PaymentTenderTypeId));
                }

                string changeTenderTypeId;

                if (overtenderTenderType.AboveMinimumChangeAmount != decimal.Zero &&
                    Math.Abs(request.ChangeAmount) > Math.Abs(overtenderTenderType.AboveMinimumChangeAmount) &&
                    !string.IsNullOrWhiteSpace(overtenderTenderType.AboveMinimumChangeTenderTypeId))
                {
                    // Use "above minimum change tender type" if amount exceeds configured value.
                    changeTenderTypeId = overtenderTenderType.AboveMinimumChangeTenderTypeId;
                }
                else
                {
                    changeTenderTypeId = overtenderTenderType.ChangeTenderTypeId;
                }

                if (string.IsNullOrWhiteSpace(changeTenderTypeId))
                {
                    // If change tender type is not configured using tender type of last payment (ePOS behavior)
                    changeTenderTypeId = overtenderTenderType.TenderTypeId;
                }

                TenderType changeTenderType = GetTenderType(request.RequestContext, changeTenderTypeId);

                if (changeTenderType == null)
                {
                    // If change tender type is not configured using tender type of last payment (ePOS behavior)
                    changeTenderType = overtenderTenderType;
                }

                request.ChangeTenderTypeId = changeTenderType.TenderTypeId;

                // Round change amount.
                request.ChangeAmount = RoundAmountByTenderType(request.RequestContext, request.ChangeTenderTypeId, request.ChangeAmount, isChange: true);

                IRequestHandler paymentService           = ResolvePaymentService(request.RequestContext, request.GetType(), request.ChangeTenderTypeId);
                GetChangePaymentServiceResponse response = request.RequestContext.Runtime.Execute <GetChangePaymentServiceResponse>(request, request.RequestContext, paymentService);

                // Update tender lines with amounts and exchange rates for channel and company currencies.
                CalculateTenderLineCurrencyAmounts(response.TenderLine, request.RequestContext);

                return(response);
            }
예제 #2
0
 /// <summary>
 /// Gets the change.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns>
 /// A response containing the change tender line.
 /// </returns>
 private static GetChangePaymentServiceResponse GetChange(GetChangePaymentServiceRequest request)
 {
     // Change cannot be given in loyalty cards because loyalty card balance is meansured using loyalty points.
     throw new FeatureNotSupportedException(FeatureNotSupportedErrors.Microsoft_Dynamics_Commerce_Runtime_ChangeTenderTypeNotSupported, string.Format(CultureInfo.InvariantCulture, "Request '{0}' is not supported.", request.GetType()));
 }
예제 #3
0
 /// <summary>
 /// Gets the change.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns>
 /// A response containing the change tender line.
 /// </returns>
 private static GetChangePaymentServiceResponse GetChange(GetChangePaymentServiceRequest request)
 {
     // Change cannot be given to customer account.
     throw new FeatureNotSupportedException(FeatureNotSupportedErrors.Microsoft_Dynamics_Commerce_Runtime_ChangeTenderTypeNotSupported, string.Format(CultureInfo.InvariantCulture, "Request '{0}' is not supported. Verify change tender type settings.", request.GetType()));
 }
예제 #4
0
 /// <summary>
 /// Gets the change.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns>
 /// A response containing the change tender line.
 /// </returns>
 private static GetChangePaymentServiceResponse GetChange(GetChangePaymentServiceRequest request)
 {
     // Change cannot be given in gift cards because it requires manual card number input.
     throw new FeatureNotSupportedException(FeatureNotSupportedErrors.Microsoft_Dynamics_Commerce_Runtime_ChangeTenderTypeNotSupported, string.Format("Request '{0}' is not supported. Verify change tender type settings.", request.GetType()));
 }