在Receipt Card Bot Framework

时间:2018-06-08 11:09:20

标签: asp.net botframework bots

我正在尝试使用机器人框架C#实现收据卡,但它一直以美元显示货币。我试图将API端点托管的货币从$更改为我想要的货币,但货币仍然没有变化。知道什么是不对的吗?

CardAction pbv = new CardAction()
{
    Value = "Check Status",
    Type = "imBack" 
};

ReceiptCard plCard = new ReceiptCard()
{
    Title = "Little Live Fare",
    Items = new List<ReceiptItem>
    {
      new ReceiptItem("TRIP STATUS",subtitle:status, image: new CardImage(url: img_url)),
    },
    Total = "500.00",
    Tax = "0.00",
    Tap = pbv
};

我希望总计显示为 KES:200.00 ,而不是 $ 200.00 。 还是一样,可以自定义卡并省略税收显示在收据上吗?

1 个答案:

答案 0 :(得分:1)

在收据卡中有一个Facts属性List<Fact>,在这些事实中您可以设置货币类型。货币类型似乎遵循ISO 4217 Standard您还可以找到corresponding symbols

Facts = new List<Fact>
{
    new Fact("currency", "KES")
}

我将在下面向您展示我正在使用的代码,但这是它分别在slack和facebook上呈现的方式:

Facebook的:

FaceBook Receipt Card

松弛:

Slack Receipt Card

我也可以通过不包含税收参数来排除税收,如下面的代码所示:

        Activity reply = activity.CreateReply();
        reply.Attachments = new List<Attachment>();
        var receiptCard = new ReceiptCard
        {
            Title = "John Doe",
            Facts = new List<Fact>
            {
                new Fact("Order Number", "1234"),
                new Fact("Payment Method", "VISA 5555-****"),
                new Fact("currency", "KES")
            },
            Items = new List<ReceiptItem>
            {
                new ReceiptItem("Data Transfer", price: "KSh 38.45", quantity: "368", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/traffic-manager.png")),
                new ReceiptItem("App Service", price: "KSh 45.00", quantity: "720", image: new CardImage(url: "https://github.com/amido/azure-vector-icons/raw/master/renders/cloud-service.png")),
            },
            Total = "90.95",
            Buttons = new List<CardAction>
            {
                new CardAction(
                    ActionTypes.OpenUrl,
                    "More information",
                    "https://account.windowsazure.com/content/6.10.1.38-.8225.160809-1618/aux-pre/images/offer-icon-freetrial.png",
                    "https://azure.microsoft.com/en-us/pricing/")
            }
        };
        reply.Attachments.Add(receiptCard.ToAttachment());
        await context.PostAsync(reply);