我的代码如下所示:
var applicationId = 'sq0idp-EYeN-hglrwbhqPIuwJjFUA';
if (applicationId == '') {
alert('You need to provide a value for the applicationId variable.');
}
var paymentForm = new SqPaymentForm({
applicationId: applicationId,
cardNumber: {
elementId: 'ccnumber',
},
cvv: {
elementId: 'cccvc',
placeholder: 'CVV'
},
expirationDate: {
elementId: 'ccexpdatemonth',
placeholder: 'MM/YY'
},
postalCode: {
elementId: 'postalcode'
},
callbacks: {
cardNonceResponseReceived: function(errors, nonce, cardData) {
if (errors) {
console.log("Encountered errors:");
errors.forEach(function(error) {
console.log(' ' + error.message);
});
} else {
alert('Nonce received: ' + nonce);
}
},
unsupportedBrowserDetected: function() {
},
inputEventReceived: function(inputEvent) {
switch (inputEvent.eventType) {
case 'focusClassAdded':
// Handle as desired
break;
case 'focusClassRemoved':
// Handle as desired
break;
case 'errorClassAdded':
// Handle as desired
break;
case 'errorClassRemoved':
// Handle as desired
break;
case 'cardBrandChanged':
// Handle as desired
break;
case 'postalCodeChanged':
// Handle as desired
break;
}
},
paymentFormLoaded: function() {
}
}
});
function requestCardNonce(event) {
event.preventDefault();
alert('method called: ');
paymentForm.requestCardNonce();
}
squarePayment.js
The SqPaymentForm inputClass option is required.
但不知何故,它会抛出错误{{1}}集成有问题吗?
答案 0 :(得分:2)
好的,所以我只是去了他们的文档并进行了检查,我认为它缺少必需的选项,显然我们无法从您提供的代码中确切地说出这一点。
// Initializes the payment form. See the documentation for descriptions of
// each of these parameters.
var paymentForm = new SqPaymentForm({
applicationId: applicationId,
inputClass: 'sq-input', <----------------
inputStyles: [
{
fontSize: '15px'
}
],
inputClas string
此CSS类已分配给为付款&gt;表格生成的所有四个iframe。您可以为其创建CSS规则 这个类来设计输入的外部(即边界和 边距)。有关详细信息,请参阅样式输入外部。