我正在尝试更新我们的广场支付形式JS的cardNonceResponseReceived SCA (我们在英国),并使用当前的连接版本,并遵循广场提供的代码示例,但我得到一个错误时,在控制台和表单加载失败,如预期。我看不到我错过了什么--感谢任何帮助。
我已经检查了最新的JS示例的当前connect-api php-payment,但问题仍然存在于我们的实时示例和https://github.com/square/connect-api-examples/blob/master/connect-examples/v2/php_payment/js/sq-payment-form.js示例中,无论是调用沙箱还是实时环境。该错误发生在食谱中更新的cardNonceResponseReceived示例的所有Square示例中。我提供了locationId,并按如下方式更新了代码(从提供的示例中获得):
/*
* callback function: cardNonceResponseReceived
* Triggered when: SqPaymentForm completes a card nonce request
*/
cardNonceResponseReceived: function (errors, nonce, cardData) {
// Assign the nonce value to the hidden form field
document.getElementById('card-nonce').value = nonce;
const verificationDetails = {
amount: '100.00',
intent: "CHARGE", //Allowed values: "CHARGE", "STORE"
billingContact: {
familyName: "Smith",
givenName: "John",
email: "jsmith@example.com",
country: "GB",
city: "London",
postalCode: "SW7 4JA",
phone: "020 7946 0532"
}
};
try {
paymentform.verifyBuyer(
nonce,
verificationDetails,
callback(err,verification) {
if (err == null) {
document.getElementById('buyerVerification-token').value = verification;
}
});
// POST the nonce form to the payment processing page
document.getElementById('nonce-form').submit();
} catch (typeError) {
//TypeError thrown if illegal arguments are passed
}
}控制台在callback(err,verification) {行上报告SyntaxError: Expected ')' (边缘) SyntaxError: missing ) after argument list (火狐
发布于 2019-09-10 01:14:56
执行此操作:创建一个单独的调用函数。
function verifyBuyerCallback(err,verification) {
if (err == null) {
document.getElementById('buyerVerification-token').value = verification;
}
}
paymentform.verifyBuyer(nonce, verificationDetails, verifyBuyerCallback);
发布于 2019-09-10 20:12:14
Square提供的示例是不准确的,将被更新- callback(err,verification)应该阅读function callback(err,verification)
发布于 2020-01-10 00:30:33
先说清楚,
paymentform.verifyBuyer(
nonce,
verificationDetails,
callback(err,verification) {
//--------------------------^函数调用的Javascript语法类似于callback(err,verification);匿名函数定义的语法类似于function(err,verification) {...},而命名函数定义的语法类似于function callback(err,verification) {...}。这就是说,你想调用一个已有的名为"callback“的函数作为第三个参数,然后你就有了{,这是没有意义的。最常见的情况是缺少结束字符,这就是为什么所有的Javascript引擎都会提示缺少)。
它应该是function(err,verification) {而不是callback(err,verification) {。
https://stackoverflow.com/questions/57853908
复制相似问题