jquery - 如何在 woocommerce 中提交结帐表单之前获取付款令牌
问题描述
我正在做一个 woocommerce 项目,我需要将 google pay 与 authorize.net 集成。
我的主要问题是在提交结帐表格之前我无法获取付款令牌。当我单击“下订单”按钮时,会打开一个弹出窗口供 google pay 提交卡详细信息,但随后结帐表格会自动提交。
到目前为止我所尝试的。
在javascript中
$( "form.checkout" ).on('checkout_place_order_my_gpay_gateway', function(){
const paymentDataRequest = getGooglePaymentDataRequest();
paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
const paymentsClient = getGooglePaymentsClient();
paymentsClient.loadPaymentData(paymentDataRequest)
.then(function(paymentData) {
const enc = window.btoa(paymentData.paymentMethodData.tokenizationData.token);
// here i attach the token into the hidden field and then grab it in the
document.getElementById('gpay_token').value = enc;
// return true;
})
.catch(function(err) {
console.error(err);
});
});
我想要什么
我首先需要获取付款令牌然后我想将此令牌发送到后端以完成付款。
谢谢
解决方案
推荐阅读
- node.js - 使用firebase云功能将数据从一个node1子节点复制到另一个node2子节点
- react-native - 带有变量占位符的文本输入并在按钮单击时清除
- ios - 无法完全安装 pod 'FBSDKLoginKit' 它就停在那里
- python-3.x - 熊猫如何将二维数据帧转换为一维数据帧
- c# - 隐藏或保护 .txt 保存数据 c#
- python - Python 多处理,TypeError
- webpack - 与 webpack 的浏览器同步不起作用
- javascript - Vue + Laravel:如何正确下载 PDF 文件?
- java - ChannelInboundHandlerAdapter 即时删除
- r - 从润滑日期时间对象中提取时间(HMS)?