public IMerchantPayment FindPayment(string purse, long number, Contracts.BasicTypes.PaymentNumberKind numberKind) { if (null == purse) { throw new ArgumentNullException(nameof(purse)); } var request = new MerchantOperationObtainer(Purse.Parse(purse), number, ConvertFrom.ContractTypeToApiType(numberKind)) { Initializer = CreateInitializer(purse) }; MerchantOperation response; try { response = request.Submit(); } catch (WmException exception) { throw new ExternalServiceException(exception.Message, exception); } var merchantPayment = new MerchantPayment(response.TransferId, response.InvoiceId, response.Amount, response.CreateTime.ToUniversalTime(), response.Description, response.SourceWmId, response.SourcePurse.ToString()) { IsCapitaller = response.CapitallerFlag, IsEnum = response.EnumFlag, IPAddress = response.IpAddress, TelepatPhone = response.TelepatPhone, PaymerNumber = response.PaymerNumber, PaymerEmail = response.PaymerEmail, CashierNumber = response.CashierNumber, CashierDate = response.CashierDate?.ToUniversalTime(), CashierAmount = response.CashierAmount, }; if (null != response.TelepatMethod) { merchantPayment.TelepatMethod = ConvertFrom.ApiTypeToContractType(response.TelepatMethod.Value); } if (XmlInterfaces.BasicObjects.PaymerType.None != response.PaymerType) { merchantPayment.PaymerType = ConvertFrom.ApiTypeToContractType(response.PaymerType); } // TODO [L] Расшифровать тип e-invoicing платежа. if (null != response.SdpType) { merchantPayment.InvoicingMethod = (byte)response.SdpType.Value; } return(merchantPayment); }
public ITrustConfirmationInstruction RequestTrust(IOriginalExpressTrust originalExpressTrust) { if (null == originalExpressTrust) { throw new ArgumentNullException(nameof(originalExpressTrust)); } XmlInterfaces.BasicObjects.ConfirmationType confirmationType = ConvertFrom.ContractTypeToApiType(originalExpressTrust.ConfirmationType); ExpressTrustRequest request; switch (originalExpressTrust.Identifier.Type) { case ExtendedIdentifierType.Phone: var phone = originalExpressTrust.Identifier.Value; if (!phone.StartsWith("+")) { phone = $"+{phone}"; } request = new ExpressTrustRequest(Purse.Parse(originalExpressTrust.StorePurse), (Amount)originalExpressTrust.DayLimit, (Amount)originalExpressTrust.WeekLimit, (Amount)originalExpressTrust.MonthLimit, Phone.Parse(phone), confirmationType); break; case ExtendedIdentifierType.WmId: request = new ExpressTrustRequest(Purse.Parse(originalExpressTrust.StorePurse), (Amount)originalExpressTrust.DayLimit, (Amount)originalExpressTrust.WeekLimit, (Amount)originalExpressTrust.MonthLimit, WmId.Parse(originalExpressTrust.Identifier.Value), confirmationType); break; case ExtendedIdentifierType.Email: MailAddress mailAddress = new MailAddress(originalExpressTrust.Identifier.Value); request = new ExpressTrustRequest(Purse.Parse(originalExpressTrust.StorePurse), (Amount)originalExpressTrust.DayLimit, (Amount)originalExpressTrust.WeekLimit, (Amount)originalExpressTrust.MonthLimit, mailAddress, confirmationType); break; case ExtendedIdentifierType.Purse: request = new ExpressTrustRequest(Purse.Parse(originalExpressTrust.StorePurse), (Amount)originalExpressTrust.DayLimit, (Amount)originalExpressTrust.WeekLimit, (Amount)originalExpressTrust.MonthLimit, Purse.Parse(originalExpressTrust.Identifier.Value), confirmationType); break; default: throw new InvalidOperationException("originalExpressTrust.Identifier.Type == " + originalExpressTrust.Identifier.Type); } request.DayLimit = (Amount)originalExpressTrust.DayLimit; request.WeekLimit = (Amount)originalExpressTrust.WeekLimit; request.MonthLimit = (Amount)originalExpressTrust.MonthLimit; request.Initializer = Session.AuthenticationService.ObtainInitializer(); ExpressTrustResponse response; try { response = request.Submit(); } catch (WmException exception) { throw new ExternalServiceException(exception.Message, exception); } var instruction = new TrustConfirmationInstruction(response.Reference, ConvertFrom.ApiTypeToContractType(response.ConfirmationType), response.Info, response.SmsReference); return(instruction); }
public IPaymentConfirmationInstruction RequestPayment(IOriginalExpressPayment originalExpressPayment) { if (null == originalExpressPayment) { throw new ArgumentNullException(nameof(originalExpressPayment)); } ExpressPaymentRequest request; switch (originalExpressPayment.ExtendedIdentifier.Type) { case ExtendedIdentifierType.Phone: var phone = originalExpressPayment.ExtendedIdentifier.Value; if (!phone.StartsWith("+")) { phone = $"+{phone}"; } request = new ExpressPaymentRequest(Purse.Parse(originalExpressPayment.TargetPurse), originalExpressPayment.OrderId, (Amount)originalExpressPayment.Amount, (Description)originalExpressPayment.Description, Phone.Parse(phone), ConvertFrom.ContractTypeToApiType(originalExpressPayment.ConfirmationType)); break; case ExtendedIdentifierType.WmId: request = new ExpressPaymentRequest(Purse.Parse(originalExpressPayment.TargetPurse), originalExpressPayment.OrderId, (Amount)originalExpressPayment.Amount, (Description)originalExpressPayment.Description, WmId.Parse(originalExpressPayment.ExtendedIdentifier.Value), ConvertFrom.ContractTypeToApiType(originalExpressPayment.ConfirmationType)); break; case ExtendedIdentifierType.Email: request = new ExpressPaymentRequest(Purse.Parse(originalExpressPayment.TargetPurse), originalExpressPayment.OrderId, (Amount)originalExpressPayment.Amount, (Description)originalExpressPayment.Description, new MailAddress(originalExpressPayment.ExtendedIdentifier.Value), ConvertFrom.ContractTypeToApiType(originalExpressPayment.ConfirmationType)); break; default: throw new ArgumentOutOfRangeException(); } request.Initializer = CreateInitializer(originalExpressPayment.TargetPurse, true); ExpressPaymentResponse response; try { response = request.Submit(); } catch (WmException exception) { throw new ExternalServiceException(exception.Message, exception); } return(new PaymentConfirmationInstruction(response.InvoiceId, ConvertFrom.ApiTypeToContractType(response.ConfirmationType), response.Info)); }