Example #1
0
        public async Task <MobilePayPaymentDetails> GetPayment(Guid paymentId)
        {
            try
            {
                var response = await _paymentsApi.PaymentsGET2Async(paymentId, null);

                return(new MobilePayPaymentDetails(response.Reference, response.RedirectUri,
                                                   response.PaymentId.ToString(), response.State.ToString()));
            }
            catch (ApiException <ErrorResponse> e)
            {
                var errorResponse = e.Result;
                Log.Error(
                    "MobilePay GetPayment failed with HTTP {StatusCode}. ErrorCode: {ErrorCode} Message: {Message} CorrelationId: {CorrelationId}",
                    e.StatusCode, errorResponse.Code, errorResponse.Message, errorResponse.CorrelationId);

                // FIXME Consider retry

                throw new MobilePayApiException(e.StatusCode, errorResponse.Message, errorResponse.Code);
            }
            catch (ApiException apiException)
            {
                LogMobilePayException(apiException);
                throw new MobilePayApiException(apiException.StatusCode, apiException.Message);
            }
        }