String createAppDataForExportOperation(ExchangeContext ctx) { ExportData exportData = new ExportData(); DataRequest dataRequest = new DataRequest(); Date startDate = (Date) ctx.getVariable("startDate"); if (startDate != null) { dataRequest.setStartDate( XmlTypes.dateTimeAndZeroMilliseconds(formatDate(startDate, "dd.MM.yyyy HH:mm:ss"))); } Date endDate = (Date) ctx.getVariable("endDate"); if (endDate != null) { dataRequest.setEndDate( XmlTypes.dateTimeAndZeroMilliseconds(formatDate(endDate, "dd.MM.yyyy HH:mm:ss"))); } exportData.setDataRequest(dataRequest); dataRequest.setKind((String) ctx.getVariable("exportRequestType")); String postBlockSenderIdentifier = (String) ctx.getVariable("postBlockSenderIdentifier"); final PostBlock postBlock = createPostBlock(ctx, postBlockSenderIdentifier); dataRequest.setPostBlock(postBlock); fillSupplierBillIds(ctx, dataRequest); fillApplicationIds(ctx, dataRequest); fillUnifiedPayerIds(ctx, dataRequest); return new XmlTypes(ExportData.class).toXml(exportData); }
private PostBlock createPostBlock(ExchangeContext ctx, String postBlockSenderIdentifier) { final PostBlock postBlock = new PostBlock(); String postBlockID = ctx.getVariable("postBlockId") == null ? UUID.randomUUID().toString() : (String) ctx.getVariable("postBlockId"); ctx.setVariable("postBlockId", postBlockID); postBlock.setID(postBlockID); // идентификатор запроса postBlock.setSenderIdentifier(postBlockSenderIdentifier); Date postBlockTimeStamp = ctx.getVariable("postBlockTimeStamp") != null ? (Date) ctx.getVariable("postBlockTimeStamp") : new Date(); postBlock.setTimeStamp( XmlTypes.dateTimeAndZeroMilliseconds( formatDate(postBlockTimeStamp, "dd.MM.yyyy HH:mm:ss"))); // дата составления запроса return postBlock; }
String createAppDataForImportChargeOperation(ExchangeContext ctx) throws Exception { ImportData importData = new ImportData(); final ImportRequest importRequest = new ImportRequest(); String postBlockSenderIdentifier = (String) ctx.getVariable("postBlockSenderIdentifier"); final PostBlock postBlock = createPostBlock(ctx, postBlockSenderIdentifier); importRequest.setPostBlock(postBlock); final ChargeType charge = new ChargeType(); importRequest.setCharge(charge); String ordinalNumber = (String) ctx.getVariable("ordinalNumber"); if (ordinalNumber == null || "".equals(ordinalNumber)) { ordinalNumber = formatDate(new Date(), "ddMMyyHHmmss"); } String supplierBillID = UINGenerator.generateChargeUIN(postBlockSenderIdentifier, ordinalNumber); ctx.setVariable("supplierBillID", supplierBillID); charge.setSupplierBillID(supplierBillID); // Уникальный идентификатор счёта в ИСП charge.setBillDate( XmlTypes.date( formatDate( (Date) ctx.getVariable("chargeBillDate"), "dd.MM.yyyy"))); // Дата выставления счёта final Organization supplierOrgInfo = new Organization(); supplierOrgInfo.setName((String) ctx.getVariable("supplierOrgInfoName")); supplierOrgInfo.setINN((String) ctx.getVariable("supplierOrgInfoINN")); supplierOrgInfo.setKPP((String) ctx.getVariable("supplierOrgInfoKPP")); final Account account = new Account(); account.setAccount((String) ctx.getVariable("accountAccount")); account.setKind((String) ctx.getVariable("accountKind")); final Bank bank = new Bank(); bank.setBIK((String) ctx.getVariable("bankBIK")); bank.setName((String) ctx.getVariable("bankName")); account.setBank(bank); supplierOrgInfo.setAccount(account); charge.setSupplierOrgInfo(supplierOrgInfo); charge.setBillFor((String) ctx.getVariable("chargeBillFor")); charge.setTotalAmount(toLong((String) ctx.getVariable("chargeTotalAmount"))); charge.setChangeStatus( (String) ctx.getVariable( "chargeChangeStatus")); /* Статус счёта 1 - новый 2 - изменение 3 - аннулирование */ charge.setTreasureBranch( (String) ctx.getVariable( "chargeTreasureBranch")); // Орган ФК, на счёт которого должны поступать средства // плательщика charge.setKBK((String) ctx.getVariable("chargeKBK")); charge.setOKATO((String) ctx.getVariable("chargeOKATO")); final BudgetIndex budgetIndex = new BudgetIndex(); budgetIndex.setStatus((String) ctx.getVariable("budgetIndexStatus")); // Статус плательщика budgetIndex.setPaymentType((String) ctx.getVariable("budgetPaymentType")); // тип платежа budgetIndex.setPurpose( (String) ctx.getVariable("budgetPurpose")); // основание платежа 2 символа максимум budgetIndex.setTaxPeriod( (String) ctx.getVariable("budgetTaxPeriod")); // налоговый период до 10 символов budgetIndex.setTaxDocNumber( (String) ctx.getVariable("budgetTaxDocNumber")); // Показатель номера документа budgetIndex.setTaxDocDate( (String) ctx.getVariable("budgetTaxDocDate")); // Показатель даты документа charge.setBudgetIndex(budgetIndex); if ("".equals(getStringFromContext(ctx, "chargeApplicationID", ""))) { String applicationID = String.valueOf(System.currentTimeMillis()); ctx.setVariable("chargeApplicationID", applicationID); charge.setApplicationID(applicationID); } else { charge.setApplicationID((String) ctx.getVariable("chargeApplicationID")); } String unifiedPayerIdentifier = buildUnifiedPayerID(ctx, ""); ctx.setVariable("unifiedPayerIdentifier", unifiedPayerIdentifier); charge.setUnifiedPayerIdentifier(unifiedPayerIdentifier); // единый идентификатор плательщика importData.setImportRequest(importRequest); String importDataStr = new XmlTypes(ImportData.class).toXml(importData); return cryptoProvider.signElement(importDataStr, "Charge", null, true, true, false); }
private String createAppDataForImportPaymentOperation(ExchangeContext ctx) throws Exception { ImportData importData = new ImportData(); final ImportRequest importRequest = new ImportRequest(); importData.setImportRequest(importRequest); String postBlockSenderIdentifier = (String) ctx.getVariable("postBlockSenderIdentifier"); final PostBlock postBlock = createPostBlock(ctx, postBlockSenderIdentifier); importRequest.setPostBlock(postBlock); PaymentInfoType paymentInfo = new PaymentInfoType(); importRequest.setFinalPayment(paymentInfo); paymentInfo.setNarrative(getStringFromContext(ctx, "paymentNarrative", "")); paymentInfo.setSupplierBillID(getStringFromContext(ctx, "paymentSupplierBillID", "")); paymentInfo.setAmount(toLong((String) ctx.getVariable("paymentAmount"))); paymentInfo.setPaymentDate( XmlTypes.date(formatDate((Date) ctx.getVariable("paymentDate"), "dd.MM.yyyy"))); paymentInfo.setChangeStatus(getStringFromContext(ctx, "paymentChangeStatus", "1")); paymentInfo.setPayeeINN(getStringFromContext(ctx, "paymentPayeeINN", "")); paymentInfo.setPayeeKPP(getStringFromContext(ctx, "paymentPayeeKPP", "")); paymentInfo.setKBK(getStringFromContext(ctx, "paymentKBK", "")); paymentInfo.setOKATO(getStringFromContext(ctx, "paymentOKATO", "")); paymentInfo.setPayerPA(getStringFromContext(ctx, "paymentPA", "")); Account payeeBankAcc = new Account(); paymentInfo.setPayeeBankAcc(payeeBankAcc); payeeBankAcc.setAccount(getStringFromContext(ctx, "paymentPayeeAccount", "")); payeeBankAcc.setKind(getStringFromContext(ctx, "paymentPayeeBankAccKind", "!")); Bank payeeBank = new Bank(); payeeBankAcc.setBank(payeeBank); payeeBank.setName(getStringFromContext(ctx, "paymentPayeeBankName", "")); payeeBank.setCorrespondentBankAccount( getStringFromContext(ctx, "paymentCorrespondentBankAccount", "")); payeeBank.setBIK(getStringFromContext(ctx, "paymentPayeeBankBIK", "")); PaymentIdentificationDataType paymentIdentificationData = new PaymentIdentificationDataType(); paymentInfo.setPaymentIdentificationData(paymentIdentificationData); Bank bank = new Bank(); paymentIdentificationData.setBank(bank); bank.setBIK(getStringFromContext(ctx, "paymentBIK", "")); bank.setName(getStringFromContext(ctx, "paymentBankName", "")); paymentIdentificationData.setSystemIdentifier( buildSystemIdentifierForImportPaymentOperation(ctx)); fillPaymentAdditionalData(paymentInfo, ctx); final BudgetIndex budgetIndex = new BudgetIndex(); paymentInfo.setBudgetIndex(budgetIndex); budgetIndex.setStatus(getStringFromContext(ctx, "Status", "0")); // Статус плательщика budgetIndex.setPaymentType(getStringFromContext(ctx, "PaymentType", "0")); // тип платежа budgetIndex.setPurpose( getStringFromContext(ctx, "Purpose", "0")); // основание платежа 2 символа максимум budgetIndex.setTaxPeriod( getStringFromContext(ctx, "TaxPeriod", "0")); // налоговый период до 10 символов budgetIndex.setTaxDocNumber( getStringFromContext(ctx, "TaxDocNumber", "0")); // Показатель номера документа budgetIndex.setTaxDocDate( getStringFromContext(ctx, "TaxDocDate", "0")); // Показатель даты документа paymentInfo.setPayerIdentifier(buildUnifiedPayerID(ctx, "")); String importDataStr = new XmlTypes(ImportData.class).toXml(importData); return cryptoProvider.signElement(importDataStr, "FinalPayment", null, true, true, false); }