自适应卡:付款请求
Adaptive Cards: Payment Request
我目前正在开发一个机器人项目,我正在尝试利用 Microsoft 自适应卡向用户发送 PaymentRequest。我创建了一个虚拟 paymentrequest 对象并将其插入到 Hero 卡中,如文档所述。
var methodList = new List<PaymentMethodData>();
var method = new PaymentMethodData()
{Data = new {supportedNetworks = new[] { "visa", "mastercard", "amex", "discover", "diners", "jcb", "unionpay"} }, SupportedMethods = new[] { "https://bobpay.xyz/pay" } };
methodList.Add(method);
var details = new PaymentDetails {};
var test = new PaymentRequest(null, methodList, details);
var heroCard = new HeroCard
{
Title = "Bob",
Subtitle = "The Builder",
Text = "Kunnen wij het maken!",
Images = new List<CardImage>
{
new CardImage
{
Url = "https://m.media-amazon.com/images/M/MV5BNjRlYjgwMWMtNDFmMy00OWQ0LWFhMTMtNWE3MTU4ZjQ3MjgyXkEyXkFqcGdeQXVyNzU1NzE3NTg@._V1_CR0,45,480,270_AL_UX477_CR0,0,477,268_AL_.jpg"
}
},
Buttons = new List<CardAction>
{
new CardAction
{
Title = "Buy",
Type = PaymentRequest.PaymentActionType,
Value = test,
}
}
};
replyMessage.Attachments.Add(heroCard.ToAttachment());
await context.PostAsync(replyMessage);
我从 PaymentRequest 构造函数中取出了一堆参数,因为我正在尝试尝试获得某种反馈。有了这个,我除了 url 什么都没有得到,当我尝试 运行 它时浏览器崩溃了。
"content": {
"buttons": [
{
"title": "Buy",
"type": "openUrl",
"value": "payment://{\"methodData\":[{\"supportedMethods\":[\"https://bobpay.xyz/pay\"],\"data\":{}}],\"details\":{}}"
}
],
我找不到任何关于如何正确执行此操作的文档,但它似乎并没有说它在文档中已被弃用。如果有帮助,我正在使用 bot 框架 v3。我觉得即使在 PaymentRequest 中没有一些参数,当我点击按钮时它仍然应该给我一些东西。
如本文档所述:bot-builder-dotnet-request-payment 要使用 Bot Builder Payments 库,您必须首先:
Create and activate a Stripe account if you don't have one already.
Sign in to Seller Center with your Microsoft account.
Within Seller Center, connect your account with Stripe.
Within Seller Center, navigate to the Dashboard and copy the value of
MerchantID.
Update your bot's Web.config file to set MerchantId to the value that
you copied from the Seller Center Dashboard.
目前Bot Framework SDK只直接支持Stripe支付。如果您使用其他提供商,则需要手动添加支持。
另请注意:自 2019 年 2 月 25 日起,Bot Builder V4 SDK 没有内置支付支持。Bot Builder V3 SDK 有:https://github.com/Microsoft/BotBuilder-Samples/tree/v3-sdk-samples/CSharp/sample-payments (Also, the Bot Framework Emulator V4 does not yet support payments: https://github.com/Microsoft/BotFramework-Emulator/issues/1324 The V3 emulator can be downloaded from here: https://github.com/Microsoft/BotFramework-Emulator/releases/tag/v3.5.37 )
我目前正在开发一个机器人项目,我正在尝试利用 Microsoft 自适应卡向用户发送 PaymentRequest。我创建了一个虚拟 paymentrequest 对象并将其插入到 Hero 卡中,如文档所述。
var methodList = new List<PaymentMethodData>();
var method = new PaymentMethodData()
{Data = new {supportedNetworks = new[] { "visa", "mastercard", "amex", "discover", "diners", "jcb", "unionpay"} }, SupportedMethods = new[] { "https://bobpay.xyz/pay" } };
methodList.Add(method);
var details = new PaymentDetails {};
var test = new PaymentRequest(null, methodList, details);
var heroCard = new HeroCard
{
Title = "Bob",
Subtitle = "The Builder",
Text = "Kunnen wij het maken!",
Images = new List<CardImage>
{
new CardImage
{
Url = "https://m.media-amazon.com/images/M/MV5BNjRlYjgwMWMtNDFmMy00OWQ0LWFhMTMtNWE3MTU4ZjQ3MjgyXkEyXkFqcGdeQXVyNzU1NzE3NTg@._V1_CR0,45,480,270_AL_UX477_CR0,0,477,268_AL_.jpg"
}
},
Buttons = new List<CardAction>
{
new CardAction
{
Title = "Buy",
Type = PaymentRequest.PaymentActionType,
Value = test,
}
}
};
replyMessage.Attachments.Add(heroCard.ToAttachment());
await context.PostAsync(replyMessage);
我从 PaymentRequest 构造函数中取出了一堆参数,因为我正在尝试尝试获得某种反馈。有了这个,我除了 url 什么都没有得到,当我尝试 运行 它时浏览器崩溃了。
"content": {
"buttons": [
{
"title": "Buy",
"type": "openUrl",
"value": "payment://{\"methodData\":[{\"supportedMethods\":[\"https://bobpay.xyz/pay\"],\"data\":{}}],\"details\":{}}"
}
],
我找不到任何关于如何正确执行此操作的文档,但它似乎并没有说它在文档中已被弃用。如果有帮助,我正在使用 bot 框架 v3。我觉得即使在 PaymentRequest 中没有一些参数,当我点击按钮时它仍然应该给我一些东西。
如本文档所述:bot-builder-dotnet-request-payment 要使用 Bot Builder Payments 库,您必须首先:
Create and activate a Stripe account if you don't have one already.
Sign in to Seller Center with your Microsoft account.
Within Seller Center, connect your account with Stripe.
Within Seller Center, navigate to the Dashboard and copy the value of MerchantID.
Update your bot's Web.config file to set MerchantId to the value that you copied from the Seller Center Dashboard.
目前Bot Framework SDK只直接支持Stripe支付。如果您使用其他提供商,则需要手动添加支持。
另请注意:自 2019 年 2 月 25 日起,Bot Builder V4 SDK 没有内置支付支持。Bot Builder V3 SDK 有:https://github.com/Microsoft/BotBuilder-Samples/tree/v3-sdk-samples/CSharp/sample-payments (Also, the Bot Framework Emulator V4 does not yet support payments: https://github.com/Microsoft/BotFramework-Emulator/issues/1324 The V3 emulator can be downloaded from here: https://github.com/Microsoft/BotFramework-Emulator/releases/tag/v3.5.37 )