Javascript 账单名称带有撇号时不显示条带表单

Javascript 账单名称带有撇号时不显示条带表单,javascript,php,stripe-payments,Javascript,Php,Stripe Payments,我的页面上有以下条带付款表: stripe.createToken(card,{name: '<?php echo $order->customer['firstname'] . ' ' . $order->customer['lastname']; ?>', address_line1 : '<?php echo $order->customer['street_address']; ?>', address_city : '<?php echo

我的页面上有以下条带付款表:

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);
        }
    });
});
stripe.createToken(卡片,{name:'',地址\行1:'',地址\城市:'',地址\州:'',地址\国家:'})。然后(函数(结果){
if(result.error){
//如果出现错误,请通知用户
var errorElement=document.getElementById('card-errors');
errorElement.textContent=result.error.message;
}否则{
//将令牌发送到服务器
stripeTokenHandler(表单、结果、令牌);
}
});
});
我最近发现一位姓o'brian的客户没有看到表格中允许他们输入信用卡信息的部分。花了一段时间才弄清楚他们为什么会有这样的问题


在任何情况下,我应该用str_替换掉撇号吗?删除撇号似乎有点奇怪?或者我还应该做些什么?

撇号匹配JavaScript字符串开头和结尾的单引号,导致JavaScript中的引号不匹配

使用
json\u encode()
将PHP值安全地转换为等效的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) {
stripe.createToken(卡、{
姓名:,
地址第1行:,
地址(城市):,
地址(州):,
地址/国家:
}).然后(函数(结果){