Ejemplo n.º 1
0
            /// <summary>
            /// Cancels the payment.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>A response containing the canceled tender line.</returns>
            private static VoidPaymentServiceResponse CancelPayment(VoidPaymentServiceRequest request)
            {
                if (request == null)
                {
                    throw new ArgumentNullException("request");
                }

                if (request.TenderLine == null)
                {
                    throw new PaymentException(PaymentErrors.Microsoft_Dynamics_Commerce_Runtime_InvalidPaymentRequest, "request.TenderLine is null.");
                }

                if (request.TenderLine.Amount <= 0)
                {
                    throw new PaymentException(PaymentErrors.Microsoft_Dynamics_Commerce_Runtime_InvalidPaymentRequest, "Issued credit memo cannot be voided.");
                }

                string orgUnitNumber = request.RequestContext.GetOrgUnit().OrgUnitNumber;

                var unlockCreditMemoRealtimeRequest = new UnlockCreditMemoRealtimeRequest(
                    request.TenderLine.CreditMemoId,
                    orgUnitNumber,
                    request.RequestContext.GetTerminal().TerminalId);

                request.RequestContext.Execute <NullResponse>(unlockCreditMemoRealtimeRequest);

                request.TenderLine.Status     = TenderLineStatus.Voided;
                request.TenderLine.IsVoidable = false;

                return(new VoidPaymentServiceResponse(request.TenderLine));
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Removes reservation of the credit memo from a given terminal so it can be used on other terminals.
            /// </summary>
            /// <param name="request">The <see cref="UnlockCreditMemoRealtimeRequest"/> request.</param>
            /// <returns>The <see cref="NullResponse"/> response.</returns>
            private static NullResponse UnlockCreditMemo(UnlockCreditMemoRealtimeRequest request)
            {
                var transactionClient = new TransactionService.TransactionServiceClient(request.RequestContext);

                transactionClient.UnlockCreditMemo(request.CreditMemoId, request.StoreId, request.TerminalId);

                return(new NullResponse());
            }