Javascript 在(Phonegap应用程序)中的IOS设备上未填充字段的平方表单生成
我正在开发square-up API。并使用js库填充表单。当我创建应用程序的构建并在android上运行它时,它工作正常,并按预期填充表单 但在IOS设备上,它不会填充表单字段。即使是对象也会在我发出警报时创建 alertJSON.stringifypaymentform 在IOS和Android上以同样的方式填充 我的密码是 HTML JS代码 我认为它应该适用于IOS和Android。但只在安卓上工作 任何帮助都将不胜感激。Javascript 在(Phonegap应用程序)中的IOS设备上未填充字段的平方表单生成,javascript,android,ios,phonegap,square,Javascript,Android,Ios,Phonegap,Square,我正在开发square-up API。并使用js库填充表单。当我创建应用程序的构建并在android上运行它时,它工作正常,并按预期填充表单 但在IOS设备上,它不会填充表单字段。即使是对象也会在我发出警报时创建 alertJSON.stringifypaymentform 在IOS和Android上以同样的方式填充 我的密码是 HTML JS代码 我认为它应该适用于IOS和Android。但只在安卓上工作 任何帮助都将不胜感激。 谢谢大家把答案贴在这里: 在config.xml文件中,需要添加
谢谢大家把答案贴在这里: 在config.xml文件中,需要添加
<allow-navigation href="https://*squareup.com/*" />
基于填充表单是什么意思?它没有加载输入字段吗?您是否能够调试并查看浏览器控制台错误?此外,我们还有应用内支付SDK,它基本上是移动应用程序中构建的支付表单。我们没有Phonegap的插件,但您可能会感兴趣:@sjosey Hi,填充表单意味着在android中它会在表单中应用占位符。在IOS中,它只是给我没有占位符的字段。并且字段也不可编辑。然后单击“充电”按钮,“平方回叫函数未启动”。@sjosey,在浏览器控制台中,它向我显示了无法读取未定义的属性“build”的错误。但它在android设备上运行良好。你从哪里调用构建?我在上面的JS代码中没有看到它。这是付款单上的一个函数,但听起来好像它是在付款单对象初始化之前被调用的。我在单击函数时调用它。当用户单击信用卡付款按钮时。我在IOS设备中提醒了对象,它也返回了完整的对象。
/*
* function: requestCardNonce
*
* requestCardNonce is triggered when the "Pay with credit card" button is
* clicked
*
* Modifying this function is not required, but can be customized if you
* wish to take additional action when the form button is clicked.
*/
function requestCardNonce(event) {
// Don't submit the form until SqPaymentForm returns with a nonce
event.preventDefault();
// Request a nonce from the SqPaymentForm object
paymentForm.requestCardNonce();
}
// Create and initialize a payment form object
var paymentForm = new SqPaymentForm({
// Initialize the payment form elements
applicationId: applicationId,
locationId: locationId,
inputClass: 'sq-input',
// Customize the CSS for SqPaymentForm iframe elements
inputStyles: [{
fontSize: '.9em'
}],
// Initialize the credit card placeholders
cardNumber: {
elementId: 'sq-card-number',
placeholder: '•••• •••• •••• ••••'
},
cvv: {
elementId: 'sq-cvv',
placeholder: 'CVV'
},
expirationDate: {
elementId: 'sq-expiration-date',
placeholder: 'MM/YY'
},
postalCode: {
elementId: 'sq-postal-code',
placeholder: '-----'
},
// SqPaymentForm callback functions
callbacks: {
/*
* callback function: methodsSupported
* Triggered when: the page is loaded.
*/
methodsSupported: function (methods) {
var applePayBtn = document.getElementById('sq-apple-pay');
var applePayLabel = document.getElementById('sq-apple-pay-label');
var masterpassBtn = document.getElementById('sq-masterpass');
var masterpassLabel = document.getElementById('sq-masterpass-label');
// Only show the button if Apple Pay for Web is enabled
// Otherwise, display the wallet not enabled message.
if (methods.applePay === true) {
applePayBtn.style.display = 'inline-block';
applePayLabel.style.display = 'none';
}
// Only show the button if Masterpass is enabled
// Otherwise, display the wallet not enabled message.
if (methods.masterpass === true) {
masterpassBtn.style.display = 'inline-block';
masterpassLabel.style.display = 'none';
}
},
/*
* callback function: createPaymentRequest
* Triggered when: a digital wallet payment button is clicked.
*/
createPaymentRequest: function () {
var paymentRequestJson;
/* ADD CODE TO SET/CREATE paymentRequestJson */
return paymentRequestJson;
},
/*
* callback function: cardNonceResponseReceived
* Triggered when: SqPaymentForm completes a card nonce request
*/
cardNonceResponseReceived: function (errors, nonce, cardData) {
if (errors) {
// Log errors from nonce generation to the Javascript console
console.log("Encountered errors:");
var message_string = "";
errors.forEach(function (error) {
message_string = message_string + error.message + ".<br>";
});
swal({
type: "error",
title: "Error Charging Card",
html: true,
text: message_string,
confirmButtonClass: "btn-danger",
});
return;
}
// Assign the nonce value to the hidden form field
console.log(nonce);
document.getElementById('card-nonce').value = nonce;
//alert(nonce);
// POST the nonce form to the payment processing page
// document.getElementById('nonce-form').submit();
test_cc();
},
/*
* callback function: unsupportedBrowserDetected
* Triggered when: the page loads and an unsupported browser is detected
*/
unsupportedBrowserDetected: function () {
/* PROVIDE FEEDBACK TO SITE VISITORS */
},
/*
* callback function: inputEventReceived
* Triggered when: visitors interact with SqPaymentForm iframe elements.
*/
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;
}
},
/*
* callback function: paymentFormLoaded
* Triggered when: SqPaymentForm is fully loaded
*/
paymentFormLoaded: function () {
console.log("Square loaded");
/* HANDLE AS DESIRED */
}
}
});
<allow-navigation href="https://*squareup.com/*" />