I am having trouble setting up Apple Pay and Google Pay in my shopping cart app. I have Apple Pay enabled via domain verification, but am trying to get Google Pay to work - I don’t have access to an IOS machine at the moment. Can you check to see if my Square account is correctly set up for Apple Pay/ Google Pay my application id is sq0idp-eLT76K0A-xczgNpIkJoghA, so that I can concentrate my efforts away from Square and in the code. Thank you
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
Additional Documentation
Troubleshoot In-App Payments SDK Problems
In-App Payment Solutions
Take Payments and Build Integrations on Square Hardware
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
I have the code below which causes the message to be displayed. I was hoping I had missed something in the Square set up that was causing the problem but it appears that message is entirely determined by Google Pay’s environment checks through Square. So although I think I am using https , have a google wallet, no adblocker etc, something may be wrong in my set up. Cosequently I may have disturbed you unnecessarily.
try {
const payments = window.Square.payments(applicationId, locationId);
// Initialize Google Pay button if available
if (window.Square.payments.googlePay) {
try {
console.log(‘Attempting to initialize Google Pay…’);
const gpay = await payments.googlePay();
// Check if Google Pay can make payments on this device
const canMakePayment = await gpay.canMakePayment();
console.log(‘Google Pay canMakePayment:’, canMakePayment);
if (canMakePayment) {
const gpayButton = await gpay.attach(‘#google-pay-button’);
gpayButton.addEventListener(‘click’, async () => {
try {
setLoading(true);
setError(null);
const paymentRequest = {
countryCode: ‘GB’,
currencyCode: ‘GBP’,
total: {
amount: (amount / 100).toFixed(2),
label: ‘East View Pottery’
}
};
const tokenResult = await gpay.tokenize(paymentRequest);
if (tokenResult.status === ‘OK’) {
await onPaymentComplete(tokenResult);
} else {
console.error(‘Google Pay tokenization failed:’, tokenResult.errors);
setError(‘Google Pay payment failed’);
}
} catch (err) {
console.error(‘Google Pay error:’, err);
setError(err.message || ‘Google Pay payment failed’);
} finally {
setLoading(false);
}
});
// Only set as available if button creation succeeds
setGooglePayAvailable(true);
console.log(‘Google Pay initialized successfully’);
} else {
console.log(‘Google Pay cannot make payments on this device’);
setGooglePayAvailable(false);
}
} catch (gpayError) {
console.error(‘Failed to initialize Google Pay:’, gpayError);
setGooglePayAvailable(false);
}
} else {
console.log(‘Google Pay not available on this device/browser’);
setGooglePayAvailable(false);
}
} catch (err) {
console.error(‘Error initializing wallet payments:’, err);
setError(‘Failed to initialize wallet payments’);
// Reset availability on error
setApplePayAvailable(false);
setGooglePayAvailable(false);
} finally {
// Mark initialization as complete
setInitializing(false);
}
};
Regards
