Hello I’m super new rot Square and I’m setting up membership payment system with the Square API.
I have everything working great I get the proper auth codes the money shows up in the account the only issue is a membership is $40 and when I did the autorization it only changes $0.40. I can’t find the issue. I’ve added 40.00 where is makes sense.
Is this an issues that is common? is there a simple fix for this error I’m doing?
For reference here is the square-pay,php code.
/////////////////\\\\\\\\/////////////////\\\\\\\\/////////////////\\\\\\\\/////////////////\\\\\\\\
<?php require 'vendor/autoload.php'; require_once('/home2/pvcoucmy/public_html/acoontario/includes/bootstrap.php'); require_once('/home2/pvcoucmy/public_html/acoontario/includes/functions.php'); ?> <? $newID = $_GET['newID']; if ($newID == '') { echo "did not work"; } $sql = "SELECT receipts_hold.t_id, receipts_hold.email_address, receipts_hold.temp_number, receipts_hold.fname, receipts_hold.lname, receipts_hold.total_for_receipt, receipts_hold.address, receipts_hold.city, receipts_hold.province, receipts_hold.p_code, receipts_hold.country FROM receipts_hold WHERE receipts_hold.t_id =".$newID; $result=mysqli_query($mysqli,$sql); $get_stuff=mysqli_fetch_assoc($result); $t_id = $get_stuff['t_id']; $fname = $get_stuff['fname']; $lname = $get_stuff['lname']; $total_for_receipt = $get_stuff['total_for_receipt']; $total_for_receipt = round($total_for_receipt); $total_for_receipt = $total_for_receipt.'.00'; $address = $get_stuff['address']; $city = $get_stuff['city']; $province = $get_stuff['province']; $p_code = $get_stuff['p_code']; $email_address = $get_stuff['email_address']; $country = $get_stuff['country']; if ($country == '') { $country = "Canada"; } use Square\Environment; // dotenv is used to read from the '.env' file created for credentials $dotenv = Dotenv\Dotenv::create(__DIR__); $dotenv->load(); // Pulled from the .env file and upper cased e.g. SANDBOX, PRODUCTION. $upper_case_environment = strtoupper(getenv('ENVIRONMENT')); ?> My Payment Form<script type="text/x-javascript">
/**
- Define callback function for “sq-button”
-
@param {*} event
*/
function onGetCardNonce(event) {
// Don’t submit the form until SqPaymentForm returns with a nonce
event.preventDefault();
// Request a nonce from the SqPaymentForm object
paymentForm.requestCardNonce();
}
// Initializes the SqPaymentForm object by
// initializing various configuration fields and providing implementation for callback functions.
var paymentForm = new SqPaymentForm({
// Initialize the payment form elements
applicationId: applicationId,
locationId: locationId,
inputClass: ‘sq-input’,
// Customize the CSS for SqPaymentForm iframe elements
inputStyles: [{
backgroundColor: ‘transparent’,
color: ‘#333333’,
fontFamily: ‘“Helvetica Neue”, “Helvetica”, sans-serif’,
fontSize: ‘16px’,
fontWeight: ‘400’,
placeholderColor: ‘#8594A7’,
placeholderFontWeight: ‘400’,
padding: ‘16px’,
_webkitFontSmoothing: ‘antialiased’,
_mozOsxFontSmoothing: ‘grayscale’
}],
// Initialize Google Pay button ID
googlePay: {
elementId: ‘sq-google-pay’
},
// Initialize Apple Pay placeholder ID
applePay: {
elementId: ‘sq-apple-pay’
},
// Initialize Masterpass placeholder ID
masterpass: {
elementId: ‘sq-masterpass’
},
// 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’
},
// SqPaymentForm callback functions
callbacks: {
/*
* callback function: methodsSupported
* Triggered when: the page is loaded.
*/
methodsSupported: function (methods) {
if (!methods.masterpass && !methods.applePay && !methods.googlePay) {
var walletBox = document.getElementById('sq-walletbox');
walletBox.style.display = 'none';
} else {
var walletBox = document.getElementById('sq-walletbox');
walletBox.style.display = 'block';
}
// Only show the button if Google Pay is enabled
if (methods.googlePay === true) {
var googlePayBtn = document.getElementById('sq-google-pay');
googlePayBtn.style.display = 'inline-block';
}
// Only show the button if Apple Pay for Web is enabled
if (methods.applePay === true) {
var applePayBtn = document.getElementById('sq-apple-pay');
applePayBtn.style.display = 'inline-block';
}
// Only show the button if Masterpass is enabled
if (methods.masterpass === true) {
var masterpassBtn = document.getElementById('sq-masterpass');
masterpassBtn.style.display = 'inline-block';
}
},
/*
* callback function: createPaymentRequest
* Triggered when: a digital wallet payment button is clicked.
*/
createPaymentRequest: function () {
var paymentRequestJson = {
requestShippingAddress: false,
requestBillingInfo: true,
shippingContact: {
familyName: "<?=$lname?>",
givenName: "<?=$fname?>",
email: "<?=$email_address?>",
country: "<?=$country?>",
region: "CA",
city: "<?=$city?>",
addressLines: [
"<?=$address?>"
],
postalCode: "<?=$p_code?>",
phone:""
},
currencyCode: "CAN",
countryCode: "CA",
total: {
label: "ACO Ontario",
amount: "<?=$total_for_receipt?>",
pending: false
},
lineItems: [
{
label: "Subtotal",
amount: "<?=$total_for_receipt?>",
pending: false
}
]
};
return paymentRequestJson;
},
/*
* callback function: validateShippingContact
* Triggered when: a shipping address is selected/changed in a digital
* wallet UI that supports address selection.
*/
validateShippingContact: function (contact) {
var validationErrorObj ;
/* ADD CODE TO SET validationErrorObj IF ERRORS ARE FOUND */
return validationErrorObj ;
},
/*
* callback function: cardNonceResponseReceived
* Triggered when: SqPaymentForm completes a card nonce request
*/
cardNonceResponseReceived: function(errors, nonce, cardData, billingContact, shippingContact) {
if (errors){
var error_html = "";
for (var i =0; i < errors.length; i++){
error_html += "<li> " + errors[i].message + " </li>";
}
document.getElementById("error").innerHTML = error_html;
document.getElementById('sq-creditcard').disabled = false;
return;
}else{
document.getElementById("error").innerHTML = "";
}
// Assign the nonce value to the hidden form field
document.getElementById('card-nonce').value = nonce;
// POST the nonce form to the payment processing page
document.getElementById('nonce-form').submit();
},
/*
* 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() {
/* HANDLE AS DESIRED */
}
}
});
</script>