Integrating 1C-Bitrix with Google Pay
Google Pay is a fast payment method available through the Chrome browser and Android devices without requiring manual card entry. Like Apple Pay, it is not a standalone payment system but a card tokenization interface built on top of an existing acquiring service. The key difference from Apple Pay: it works not only in mobile applications but also in Chrome on desktop — provided the user has saved a card in their Google account. The audience reach is broader, and the implementation through the Google Pay API is somewhat simpler than Apple Pay.
How It Works
The Google Pay API provides an encrypted payment token (Google Pay token) that must be passed to the acquirer's processing system. The flow:
- The Google Pay JS library (
pay.google.com/gp/p/js/pay.js) loads on the page - The buyer clicks "Pay with Google Pay"
- The browser displays a native confirmation dialog with the linked card
- Google Pay returns an encrypted token
- The store passes the token to the acquiring service (YooKassa, Tinkoff, Sber, Stripe)
Google Pay API Initialization
In the payment page template or in the JS file of a custom component:
const googlePayConfig = {
environment: 'PRODUCTION', // 'TEST' for testing
apiVersion: 2,
apiVersionMinor: 0,
};
const paymentsClient = new google.payments.api.PaymentsClient(googlePayConfig);
const allowedPaymentMethods = [{
type: 'CARD',
parameters: {
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
allowedCardNetworks: ['MASTERCARD', 'VISA', 'MIR'],
},
tokenizationSpecification: {
type: 'PAYMENT_GATEWAY',
parameters: {
gateway: 'yookassa', // or 'tinkoff', 'sberbank', etc.
gatewayMerchantId: 'SHOP_ID', // your ID in the acquiring service
},
},
}];
// Check whether the user is ready to pay
paymentsClient.isReadyToPay({
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods,
}).then(response => {
if (response.result) {
const button = paymentsClient.createButton({
onClick: processPayment,
buttonColor: 'default',
buttonType: 'pay',
});
document.getElementById('google-pay-container').appendChild(button);
}
});
Payment Request
function processPayment() {
const paymentDataRequest = {
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods,
merchantInfo: {
merchantId: 'BCR2DN4T...', // Google Merchant ID from Google Pay Console
merchantName: 'My Store',
},
transactionInfo: {
totalPriceStatus: 'FINAL',
totalPrice: orderTotal.toString(), // string, e.g. '1500.00'
currencyCode: 'RUB',
countryCode: 'RU',
},
};
paymentsClient.loadPaymentData(paymentDataRequest)
.then(paymentData => {
const token = paymentData.paymentMethodData.tokenizationData.token;
return fetch('/bitrix/tools/gpay_charge.php', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ token, orderId }),
});
})
.then(res => res.json())
.then(data => {
if (data.success) window.location.href = data.redirect;
})
.catch(err => console.error('Google Pay error', err));
}
Server-Side Token Processing
// /bitrix/tools/gpay_charge.php
$input = json_decode(file_get_contents('php://input'), true);
$gpToken = $input['token']; // JSON string or object
$orderId = (int)$input['orderId'];
// For YooKassa, pass the token directly
$payment = $yookassaClient->createPayment([
'amount' => ['value' => getOrderAmount($orderId), 'currency' => 'RUB'],
'payment_method_data' => [
'type' => 'google_pay',
'payment_methodology_token' => is_string($gpToken) ? $gpToken : json_encode($gpToken),
],
'capture' => true,
'description' => 'Order #' . $orderId,
], uniqid('', true));
$success = $payment->getStatus() === 'succeeded';
if ($success) {
$bitrixPayment->setPaid('Y');
$bitrixPayment->save();
}
header('Content-Type: application/json');
echo json_encode([
'success' => $success,
'redirect' => $success ? '/personal/order/detail/' . $orderId . '/' : null,
]);
Testing
In TEST mode, Google Pay returns a fixed test token without a real card. For full testing with a real token, you need:
- A Google Merchant ID (registered in Google Pay & Wallet Console)
- A verified domain
- Test cards from Google Pay Console → Test Cards
It is essential to test in Chrome on an Android device — the dialog behavior differs from desktop.
Timeline
| Task | Duration |
|---|---|
| JS integration of the Google Pay button | 0.5 day |
| Server-side token processing via acquiring service | 0.5 day |
| Registration in Google Pay Console + testing | 1 day |







