示例#1
0
 private static string CreateSimpleRequestData(Invoice invoice, MellatGatewayAccount account)
 {
     return
         ("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:int=\"http://interfaces.core.sw.bps.com/\">" +
          "<soapenv:Header/>" +
          "<soapenv:Body>" +
          "<int:bpPayRequest>" +
          $"<terminalId>{account.TerminalId}</terminalId>" +
          "<!--Optional:-->" +
          $"<userName>{account.UserName}</userName>" +
          "<!--Optional:-->" +
          $"<userPassword>{account.UserPassword}</userPassword>" +
          $"<orderId>{invoice.TrackingNumber}</orderId>" +
          $"<amount>{(long)invoice.Amount}</amount>" +
          "<!--Optional:-->" +
          $"<localDate>{DateTime.Now:yyyyMMdd}</localDate>" +
          "<!--Optional:-->" +
          $"<localTime>{DateTime.Now:HHmmss}</localTime>" +
          "<!--Optional:-->" +
          "<additionalData></additionalData>" +
          "<!--Optional:-->" +
          $"<callBackUrl>{invoice.CallbackUrl}</callBackUrl>" +
          "<payerId>0</payerId>" +
          "'</int:bpPayRequest>" +
          "</soapenv:Body>" +
          "</soapenv:Envelope>");
 }
示例#2
0
        public static string CreateRequestData(Invoice invoice, MellatGatewayAccount account)
        {
            if (invoice.AdditionalData == null || !invoice.AdditionalData.ContainsKey(CumulativeAccountsKey))
            {
                return(CreateSimpleRequestData(invoice, account));
            }

            return(CreateCumulativeRequestData(invoice, account));
        }
示例#3
0
        private static string CreateCumulativeRequestData(Invoice invoice, MellatGatewayAccount account)
        {
            var cumulativeAccounts = (IList <MellatCumulativeDynamicAccount>)invoice.AdditionalData[CumulativeAccountsKey];

            if (cumulativeAccounts.Count > 10)
            {
                throw new Exception("Cannot use more than 10 accounts for each Cumulative payment request.");
            }

            //var totalAmount = cumulativeAccounts.Sum(cumulativeAccount => cumulativeAccount.Amount);

            //if (totalAmount != invoice.Amount)
            //{
            //    throw new Exception("The total amount of Mellat Cumulative accounts is not equals to the amount of the invoice." +
            //                        $"Invoice amount: {invoice.Amount}." +
            //                        $"Accounts total amount: {totalAmount}");
            //}

            var additionalData = cumulativeAccounts.Aggregate("", (current, cumulativeAccount) => current + $"{cumulativeAccount};");

            return
                ("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:int=\"http://interfaces.core.sw.bps.com/\">" +
                 "<soapenv:Header/>" +
                 "<soapenv:Body>" +
                 "<int:bpCumulativeDynamicPayRequest>" +
                 $"<terminalId>{account.TerminalId}</terminalId>" +
                 "<!--Optional:-->" +
                 $"<userName>{account.UserName}</userName>" +
                 "<!--Optional:-->" +
                 $"<userPassword>{account.UserPassword}</userPassword>" +
                 $"<orderId>{invoice.TrackingNumber}</orderId>" +
                 $"<amount>{(long)invoice.Amount}</amount>" +
                 "<!--Optional:-->" +
                 $"<localDate>{DateTime.Now:yyyyMMdd}</localDate>" +
                 "<!--Optional:-->" +
                 $"<localTime>{DateTime.Now:HHmmss}</localTime>" +
                 "<!--Optional:-->" +
                 $"<additionalData>{additionalData}</additionalData>" +
                 "<!--Optional:-->" +
                 $"<callBackUrl>{invoice.CallbackUrl}</callBackUrl>" +
                 "</int:bpCumulativeDynamicPayRequest>" +
                 "</soapenv:Body>" +
                 "</soapenv:Envelope>");
        }
示例#4
0
 public static string CreateRefundData(InvoiceContext context, MellatGatewayAccount account)
 {
     return
         ("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:int=\"http://interfaces.core.sw.bps.com/\">" +
          "<soapenv:Header/>" +
          "<soapenv:Body>" +
          "<int:bpReversalRequest>" +
          $"<terminalId>{account.TerminalId}</terminalId>" +
          "<!--Optional:-->" +
          $"<userName>{account.UserName}</userName>" +
          "<!--Optional:-->" +
          $"<userPassword>{account.UserPassword}</userPassword>" +
          $"<orderId>{context.Payment.TrackingNumber}</orderId>" +
          $"<saleOrderId>{context.Payment.TrackingNumber}</saleOrderId>" +
          $"<saleReferenceId>{context.Payment.TransactionCode}</saleReferenceId>" +
          "</int:bpReversalRequest>" +
          "</soapenv:Body>" +
          "</soapenv:Envelope>");
 }