Esempio n. 1
0
        //Todo: Remove the mock code once Visa provides the saveoffer api
        /// <summary>
        ///     Visa is supposed to implemented an api for register deal
        ///     it is not available now and all deals are registered manually offline
        ///     We are mocking the request now
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <RegisterDealResponse> RegisterDeal(RegisterDealRequest request)
        {
#if !XXXDEBUG
            string logstring = string.Format("{0} RegisterDealRequest {1}\n",
                                             DateTime.Now.ToString(CultureInfo.InvariantCulture),
                                             request.BingOfferDealId);
            // just the last four digits
            File.AppendAllText(Logfilename, logstring);
#endif
            RegisterDealResponse response;
            Stopwatch            sprocTimer = Stopwatch.StartNew();
            try
            {
                response = await RegisterDealMock.RegisterDeal(request).ConfigureAwait(false);
            }
            finally
            {
                sprocTimer.Stop();
                PerformanceInformation.Add("Visa RegisterDeal ",
                                           String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
            }
#if !XXXDEBUG
            logstring = string.Format("{0} RegisterDealResponse {1}, {2}\n",
                                      DateTime.Now.ToString(CultureInfo.InvariantCulture),
                                      request.BingOfferDealId, response.VisaDealId);
            // just the last four digits
            File.AppendAllText(Logfilename, logstring);
#endif
            return(response);
        }
Esempio n. 2
0
        /// <summary>
        ///     Remove a user request
        /// </summary>
        /// <param name="request">request for remove user</param>
        /// <param name="shallNotRun">Shall not run for normal cases</param>
        /// <returns>response for removing user</returns>
        public async Task <Unenroll_Response> RemoveUser(UnenrollRequest request, bool shallNotRun = true)
        {
            Unenroll_Response response;

            using (var client = VisaRtmClientManager.Instance.GetVisaRtmClient())
            {
                Stopwatch sprocTimer = Stopwatch.StartNew();
                try
                {
                    if (shallNotRun)
                    {
                        response         = new Unenroll_Response();
                        response.Success = true;
                    }
                    else
                    {
#if !XXXDEBUG
                        string logstring = string.Format("{0} UnenrollRequest {1}\n",
                                                         DateTime.Now.ToString(CultureInfo.InvariantCulture),
                                                         ((ExternalAuthenticationRecord)request.AuthenticationRecord)
                                                         .UserKey);
                        // just the last four digits
                        File.AppendAllText(Logfilename, logstring);
#endif
                        response = await client.UnenrollAsync(request).ConfigureAwait(false);

#if !XXXDEBUG
                        if (response.Success)
                        {
                            logstring = string.Format("{0} UnenrollResponse {1} {2}\n",
                                                      DateTime.Now.ToString(CultureInfo.InvariantCulture),
                                                      ((ExternalAuthenticationRecord)request.AuthenticationRecord)
                                                      .UserKey,
                                                      response.Success);
                            File.AppendAllText(Logfilename, logstring);
                        }
#endif
                    }
                }
                finally
                {
                    sprocTimer.Stop();
                    if (PerformanceInformation != null)
                    {
                        PerformanceInformation.Add("Visa RemoveUser ",
                                                   String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
                    }
                }
            }
            return(response);
        }
Esempio n. 3
0
        /// <summary>
        ///     Create Card Enrollment Request
        /// </summary>
        /// <param name="request">request</param>
        /// <returns>response</returns>
        public async Task <EnrollResponse> CreateEnrollment(EnrollRequest request)
        {
            EnrollResponse response;

            using (var client = VisaRtmClientManager.Instance.GetVisaRtmClient())
            {
                Stopwatch sprocTimer = Stopwatch.StartNew();
                try
                {
                    // Todo: Should remove this later
                    // Visa has issues to add the same card to multiple users.
                    // Requests are logged so we can clean up the users using an external tool
#if !XXXDEBUG
                    string logstring = string.Format("{0} CreateEnrollmentRequest {1} {2}\n",
                                                     DateTime.Now.ToString(CultureInfo.InvariantCulture),
                                                     request.CardHolderDetails.ExternalUserId,
                                                     request.CardDetails[0].CardNumber.Substring(12));
                    // just the last four digits
                    File.AppendAllText(Logfilename, logstring);
#endif
                    response = await client.EnrollAsync(request).ConfigureAwait(false);

#if !XXXDEBUG
                    if (response.EnrollmentRecord != null && response.EnrollmentRecord.CardDetails.Length > 0)
                    {
                        logstring = string.Format("{0} CreateEnrollmentResponse {1} {2}\n",
                                                  DateTime.Now.ToString(CultureInfo.InvariantCulture),
                                                  response.EnrollmentRecord.CardHolderDetails.ExternalUserId,
                                                  response.EnrollmentRecord.CardDetails[0].CardId);
                        File.AppendAllText(Logfilename, logstring);
                    }
#endif
                }
                finally
                {
                    sprocTimer.Stop();
                    PerformanceInformation.Add("Visa CreateEnrollment ",
                                               String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
                }
            }
            return(response);
        }
Esempio n. 4
0
        /// <summary>
        /// Issue credit to user during a burn transaction in lieu of earn credit that user has in his account
        /// </summary>
        /// <param name="request"></param>
        /// <returns>result</returns>
        public async Task <SaveStatementCredit_Response> SaveStatementCreditAsync(SaveStatementCreditRequest request)
        {
            SaveStatementCredit_Response response;

            using (var client = VisaRtmClientManager.Instance.GetVisaRtmClient())
            {
                Stopwatch sprocTimer = Stopwatch.StartNew();
                try
                {
                    response = await client.SaveStatementCreditAsync(request).ConfigureAwait(false);
                }
                finally
                {
                    sprocTimer.Stop();
                    PerformanceInformation.Add("SaveStatementCreditAsync ",
                                               String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
                }
            }
            return(response);
        }
Esempio n. 5
0
        /// <summary>
        ///     Remove card from user
        /// </summary>
        /// <param name="request">userkey, community, cardnumber</param>
        /// <returns>result</returns>
        public async Task <DeleteCardResponse> RemoveCard(DeleteCardRequest request)
        {
            DeleteCardResponse response;

            using (var client = VisaRtmClientManager.Instance.GetVisaRtmClient())
            {
                Stopwatch sprocTimer = Stopwatch.StartNew();
                try
                {
                    response = await client.DeleteCardAsync(request).ConfigureAwait(false);
                }
                finally
                {
                    sprocTimer.Stop();
                    PerformanceInformation.Add("Visa RemoveCard ",
                                               String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
                }
            }
            return(response);
        }
        /// <summary>
        /// Adds the described card to MasterCard.
        /// </summary>
        /// <param name="doEnrollmentRequest">
        /// Description of the card to add.
        /// </param>
        /// <returns>
        /// The response from MasterCard for the add card attempt.
        /// </returns>
        public async Task <DoEnrollmentResp> AddCard(doEnrollment doEnrollmentRequest)
        {
            DoEnrollmentResp result = null;

            using (masterCardMRSServiceClient registrationClient = new masterCardMRSServiceClient("mastercardregistrationserviceSoap11"))
            {
                Stopwatch sprocTimer = Stopwatch.StartNew();
                try
                {
                    doEnrollmentResponse1 response1 = await registrationClient.doEnrollmentAsync(doEnrollmentRequest).ConfigureAwait(false);

                    result = response1.doEnrollmentResponse.doEnrollmentResult;
                }
                finally
                {
                    sprocTimer.Stop();
                    PerformanceInformation.Add("MasterCard DoEnrollment (add card)",
                                               String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
                }
            }

            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// Adds the described card to FirstData.
        /// </summary>
        /// <param name="cardRegisterRequest">
        /// Description of the card to add.
        /// </param>
        /// <returns>
        /// The response from First Data for the add card attempt.
        /// </returns>
        public async Task <CardRegisterResponse> AddCard(CardRegisterRequest cardRegisterRequest)
        {
            CardRegisterResponse result;

            using (registrationserviceClient registrationClient = new registrationserviceClient("registrationserviceSoap12"))
            {
                Stopwatch sprocTimer = Stopwatch.StartNew();
                try
                {
                    CardRegisterResponse1 response1 = await registrationClient.CardRegisterAsync(cardRegisterRequest);

                    result = response1.CardRegisterResponse;
                }
                finally
                {
                    sprocTimer.Stop();
                    PerformanceInformation.Add("FirstData CardRegister (add card)",
                                               String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
                }
            }

            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// Claims the specified deal for redemption with the specified card with First Data.
        /// </summary>
        /// <param name="offerRegisterRequest">
        /// Description of the deal to claim.
        /// </param>
        /// <returns>
        /// The response from First Data for the claim deal attempt.
        /// </returns>
        /// <remarks>
        /// First Data uses the same API for registering and claiming a deal, varying only input parameters.
        /// </remarks>
        public async Task <OfferRegisterResponse> ClaimDeal(OfferRegisterRequest offerRegisterRequest)
        {
            OfferRegisterResponse result;

            using (registrationserviceClient registrationClient = new registrationserviceClient("registrationserviceSoap12"))
            {
                Stopwatch sprocTimer = Stopwatch.StartNew();
                try
                {
                    OfferRegisterResponse1 response1 = await registrationClient.OfferRegisterAsync(offerRegisterRequest);

                    result = response1.OfferRegisterResponse;
                }
                finally
                {
                    sprocTimer.Stop();
                    PerformanceInformation.Add("FirstData OfferRegister (claim deal)",
                                               String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
                }
            }

            return(result);
        }
Esempio n. 9
0
        /// <summary>
        /// Removes the described card from FirstData.
        /// </summary>
        /// <param name="cardRegisterRequest">
        /// Description of the card to remove.
        /// </param>
        /// <returns>
        /// The response from FirstData for the remove card attempt.
        /// </returns>
        public async Task <CardRegisterResponse> RemoveCard(CardRegisterRequest cardRegisterRequest)
        {
            CardRegisterResponse result;

            using (registrationserviceClient registrationClient = new registrationserviceClient("registrationserviceSoap12"))
            {
                Stopwatch sprocTimer = Stopwatch.StartNew();
//TODO: IF we decide to delete the card in First Data at all, re-enable the call to First Data.
//                      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 the above is done, add try/finally so that analytics info is added even for failures.
//
//TODO: If we decide not to delete the card in all partners, remove all relevant code and revert DeactivateCard to a synchronous op.
                CardRegisterResponse1 response1 = new CardRegisterResponse1()
                {
                    CardRegisterResponse = new CardRegisterResponse()
                    {
                        respCode = FirstDataResponseCode.RemoveCardFieldParseError,
                        respText = "No call to First Data was made. Cards are not currently deleted from First Data."
                    }
                };

                /*CardRegisterResponse1*/ if (response1 == null)
                {
                    response1 = await registrationClient.CardRegisterAsync(cardRegisterRequest);
                }
                sprocTimer.Stop();
                PerformanceInformation.Add("FirstData CardRegister (remove card)",
                                           String.Format("{0} ms", sprocTimer.ElapsedMilliseconds));
                result = response1.CardRegisterResponse;
            }

            return(result);
        }