Skip to content

Commit

Permalink
Fix Bot Framework Payments Sample to generate receipt cards that have…
Browse files Browse the repository at this point in the history
… sales tax and shipping as facts instead of line items (microsoft#161)
  • Loading branch information
XinGao authored and msft-shahins committed Aug 16, 2017
1 parent 729fab7 commit f122076
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions CSharp/sample-payments/PaymentsBot/Dialogs/RootDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ private static async Task<Attachment> BuildReceiptCardAsync(PaymentRecord paymen

var receiptItems = new List<ReceiptItem>();

var facts = new List<Fact>
{
new Fact(Resources.RootDialog_Receipt_OrderID, paymentRecord.OrderId.ToString()),
new Fact(Resources.RootDialog_Receipt_PaymentMethod, paymentRecord.MethodName),
new Fact(Resources.RootDialog_Shipping_Address, paymentRecord.ShippingAddress.FullInline()),
new Fact(Resources.RootDialog_Shipping_Option, shippingOption != null ? shippingOption.Label : "N/A")
};

receiptItems.AddRange(paymentRecord.Items.Select<PaymentItem, ReceiptItem>(item =>
{
if (catalogItem.Title.Equals(item.Label))
Expand All @@ -181,24 +189,16 @@ private static async Task<Attachment> BuildReceiptCardAsync(PaymentRecord paymen
}
else
{
return RootDialog.BuildReceiptItem(
item.Label,
null,
$"{item.Amount.Currency} {item.Amount.Value}",
null);
facts.Add(new Fact(item.Label, $"{item.Amount.Currency} {item.Amount.Value}"));
return null;
}
}));
})
.Where(item => item != null));

var receiptCard = new ReceiptCard
{
Title = Resources.RootDialog_Receipt_Title,
Facts = new List<Fact>
{
new Fact(Resources.RootDialog_Receipt_OrderID, paymentRecord.OrderId.ToString()),
new Fact(Resources.RootDialog_Receipt_PaymentMethod, paymentRecord.MethodName),
new Fact(Resources.RootDialog_Shipping_Address, paymentRecord.ShippingAddress.FullInline()),
new Fact(Resources.RootDialog_Shipping_Option, shippingOption != null ? shippingOption.Label : "N/A")
},
Facts = facts,
Items = receiptItems,
Tax = null, // Sales Tax is a displayed line item, leave this blank
Total = $"{paymentRecord.Total.Amount.Currency} {paymentRecord.Total.Amount.Value}"
Expand Down

0 comments on commit f122076

Please sign in to comment.