private Form GetForm(SessionContext context, string accountNumber) { if (null == context) { throw new ArgumentNullException(nameof(context)); } var template = TemplateLoader.LoadSubmitFormTemplate(context.ExtensionManager, ExtensionCatalog.TakeTrust); var origin = new AccountDropDownListOrigin(context.UnityContainer) { Source = AccountSource.MasterIdentifier }; origin.FilterCriteria.CurrencyCapabilities = CurrencyCapabilities.Transfer; if (null != accountNumber) { origin.SelectedAccountNumber = accountNumber; } var itemTemplates = AccountDisplayHelper.BuildAccountDropDownListItemTemplates(origin); var step1TemplateWrapper = new TakeTrustFormTemplateWrapper.Step1(template); step1TemplateWrapper.Control1StorePurse.Items.Clear(); step1TemplateWrapper.Control1StorePurse.Items.AddRange(itemTemplates); var form = new SubmitForm(); ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, form); form.ApplyTemplate(template); form.ServiceCommand += (sender, args) => { if (TakeTrustFormValuesWrapper.Step1.Control7WMIDCommandFindPassport.Equals(args.Command)) { var identifierValue = (string)args.Argument; IdentifierDisplayHelper.ShowFindCertificateForm(form, context, identifierValue); return; } if (TakeTrustFormValuesWrapper.Step2.Control4SmsReferenceCommandGoTo.Equals(args.Command)) { Process.Start((string)args.Argument); } }; form.WorkCallback = (step, list) => { var trustService = context.UnityContainer.Resolve <ITrustService>(); switch (step) { case 0: var step1ValuesWrapper = new TakeTrustFormValuesWrapper.Step1(list); ExtendedIdentifier extendedIdentifier; switch (step1ValuesWrapper.Control5IdentifierType) { case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValueWmid: extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.WmId, step1ValuesWrapper.Control7WMID); break; case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValuePhone: extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.Phone, step1ValuesWrapper.Control6Phone); break; case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValueEmail: extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.Email, step1ValuesWrapper.Control8Email); break; default: throw new InvalidOperationException( "step1ValuesWrapper.Control5IdentifierType == " + step1ValuesWrapper.Control5IdentifierType); } var originalExpressTrust = new OriginalExpressTrust(step1ValuesWrapper.Control1StorePurse, extendedIdentifier); originalExpressTrust.DayLimit = step1ValuesWrapper.Control2DailyAmountLimit; originalExpressTrust.WeekLimit = step1ValuesWrapper.Control3WeeklyAmountLimit; originalExpressTrust.MonthLimit = step1ValuesWrapper.Control4MonthlyAmountLimit; var trustConfirmationInstruction = trustService.RequestTrust(originalExpressTrust); var step2IncomeValuesWrapper = new TakeTrustFormValuesWrapper.Step2 { Control1RequestNumber = trustConfirmationInstruction.Reference.ToString(), Control2Message = trustConfirmationInstruction.PublicMessage ?? string.Empty, Control4SmsReference = !string.IsNullOrEmpty(trustConfirmationInstruction.SmsReference) ? string.Format(CultureInfo.InvariantCulture, CheckSmsStateUrlTemplate, trustConfirmationInstruction.SmsReference) : string.Empty }; return(step2IncomeValuesWrapper.CollectIncomeValues()); case 1: var step2ValuesWrapper = new TakeTrustFormValuesWrapper.Step2(list); var trustConfirmation = new TrustConfirmation(int.Parse(step2ValuesWrapper.Control1RequestNumber), step2ValuesWrapper.Control5Code); trustService.ConfirmTrust(trustConfirmation); break; } return(new Dictionary <string, object>()); }; return(form); }
public Form GetForm(PurseContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } var template = TemplateLoader.LoadSubmitFormTemplate(context.ExtensionManager, ExtensionCatalog.TakePayment); var origin = new AccountDropDownListOrigin(context.UnityContainer) { SelectedAccountNumber = context.Account.Number }; origin.FilterCriteria.CurrencyCapabilities = CurrencyCapabilities.Transfer; var itemTemplates = AccountDisplayHelper.BuildAccountDropDownListItemTemplates(origin); var step1TemplateWrapper = new TakePaymentFormTemplateWrapper.Step1(template); step1TemplateWrapper.Control2StorePurse.Items.Clear(); step1TemplateWrapper.Control2StorePurse.Items.AddRange(itemTemplates); var form = new SubmitForm(); ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, form); var incomeValuesWrapper = new TakePaymentFormValuesWrapper.Step1 { Control2OrderId = context.Session.SettingsService.AllocateOrderId() }; form.ApplyTemplate(template, incomeValuesWrapper.CollectIncomeValues()); form.ServiceCommand += (sender, args) => { if (!TakePaymentFormValuesWrapper.Step1.Control5WMIDCommandFindPassport.Equals(args.Command)) { return; } var identifierValue = (string)args.Argument; IdentifierDisplayHelper.ShowFindCertificateForm(form, context, identifierValue); }; long invoiceId = 0; string purse = ""; form.WorkCallback = (step, list) => { var paymentService = context.UnityContainer.Resolve <IPaymentService>(); switch (step) { case 0: var step1ValuesWrapper = new TakePaymentFormValuesWrapper.Step1(list); ExtendedIdentifier extendedIdentifier; switch (step1ValuesWrapper.Control3IdentifierType) { case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValueWmid: extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.WmId, step1ValuesWrapper.Control5WMID); break; case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValuePhone: extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.Phone, step1ValuesWrapper.Control4Phone); break; case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValueEmail: extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.Email, step1ValuesWrapper.Control6Email); break; default: throw new InvalidOperationException( "step1ValuesWrapper.Control3IdentifierType == " + step1ValuesWrapper.Control3IdentifierType); } var originalExpressPayment = new OriginalExpressPayment(step1ValuesWrapper.Control2OrderId, step1ValuesWrapper.Control1StorePurse, step1ValuesWrapper.Control7PaymentAmount, step1ValuesWrapper.Control9Description, extendedIdentifier); originalExpressPayment.ConfirmationType = (ConfirmationType)Enum.Parse(typeof(ConfirmationType), step1ValuesWrapper.Control8ConfirmationType); purse = originalExpressPayment.TargetPurse; var confirmationInstruction = paymentService.RequestPayment(originalExpressPayment); invoiceId = confirmationInstruction.InvoiceId; var step2IncomeValuesWrapper = new TakePaymentFormValuesWrapper.Step2(); step2IncomeValuesWrapper.Control1InvoiceId = confirmationInstruction.InvoiceId.ToString(); step2IncomeValuesWrapper.Control2Message = confirmationInstruction.PublicMessage ?? string.Empty; return(step2IncomeValuesWrapper.CollectIncomeValues()); case 1: var step2ValuesWrapper = new TakePaymentFormValuesWrapper.Step2(list); var paymentConfirmation = new PaymentConfirmation(purse, invoiceId) { ConfirmationCode = step2ValuesWrapper.Control4CancelInvoice ? "-1" : step2ValuesWrapper.Control3Code }; paymentService.ConfirmPayment(paymentConfirmation); break; default: throw new InvalidOperationException("step == " + step); } return(new Dictionary <string, object>()); }; return(form); }