我一直在尝试将我的网站设置为将电子商务表单集成到网站中。我设法使用Sandbox凭据工作,但是一旦我将其切换到" live",替换位置ID,应用程序ID和访问令牌以获取实时数据,并试图向我自己收取1.00美元,我开始收到以下错误:
function toggleState() {
var toggle_me = d3.select(this)
var i = circles[0].findIndex(function(d) {
return d == toggle_me[0][0]
})
if (i !== -1) {
var state = !(toggle_me.attr("fill") == "#fff")
toggle_me.attr("fill", (state ? "#fff": "#000"))
// Do additional functions with i here
//var triange = d3.select(triangles[0][i])
//...
}
}
但是,我知道自从我在上一页收到我的现时收到警报以来已经创建了这个随机数。
这是index.html:
Caught exception!
Response body:
object(stdClass)[6]
public 'errors' =>
array (size=1)
0 =>
object(stdClass)[7]
public 'category' => string 'INVALID_REQUEST_ERROR' (length=21)
public 'code' => string 'NOT_FOUND' (length=9)
public 'detail' => string 'Resource not found.' (length=19)
public 'field' => string 'card_nonce' (length=10)
Response headers:
array (size=12)
0 => string 'HTTP/1.1 404 Not Found' (length=22)
'Content-Type' => string 'application/json' (length=16)
'Vary' => string 'Accept-Encoding' (length=15)
'X-Content-Type-Options' => string 'nosniff' (length=7)
'X-Download-Options' => string 'noopen' (length=6)
'X-Frame-Options' => string 'SAMEORIGIN' (length=10)
'X-Permitted-Cross-Domain-Policies' => string 'none' (length=4)
'X-Xss-Protection' => string '1; mode=block' (length=13)
'Date' => string 'Sun, 12 Jun 2016 22:20:11 GMT' (length=29)
'Content-Length' => string '121' (length=3)
'Keep-Alive' => string 'timeout=60' (length=10)
'Strict-Transport-Security' => string 'max-age=631152000' (length=17)
这是process-card.php:
<html>
<head>
<title>My Payment Form</title>
<script type="text/javascript" src="https://js.squareup.com/v2/paymentform"></script>
<script type="text/javascript">
var sqPaymentForm = new SqPaymentForm({
// Replace this value with your application's ID (available from the merchant dashboard).
// If you're just testing things out, replace this with your _Sandbox_ application ID,
// which is also available there.
applicationId: 'xxxxxxxxxxxxxxx', //for public posting purposes
inputClass: 'sq-input',
cardNumber: {
elementId: 'sq-card-number',
placeholder: "0000 0000 0000 0000"
},
cvv: {
elementId: 'sq-cvv',
placeholder: 'CVV'
},
expirationDate: {
elementId: 'sq-expiration-date',
placeholder: 'MM/YY'
},
postalCode: {
elementId: 'sq-postal-code',
placeholder: 'Postal Code'
},
inputStyles: [
// Because this object provides no value for mediaMaxWidth or mediaMinWidth,
// these styles apply for screens of all sizes, unless overridden by another
// input style below.
{
fontSize: '14px',
padding: '3px'
},
// These styles are applied to inputs ONLY when the screen width is 400px
// or smaller. Note that because it doesn't specify a value for padding,
// the padding value in the previous object is preserved.
{
mediaMaxWidth: '400px',
fontSize: '18px',
}
],
callbacks: {
cardNonceResponseReceived: function(errors, nonce, cardData) {
if (errors) {
var errorDiv = document.getElementById('errors');
errorDiv.innerHTML = "";
errors.forEach(function(error) {
var p = document.createElement('p');
p.innerHTML = error.message;
errorDiv.appendChild(p);
});
} else {
// This alert is for debugging purposes only.
alert('Nonce received! ' + nonce + ' ' + JSON.stringify(cardData));
// Assign the value of the nonce to a hidden form element
var nonceField = document.getElementById('card-nonce');
nonceField.value = nonce;
// Submit the form
document.getElementById('form').submit();
}
},
unsupportedBrowserDetected: function() {
// Alert the buyer that their browser is not supported
}
}
});
function submitButtonClick() {
event.preventDefault();
sqPaymentForm.requestCardNonce();
}
</script>
<style type="text/css">
.sq-input {
border: 1px solid #CCCCCC;
margin-bottom: 10px;
padding: 1px;
}
.sq-input--focus {
outline-width: 5px;
outline-color: #70ACE9;
outline-offset: -1px;
outline-style: auto;
}
.sq-input--error {
outline-width: 5px;
outline-color: #FF9393;
outline-offset: 0px;
outline-style: auto;
}
</style>
</head>
<body>
<h1>My Payment Form</h1>
<form id="form" novalidate action="process-card.php" method="post">
<label>Credit Card</label>
<div id="sq-card-number"></div>
<label>CVV</label>
<div id="sq-cvv"></div>
<label>Expiration Date</label>
<div id="sq-expiration-date"></div>
<label>Postal Code</label>
<div id="sq-postal-code"></div>
<input type="hidden" id="card-nonce" name="nonce">
<input type="submit" onClick="submitButtonClick()" id="card-nonce">
</form>
<div id="errors"></div>
</body>
</html>
答案 0 :(得分:2)
您是否在Square上注册了多个申请?
我认为发生此问题是因为您在初始化application_id
中的SqPaymentForm
时提供的Square index.html
与发布您在{{{{}}中提供的访问令牌的应用程序不同1}}。
尝试向卡nonce收费的应用程序必须与首先生成nonce的应用程序相同。
答案 1 :(得分:0)
我发现对我来说问题是我的javascript文件卡在缓存中,沙箱键被激活了。一旦我清除了缓存,它对我有用。