예제 #1
0
        /// <summary>
        /// Deactivate payment method
        /// </summary>
        /// <param name="siteUserGuid">Siteuserguid</param>
        /// <param name="card">card to deactivate</param>
        /// <returns>statuscode and carddata</returns>
        public ApiResponse <PaymentMethods> DeactivatePaymentMethodCustomer(int siteUserGuid, Card card)
        {
            var myClassname = MethodBase.GetCurrentMethod().Name;
            var config      = this.GetDefaultApiConfiguration();
            var api         = new CustomerApi(config);

            for (var i = 0; i <= MaxNoOfRetries; i++)
            {
                try
                {
                    var res = api.InactivatePaymentMethodWithHttpInfo(siteUserGuid.ToString(), card.Id);
                    if (res.StatusCode != (int)HttpStatusCode.OK)
                    {
                        this._log.Error($"Unexpected answer from reepay. {myClassname} Errorcode {res.StatusCode}");
                    }

                    return(res);
                }
                catch (ApiException apiException)
                {
                    this._log.Error($"{myClassname} {apiException.ErrorCode} {apiException.ErrorContent}");
                    return(new ApiResponse <PaymentMethods>(apiException.ErrorCode, null, null));
                }
                catch (Exception) when(i < MaxNoOfRetries)
                {
                    this._log.Debug($"{myClassname} retry attempt {i}");
                }
            }

            return(new ApiResponse <PaymentMethods>((int)HttpStatusCode.InternalServerError, null, null));
        }