jquery - 如何在 laravel 中使用 jquery 在 paypal 中传递帐单地址或用户详细信息
问题描述
我正在使用 Braintree 付款进行 PayPal 付款度假集成,但我无法在 PayPal 上传递参数。
jQuery
<script type="text/javascript">
jQuery(document).ready(function(e) {
braintree.setup(
// Replace this with a client token from your server
" <?php print session('braintree_token')?>",
"dropin", {
container: "payment-form",
});
});
<script type="text/javascript">
window.onload = function(e){
var paypal_public_key = document.getElementById('paypal_public_key').value;
var acount_type = document.getElementById('paypal_environment').value;
if(acount_type=='Test'){
var paypal_environment = 'sandbox'
}else if(acount_type=='Live'){
var paypal_environment = 'production'
}
paypal.Button.render({
enableBillingAddress: false,
env: paypal_environment, // sandbox | production
style: {
label: 'checkout',
size: 'small', // small | medium | large | responsive
shape: 'pill', // pill | rect
color: 'gold' // gold | blue | silver | black
},
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: paypal_public_key,
production: paypal_public_key
},
// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,
// payment() is called when the button is clicked
payment: function(data, actions) {
var payment_currency = document.getElementById('payment_currency').value;
var total_price = '<?php echo number_format((float)$total_price+0, 2, '.', '');?>';
var billing_address = false;
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: {
total: total_price,
currency: payment_currency,
},
}
]
}
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
jQuery('#update_cart_form').prepend('<input type="hidden" name="nonce" value='+JSON.stringify(data)+'>');
jQuery("#update_cart_form").submit();
});
}
}, '#paypal_button');
};
当我点击 PayPal 按钮时,它会重定向到 sandbox.paypal.com,这是正确的,但它不会隐藏帐单地址,它仍然处于启用状态,我通过了 false。所以,我的问题是如何使用 jquery 将参数传递给 PayPal 结帐,因为我需要传递一些有关客户的更多信息。那么如何实现这一点。请帮忙。
解决方案
所有 PayPal 交易都使用账单地址。这是必需的。
enableBillingAddress 参数用于请求返回该信息。很少有卖家账户可以在设置为 true 的情况下处理付款,因此您应该忽略这一点。
如果您的目标是设置预填信息,则需要与其他字段一起设置,并且在用户登录时可能会被忽略,因为已登录的用户已经存储了自己的信息。
推荐阅读
- python - 我们可以动态检索pyspark数据框中更新列的前一行值吗
- javascript - 在连续的 Ajax 函数中使用相同的变量
- java - 即使我使用 powermockito 模拟课程,“Mockito 无法模拟此类”错误
- silverlight - 从 Silverlight 到 Blazor:如何继续使用当前的 RIA Seivices
- r - 有没有办法将自定义名称添加到 R 闪亮应用程序中的错误消息中
- android - 为什么启动器应用程序在其他应用程序完成时显示第一个活动?
- sql - 将两个 group by 查询组合为一个以获取 sql server 中两个表的记录的计数
- excel - 比较两个单元格并复制它们 / 2 个工作簿
- python - Python 3.6 'f' 字符串的表达式与 `.format` 或 `.format_map` 不兼容
- android - Android:从 Google Ads 接收错误的 UTM