public PaymentInfoDTO GetPaymentStatus(string authKey, int orderId) { using (var uow = UnitOfWorkFactory.CreateWithoutRoot($"[ADS] GetPaymentStatus method")) { PaymentInfoDTO result = new PaymentInfoDTO(orderId, PaymentStatus.None); if (!CheckAuth(uow, authKey)) { return(result); } ISmsPaymentService smsPaymentService = smsPaymentChannelFactory.CreateChannel(); if (smsPaymentService == null) { logger.Warn($"Невозможно получить статус платежа. {nameof(smsPaymentService)} is null"); return(result); } PaymentResult paymentResult = null; try { paymentResult = smsPaymentService.GetActualPaymentStatus(orderId); } catch (Exception ex) { logger.Error(ex); } if (paymentResult == null || paymentResult.Status == PaymentResult.MessageStatus.Error || paymentResult.PaymentStatus == null) { result.Status = PaymentStatus.None; return(result); } switch (paymentResult.PaymentStatus.Value) { case SmsPaymentStatus.WaitingForPayment: result.Status = PaymentStatus.WaitingForPayment; break; case SmsPaymentStatus.Paid: result.Status = PaymentStatus.Paid; break; case SmsPaymentStatus.Cancelled: result.Status = PaymentStatus.Cancelled; break; } return(result); } }
public PaymentResult SendSmsPaymentToNumber(int orderId, string phoneNumber) { ISmsPaymentService service = SmsPaymentServiceSetting.GetSmsmPaymentServite(); if (service == null) { return(new PaymentResult { ErrorDescription = "Сервис отправки Sms не работает, обратитесь в РПО." }); } string realPhoneNumber = "8" + PhoneUtils.RemoveNonDigit(phoneNumber); return(service.SendPayment(orderId, realPhoneNumber)); }
public PaymentInfoDTO CreateOrderPayment(string authKey, int orderId, string phoneNumber) { ISmsPaymentService smsPaymentService = smsPaymentChannelFactory.CreateChannel(); if (smsPaymentService == null) { logger.Warn($"Невозможно создать платеж для заказа {orderId}. {nameof(smsPaymentService)} is null"); return(new PaymentInfoDTO(orderId, PaymentStatus.None)); } PaymentResult paymentResult = smsPaymentService.SendPayment(orderId, phoneNumber); if (paymentResult == null || paymentResult.Status == PaymentResult.MessageStatus.Error) { return(new PaymentInfoDTO(orderId, PaymentStatus.None)); } if (paymentResult.PaymentStatus == null) { return(new PaymentInfoDTO(orderId, PaymentStatus.None)); } else { switch (paymentResult.PaymentStatus.Value) { case SmsPaymentStatus.WaitingForPayment: return(new PaymentInfoDTO(orderId, PaymentStatus.WaitingForPayment)); case SmsPaymentStatus.Paid: return(new PaymentInfoDTO(orderId, PaymentStatus.Paid)); case SmsPaymentStatus.Cancelled: return(new PaymentInfoDTO(orderId, PaymentStatus.Cancelled)); default: return(new PaymentInfoDTO(orderId, PaymentStatus.None)); } } }
public CachePaymentsWorker(SmsPaymentFileCache smsPaymentFileCache, ISmsPaymentService smsPaymentService) { this.smsPaymentFileCache = smsPaymentFileCache ?? throw new ArgumentNullException(nameof(smsPaymentFileCache)); this.smsPaymentService = smsPaymentService ?? throw new ArgumentNullException(nameof(smsPaymentService)); }