public static Document ToMxMessage(PaymentMessage message) { var mxMessage = new Document { FIToFICstmrCdtTrf = new Transaction { GrpHdr = new GroupHeader { MsgId = message.MessageId, CreDtTm = message.CreatedDate.ToString(), NbOfTxs = 1, IntrBkSttlmDt = message.SettlementDate.ToString(), TtlIntrBkSttlmAmt = message.Amount, SttlmInf = new SettlementInformation { ClrSys = new ClrSys { Prtry = message.ClearingSystemProprietaryPurpose }, SttlmMtd = message.SettlementMethod }, InstgAgt = new Agent { FinInstnId = new FinancialInstitutionId { BIC = message.InitiatorIdentification // "INGSMMXXX" } }, InstdAgt = new Agent { FinInstnId = new FinancialInstitutionId { BIC = message.SubjectIdentification // "BTRLRO22" } } }, CdtTrfTxInf = new CreditTransferTransactionInformation[] { new CreditTransferTransactionInformation { PmtId = new PaymentId { InstrId = message.TransactionId, // "PaymentID" EndToEndId = message.TransactionId, // "PaymentID" TxId = message.TransactionId // "PaymentID" }, PmtTpInf = new PaymentTypeInformation { SvcLvl = new ServiceLevel { Cd = message.ServiceLevel // "SEPA" } }, IntrBkSttlmAmt = message.Amount, // "1" ChrgBr = message.ChargeBearer, // "SLEV" Dbtr = new Party { Nm = message.InitiatorName, // "Jane Doe" PstlAdr = new PostalAddress { Ctry = message.InitiatorCountry // "ES" }, Id = new PartyId { OrgId = new OrganizationId { Othr = new OtherOrgId { Id = message.InitiatorOrganizationId // "GFA" } } } }, DbtrAcct = new PartyAccount { Id = new PartyAccountId { IBAN = message.InitiatorAccount // "RO10INGBCBN4EVKBNFJ8YNGT" } }, DbtrAgt = new PartyAgent { FinInstnId = new FinancialInstitutionId { BIC = message.InitiatorRouting // "CECAESMMXXX" } }, CdtrAgt = new PartyAgent { FinInstnId = new FinancialInstitutionId { BIC = message.SubjectRouting // "BTRLRO22" } }, Cdtr = new Party { Nm = message.SubjectName, // "John Doe" PstlAdr = new PostalAddress { Ctry = message.SubjectCountry // "ES" }, Id = new PartyId { OrgId = new OrganizationId { Othr = new OtherOrgId { Id = message.SubjectOrganizationId // "V94025590" } } } }, CdtrAcct = new PartyAccount { Id = new PartyAccountId { IBAN = message.SubjectAccount // "RO71BTRLV67M9G4XI3IEJ5D2" } }, RmtInf = new RemittanceInformation { Ustrd = message.Description // "Incoming Payment" } } } } }; return(mxMessage); }
/// <inheritdoc /> public async Task <ClaimPaymentContext> InitiateClaimPaymentAsync(ClaimPaymentRequest request) { // Loading claim var claim = await GetClaimAsync(request.ProjectId, request.ClaimId); // Checking access rights if (claim.PlayerUserId != CurrentUserId) { throw new NoAccessToProjectException(claim.Project, CurrentUserId); } PaymentType onlinePaymentType = claim.Project.ActivePaymentTypes.SingleOrDefault( pt => pt.TypeKind == PaymentTypeKind.Online); if (onlinePaymentType == null) { throw new OnlinePaymentsNotAvailable(claim.Project); } if (request.Money <= 0) { throw new PaymentException(claim.Project, $"Money amount must be positive integer"); } User user = await GetCurrentUser(); var message = new PaymentMessage { Amount = request.Money, Details = $"Билет (организационный взнос) участника на «{claim.Project.ProjectName}»", CustomerAccount = CurrentUserId.ToString(), CustomerEmail = user.Email, CustomerPhone = user.Extra?.PhoneNumber, CustomerComment = request.CommentText, PaymentMethod = PscbPaymentMethod.BankCards, SuccessUrl = _uriService.Get(new PaymentSuccessUrl(request.ProjectId, request.ClaimId)), FailUrl = _uriService.Get(new PaymentFailUrl(request.ProjectId, request.ClaimId)), Data = new PaymentMessageData { Receipt = new Receipt { CompanyEmail = User.OnlinePaymentVirtualUser, TaxSystem = TaxSystemType.SimplifiedIncomeOutcome, Items = new List <ReceiptItem> { new ReceiptItem { ObjectType = PaymentObjectType.Service, PaymentType = ItemPaymentType.FullPayment, Price = request.Money, Quantity = 1, TotalPrice = request.Money, VatType = VatSystemType.None, Name = claim.Project.ProjectName, } } } } }; // Creating request to bank PaymentRequestDescriptor result = await GetApi(request.ProjectId, request.ClaimId) .BuildPaymentRequestAsync( message, async() => (await AddPaymentCommentAsync(claim.CommentDiscussion, onlinePaymentType, request)) .CommentId .ToString() .PadLeft(10, '0') ); return(new ClaimPaymentContext { Accepted = true, RequestDescriptor = result }); }