本文整理汇总了C#中Invoice.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Invoice.Save方法的具体用法?C# Invoice.Save怎么用?C# Invoice.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invoice
的用法示例。
在下文中一共展示了Invoice.Save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvoiceCustomData
public void InvoiceCustomData()
{
var inv = new Invoice
{
Amount = 3,
Currency = "RUB",
};
inv.CustomData["sixteen"] = "being tested";
inv.CustomData["bool"] = false;
inv.CustomData["int"] = 42;
inv.CustomData["decimal"] = 42.5m;
inv.Save();
var inv2 = Invoice.Get(inv.Id);
Assert.AreEqual(inv.ToString(), inv2.ToString());
Assert.AreEqual(42.5m, inv2.CustomData.Value<decimal>("decimal"));
inv.CustomData = JObject.Parse("{\"int\": 9000}");
inv.Save();
Assert.AreEqual(9000, inv.CustomData.Value<int>("int"));
}
示例2: InvoiceDelete
public void InvoiceDelete()
{
var inv = new Invoice
{
Amount = 1,
Currency = "rub",
};
Assert.False(inv.Deleted);
inv.Save();
Assert.AreEqual(inv.Currency, "RUB");
Assert.False(inv.Deleted);
inv.Delete();
Assert.True(inv.Deleted);
inv.Undelete();
Assert.False(inv.Deleted);
inv.Deleted = true;
inv.Save();
Assert.True(inv.Deleted);
}
示例3: InvoiceCreate
public void InvoiceCreate()
{
var inv = new Invoice();
Assert.Null(inv.Account);
Assert.True(inv.Amount == 0);
Assert.True(inv.AmountPaid == 0);
Assert.Null(inv.Currency);
Assert.Null(inv.Customer);
Assert.Null(inv.Description);
Assert.Null(inv.Created);
Assert.Null(inv.Modified);
Assert.Null(inv.Expires);
Assert.Null(inv.TestMode);
Assert.Null(inv.Reference);
inv.Amount = 42.9m;
inv.Currency = "RUB";
inv.Customer = "Посвящаю эту песню Ринату";
inv.Description = "Test invoice ®";
inv.Save();
Assert.AreEqual("acc_111tov4zxNTQObb3", inv.Account);
Assert.AreEqual(42.9m, inv.Amount);
Assert.AreEqual(0, inv.AmountPaid);
Assert.AreEqual("RUB", inv.Currency);
Assert.AreEqual("Посвящаю эту песню Ринату", inv.Customer);
Assert.AreEqual("Test invoice ®", inv.Description);
Assert.That(inv.Created, Is.EqualTo(DateTime.UtcNow).Within(5).Minutes);
Assert.That(inv.Modified, Is.EqualTo(DateTime.UtcNow).Within(5).Minutes);
Assert.AreEqual("", inv.Reference);
Assert.Null(inv.Expires);
Assert.AreEqual(false, inv.TestMode);
var inv2 = Invoice.Get(inv.Id);
Assert.AreEqual(inv.ToString(), inv2.ToString());
}
示例4: ReadInvoice
internal void ReadInvoice(string editext) {
List<Invoice> invoices = new List<Invoice>();
List<InvoiceItem> items = new List<InvoiceItem>();
List<InvoiceCode> codes = new List<InvoiceCode>();
Dictionary<string, string> itdcodes = new Dictionary<string, string>();
itdcodes.Add("01", "Basic");
itdcodes.Add("02", "End of Month");
itdcodes.Add("03", "Fixed Date");
itdcodes.Add("04", "Def. or installment");
itdcodes.Add("05", "Discount N/A");
itdcodes.Add("08", "Basic disc. offered");
itdcodes.Add("09", "Proximo");
itdcodes.Add("12", "10 days after EOM");
itdcodes.Add("14", "Previously agreed");
itdcodes.Add("17", "Terms N/A");
itdcodes.Add("ZZ", "Mutually Defined");
Invoice inv = new Invoice();
InvoiceAddress address = new InvoiceAddress();
char billorship = 'b';
List<string> edilines = editext.Split('~').ToList<string>();
foreach (string line in edilines) {
List<string> lineelements = line.Split('*').ToList<string>();
switch (lineelements[0]) {
case "ST":
// Beginning of invoice
inv = new Invoice();
items = new List<InvoiceItem>();
codes = new List<InvoiceCode>();
break;
case "BIG":
// Beginning statement
string dt = lineelements[1].Substring(4, 2) + "-" + lineelements[1].Substring(6, 2) + "-" + lineelements[1].Substring(0, 4);
inv.dateAdded = Convert.ToDateTime(dt);
inv.number = lineelements[2];
inv.orderID = lineelements[4];
switch (lineelements[7]) {
case "CN":
inv.invoiceType = "Credit Invoice";
break;
case "DI":
inv.invoiceType = "Debit Invoice";
break;
case "ZZ":
inv.invoiceType = "Mutually Defined";
break;
}
break;
case "CUR":
inv.billToCurrency = lineelements[2];
break;
case "REF":
inv.curtOrder = Convert.ToInt32(lineelements[2].Trim());
break;
case "N1":
switch (lineelements[1]) {
case "RI":
inv.remitTo = lineelements[4];
break;
case "BT":
billorship = 'b';
address = new InvoiceAddress();
string[] namesplit = lineelements[2].Split(' ');
address.first = namesplit[0];
try {
address.last = namesplit[1];
} catch {
address.last = "";
}
break;
case "ST":
billorship = 's';
address = new InvoiceAddress();
namesplit = lineelements[2].Split(' ');
address.first = namesplit[0];
try {
address.last = namesplit[1];
} catch {
address.last = "";
}
break;
}
break;
case "N2":
break;
case "N3":
address.street1 = lineelements[1];
try {
address.street2 = lineelements[2];
} catch {
address.street2 = "";
}
break;
case "N4":
address.city = lineelements[1];
address.state = lineelements[2];
address.postal_code = lineelements[3];
address.MatchOrSave();
//.........这里部分代码省略.........
示例5: InvoiceDifferentApiKeys
public void InvoiceDifferentApiKeys()
{
var inv = new Invoice
{
Amount = 4.42m,
Currency = "RUB",
};
Assert.True(string.IsNullOrEmpty(inv.ApiKey));
inv.Save();
Assert.AreEqual(Config.ApiKey, inv.ApiKey);
var originalKey = Config.ApiKey;
var anotherKey = "xmc2h3UXvzYJrwS4D4ZFFEnH";
var inv2 = new Invoice
{
Amount = 49,
Currency = "RUB",
};
Assert.Null(inv2.ApiKey);
try
{
Config.ApiKey = anotherKey;
inv2.Save();
Assert.AreEqual(anotherKey, inv2.ApiKey);
inv.Reload();
Assert.AreEqual(originalKey, inv.ApiKey);
}
finally
{
Config.ApiKey = null; // When null, effective value will be taken from App.config
}
inv2.Reload();
Assert.AreEqual(anotherKey, inv2.ApiKey);
// This should throw NotFoundException, since we're using key from another account
inv2.ApiKey = originalKey;
inv2.Reload();
}
示例6: InvoiceExpiresSwitchMonthDay
public void InvoiceExpiresSwitchMonthDay()
{
var d = new DateTime(2050,10,5);
var inv = new Invoice
{
Amount = 43,
Currency = "RUB",
Expires = d
};
inv.Save();
var expires = inv.Expires;
inv.Save();
Assert.AreEqual(inv.Expires, expires);
var inv2 = Invoice.Get(inv.Id);
Assert.AreEqual(expires, inv2.Expires);
}
示例7: InvoiceExpires
public void InvoiceExpires()
{
var d = DateTime.UtcNow;
// Truncate milliseconds
d = d.AddTicks(-(d.Ticks % TimeSpan.TicksPerSecond));
// Set expiration date and verify that it is set
var inv = new Invoice
{
Amount = 9000,
Currency = "RUB",
Expires = d
};
inv.Save();
var inv2 = Invoice.Get(inv.Id);
Assert.AreEqual(inv.Expires, d);
Assert.AreEqual(inv.Expires, inv2.Expires);
// Now clear and verify that it is cleared
inv.Expires = null;
inv.Save();
inv2.Reload();
Assert.Null(inv2.Expires);
}