コード例 #1
0
        public async Task <PaymentRecordModel> GetPaymentRecord(int id)
        {
            var payment = await _repository.GetPayment(id);

            if (payment == null)
            {
                throw new NotFoundException(nameof(Payment), id);
            }
            // if the paynent belongs to another merchant, this merchant shouldn't know it exists
            if (payment.MerchantId != GetCurrentUserId() && GetCurrentUserRole() != "admin")
            {
                throw new NotFoundException(nameof(Payment), id);
            }

            var paymentRecord = _mapper.Map <PaymentRecordModel>(payment);

            return(paymentRecord);
        }
コード例 #2
0
        public async Task <PaymentResponse> GetPaymentInformation(Guid paymentId)
        {
            var payment = _paymentsRepository.GetPayment(paymentId);

            return(payment == null ? null : new PaymentResponse
            {
                PaymentId = payment.UniqueId,
                PaymentDate = payment.DateCreated,
                Amount = payment.Amount,
                Currency = payment.Currency,
                CardMask = payment.Card.CardNumberMask,
                CardExpirationDate = $"{payment.Card.ExpireDateMonth}/{payment.Card.ExpireDateYear}",
                Status = payment.Status.ToApplicationPaymentStatus()
            });
        }