/// <summary> /// Obtain a listing of all valid payment types in Quickbooks. /// </summary> /// <returns>a list of all quickbooks payment types</returns> public List <QuickbooksPaytype> getPaymentTypes() { List <QuickbooksPaytype> paymentTypes = new List <QuickbooksPaytype>(); IMsgSetRequest msgRequest = qbMgr.CreateMsgSetRequest("US", 4, 0); msgRequest.Attributes.OnError = ENRqOnError.roeStop; msgRequest.AppendPaymentMethodQueryRq(); IMsgSetResponse response = qbMgr.DoRequests(msgRequest); IPaymentMethodRetList payment_methods = (IPaymentMethodRetList)response.ResponseList.GetAt(0).Detail; for (int i = 0; i < payment_methods.Count; i++) { paymentTypes.Add(new QuickbooksPaytype() { Name = payment_methods.GetAt(i).Name.GetValue() }); } return(paymentTypes); }
void WalkPaymentMethodQueryRs(IMsgSetResponse responseMsgSet) { if (responseMsgSet == null) { return; } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return; } //if we sent only one request, there is only one response, we'll walk the list for this sample for (int i = 0; i < responseList.Count; i++) { MethodList = new List <PaymentMethod>(); IResponse response = responseList.GetAt(i); //check the status code of the response, 0=ok, >0 is warning if (response.StatusCode >= 0) { //the request-specific response is in the details, make sure we have some if (response.Detail != null) { //make sure the response is the type we're expecting ENResponseType responseType = (ENResponseType)response.Type.GetValue(); if (responseType == ENResponseType.rtPaymentMethodQueryRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IPaymentMethodRetList PaymentMethodRet = (IPaymentMethodRetList)response.Detail; int count = PaymentMethodRet.Count; for (int a = 0; a < count; a++) { MethodList.Add(WalkPaymentMethodRet(PaymentMethodRet.GetAt(a))); } } } } } }