Exemplo n.º 1
0
 private static void PrepareBill(
     out CreateBillInfo createBillInfo,
     string value      = null,
     string currency   = null,
     string comment    = null,
     string email      = null,
     string account    = null,
     string phone      = null,
     string successUrl = null
     )
 {
     createBillInfo = new CreateBillInfo
     {
         BillId = Guid.NewGuid().ToString(),
         Amount = new MoneyAmount
         {
             ValueString    = value,
             CurrencyString = currency
         },
         Comment            = comment,
         ExpirationDateTime = BillPaymentsUtils.GetTimeoutDate(),
         Customer           = new Customer
         {
             Email   = email,
             Account = account,
             Phone   = phone
         },
         SuccessUrl = string.IsNullOrEmpty(successUrl) ? null : new Uri(successUrl)
     };
 }
        public void TestGetTimeoutDate(int offset, double?days = null)
        {
            var value = BillPaymentsUtils.GetTimeoutDate(days);

            Assert.IsTrue(DateTime.Now < value, "Timeout date in future");
            Assert.AreEqual(offset, (value - DateTime.Now).Days + 1, "Timeout date offset");
        }
        public void TestCheckNotificationSignature(
            string merchantSecret,
            string signature,
            string siteId   = null,
            string billId   = null,
            string value    = null,
            string currency = null,
            string status   = null
            )
        {
            var notification = new Notification
            {
                Bill = new Bill
                {
                    SiteId = siteId,
                    BillId = billId,
                    Amount = new MoneyAmount
                    {
                        ValueString    = value,
                        CurrencyString = currency
                    },
                    Status = new BillStatus
                    {
                        ValueString = status
                    }
                }
            };

            Assert.IsFalse(
                BillPaymentsUtils.CheckNotificationSignature("foo", notification, merchantSecret),
                "Invalid signature check fails"
                );
            Assert.IsTrue(
                BillPaymentsUtils.CheckNotificationSignature(signature, notification, merchantSecret),
                "Valid signature check success"
                );
        }
        public void TestFormatValue(string iValue, string oValue)
        {
            var value = BillPaymentsUtils.FormatValue(iValue);

            Assert.AreEqual(oValue, value, "Equal format value");
        }