/// <summary> /// Removes the card in the context for the user in the context from this partner. /// </summary> /// <returns> /// A task that will yield the result code for the operation. /// </returns> public async Task <ResultCode> RemoveCardAsync() { ResultCode result = ResultCode.None; // Build a account update request object to cancel card registration. CustomerAccountField[] customerAccountFieldFields = new CustomerAccountField[1] { new CustomerAccountField { fieldName = MasterCardConstants.AccountStatusCodeFieldName, data = MasterCardConstants.AccountStatusCanceled } }; doCustomerAccountUpdate accountUpdate = new doCustomerAccountUpdate { sourceId = MasterCardConstants.SourceId, bankCustomerNumber = ((User)Context[Key.User]).GetPartnerUserId(Partner.MasterCard), customerAccountFields = customerAccountFieldFields }; doCustomerAccountUpdateRequest accountUpdateRequest = new doCustomerAccountUpdateRequest { doCustomerAccountUpdate = accountUpdate }; LogRemoveCardRequestParameters(accountUpdateRequest); // Invoke the partner to remove the card. result = await PartnerUtilities.InvokePartner(Context, async() => { Context.Log.Verbose("Invoking partner RemoveCardAsync API."); CustomerAccountUpdateResp response = await MasterCardInvoker.RemoveCard(accountUpdate).ConfigureAwait(false); Context.Log.Verbose("Partner RemoveCardAsync API returned: {0}: {1}.", response.returnCode, response.returnMsg); LogUpdateCardResponseParameters(response); // Determine the ResultCode from the response code. switch (response.returnCode) { case MasterCardResponseCode.Success: case MasterCardResponseCode.InvalidCard: result = ResultCode.Success; break; case MasterCardResponseCode.UnknownError: result = ResultCode.UnknownError; break; } // Log a warning if result was not a success. if (result != ResultCode.Success) { Context.Log.Warning("MasterCard call failed. returnCode: {0}. returnMsg: {1}.", (int)DefaultLogEntryEventId.PartnerErrorWarning, response.returnCode, response.returnMsg); } return(result); }).ConfigureAwait(false); return(result); }
/// <summary> /// Removes the described card from MasterCard. /// </summary> /// <param name="doCustomerAccountUpdateRequest"> /// Description of the card to remove. /// </param> /// <returns> /// The response from MasterCard for the remove card attempt. /// </returns> public async Task <CustomerAccountUpdateResp> RemoveCard(doCustomerAccountUpdate doCustomerAccountUpdateRequest) { //TODO: IF we decide to delete the card in MasterCard at all, re-enable the call to MasterCard. // Since we know that this call can never succeed, let's not flood their logs with failure results and // create more work for them and for us. Note the convoluted means of disabling this are necessary to // satisfy syntactic requirements of the async/await pattern. // //TODO: If we decide not to delete the card in all partners, remove all relevant code and revert DeactivateCard to a synchronous op. doCustomerAccountUpdateResponse1 response = new doCustomerAccountUpdateResponse1 { doCustomerAccountUpdateResponse = new doCustomerAccountUpdateResponse { doCustomerAccountUpdateResult = new CustomerAccountUpdateResp { returnCode = MasterCardResponseCode.InvalidCard, returnMsg = "No call to MasterCard was made. Cards are not currently deleted from MasterCard." } } }; await Task.Factory.StartNew(() => {}); return(response.doCustomerAccountUpdateResponse.doCustomerAccountUpdateResult); //CustomerAccountUpdateResp result = null; //using (masterCardMRSServiceClient registrationClient = new masterCardMRSServiceClient("mastercardregistrationserviceSoap11")) //{ // Stopwatch sprocTimer = Stopwatch.StartNew(); // try // { // doCustomerAccountUpdateResponse1 response1 = await registrationClient.doCustomerAccountUpdateAsync(doCustomerAccountUpdateRequest); // result = response1.doCustomerAccountUpdateResponse.doCustomerAccountUpdateResult; // } // finally // { // sprocTimer.Stop(); // PerformanceInformation.Add("MasterCard DoCustomerAccountUpdateRequest (remove card)", // String.Format("{0} ms", sprocTimer.ElapsedMilliseconds)); // } //} //return result; }