/// <summary> /// Validates Customer Account Payment from AX. /// </summary> /// <param name="request">The service request to validate customer account payment.</param> /// <returns>The service response.</returns> private static NullResponse ValidateCustomerAccountPayment(ValidateCustomerAccountPaymentRealtimeRequest request) { var client = new TransactionServiceClient(request.RequestContext); client.ValidateCustomerAccountPayment(request.AccountNumber, request.Amount, request.CurrencyCode); return(new NullResponse()); }
/// <summary> /// Validates sufficient funds on account. /// </summary> /// <param name="context">The service request context.</param> /// <param name="customer">The customer.</param> /// <param name="useInvoiceAccount">Whether to use invoice account.</param> /// <param name="tenderLine">The tender line.</param> private static void CheckIfPaymentExceedsBalance(RequestContext context, Customer customer, bool useInvoiceAccount, TenderLine tenderLine) { // Search location set to all in order to retrieve pending transactions anchor from AX var localBalanceServiceRequest = new GetCustomerBalanceServiceRequest( customer.AccountNumber, customer.InvoiceAccount, SearchLocation.All); CustomerBalances pendingAccountBalances = context.Execute <GetCustomerBalanceServiceResponse>(localBalanceServiceRequest).Balance; // Total amount to verify is the sum of amount on the tender line and pending customer account balance // where pending balances = (tendered amounts - any deposits made) which is not yet uploaded to AX. decimal amountToVerify = tenderLine.Amount + (useInvoiceAccount ? pendingAccountBalances.InvoiceAccountPendingBalance : pendingAccountBalances.PendingBalance); var validateCustomerAccountPaymentRealtimeRequest = new ValidateCustomerAccountPaymentRealtimeRequest(tenderLine.CustomerId, amountToVerify, tenderLine.Currency); context.Execute <NullResponse>(validateCustomerAccountPaymentRealtimeRequest); }