字符串列表在 POST REST api Dart/Flutter 中转换为单个字符串
List of Strings converts to single String in POST REST api Dart/Flutter
我已经发布了一个相关问题 here,它专门针对我正在做的事情。
这就是问题所在,我正在将 String
的 List
传递给 Stripe API 的 POST
。但是在 Stripe 仪表板上,它是作为单个 String
获取的
payment_method_types
final body = {
'payment_method_types': [
'card',
],
'line_items': [
{
'amount': price,
'quantity': 1,
'currency': 'usd',
'name': 'Some Name here'
},
],
'mode': 'payment',
'success_url': 'https://success.com/{CHECKOUT_SESSION_ID}',
'cancel_url': 'https://cancel.com/',
};
这是 Stripe 仪表板上日志的响应:
任何帮助将不胜感激我现在被困了 3 天。
看了stripe response,好像是在把数组转成对象。
您可以尝试使用:
'payment_method_types': { '0' : 'card', }
解决方案!
代码更改:
'payment_method_types[]' : ['card']
我不知道为什么会这样,但确实如此!
我已经发布了一个相关问题 here,它专门针对我正在做的事情。
这就是问题所在,我正在将 String
的 List
传递给 Stripe API 的 POST
。但是在 Stripe 仪表板上,它是作为单个 String
payment_method_types
final body = {
'payment_method_types': [
'card',
],
'line_items': [
{
'amount': price,
'quantity': 1,
'currency': 'usd',
'name': 'Some Name here'
},
],
'mode': 'payment',
'success_url': 'https://success.com/{CHECKOUT_SESSION_ID}',
'cancel_url': 'https://cancel.com/',
};
这是 Stripe 仪表板上日志的响应:
任何帮助将不胜感激我现在被困了 3 天。
看了stripe response,好像是在把数组转成对象。 您可以尝试使用:
'payment_method_types': { '0' : 'card', }
解决方案!
代码更改:
'payment_method_types[]' : ['card']
我不知道为什么会这样,但确实如此!