我的网页上有以下条条付款表格:
stripe.createToken(card,{name: '<?php echo $order->customer['firstname'] . ' ' . $order->customer['lastname']; ?>', address_line1 : '<?php echo $order->customer['street_address']; ?>', address_city : '<?php echo $order->customer['city']; ?>', address_state : '<?php echo $order->customer['state']; ?>', address_country : '<?php echo $order->customer['country']['title']; ?>' }).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the token to your server
stripeTokenHandler(form, result.token);
}
});
});我最近发现,一个姓奥布赖恩的客户并没有被显示表单中允许他们输入信用卡信息的部分。花了一段时间才弄清楚他们为什么会有这样的问题。
在任何情况下,我是否应该用str_replace移除撇号?要去掉撇号似乎有点奇怪吗?还是我还应该做点什么?
发布于 2019-08-14 21:05:02
撇号匹配启动JavaScript字符串的单引号,并结束该字符串,从而导致JavaScript中不匹配的引号。
使用json_encode()安全地将JavaScript值转换为等效的JavaScript文本,而不是在引号中回显原始值。
stripe.createToken(card,{
name: <?php echo json_encode($order->customer['firstname'] . ' ' . $order->customer['lastname']); ?>,
address_line1 : <?php echo json_encode($order->customer['street_address']); ?>,
address_city : <?php echo json_encode($order->customer['city']); ?>,
address_state : <?php echo json_encode($order->customer['state']); ?>,
address_country : <?php echo json_encode($order->customer['country']['title']); ?>
}).then(function(result) {https://stackoverflow.com/questions/57501954
复制相似问题