Ejemplo n.º 1
0
        /// <summary>
        /// Get payment for customer
        /// </summary>
        /// <param name="siteUserGuid">siteuserGuid</param>
        /// <returns>statuscode and Customer data</returns>
        public ApiResponse <PaymentMethods> GetPaymentMethods(int siteUserGuid)
        {
            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.GetCustomerPaymentMethodsWithHttpInfo(siteUserGuid.ToString());
                    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));
        }