public WmExchangerVendor()
 {
     wmid        = WmId.Parse("320508520783");
     key         = new KeeperKey("<RSAKeyValue><Modulus>pV4KSuF3Tb7KrHeB+Mng4tRp14nw1HjuM/pBqa/YikNM7HBtwJaL9hUE5nZrcge8qjVU60jJyzPTPxEaenverjUM</Modulus><D>5bBcUTgYAzswW48F4eV6QpmscTKTBYvxasFem+NM+mlR2de+G5BO387ziYab09BtUypQKVYbJL9bewyqDqNufd8E</D></RSAKeyValue>");
     initializer = new Initializer(wmid, key);
 }
        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);
        }
Пример #3
0
        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));
        }