Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bot Framework Payments Sample to generate receipt cards that have sales tax and shipping as facts instead of line items #161

Merged
merged 1 commit into from
Aug 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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