Google Pay

Google Pay is a fast and simple payment method in mobile applications and the Chrome browser at all Android based devices. Google Pay provides all payment benefits and secures buyer data.
The Google Pay can be used with Visa and MasterCard cards and is available to all enterprises and private entrepreneurs, connected to the CloudPayments system without any additional agreements and with no modifications of working conditions.
Sample payment via Google Pay (10 rbl.)
Conditions of Use
You can use Google Pay with the CloudPayments system on web sites and in mobile applications, if complying with following requirements:

  • You shall comply with Google Usage Conditions, including: 


o List of forbidden goods and services
o Guidelines for branding

  • To accept payments in a mobile application or when adding a GPay button on your web site (see an example above), you shall register an application and a web site at Google and perform a verification procedure.


Google Pay Operation
Google Pay supports payments via Google Pay application (formerly Android Pay) in shops and traditional payments using a card, saved in a Google user account.

 

If a buyer makes a payment in application or on a web site using his mobile device which supports Google Pay, he will be prompted to confirm his payment by the method depending on device features.

If he makes a payment from his device where a Google Pay application is not installed, he will be prompted to select a saved card from his Google account and, to the discretion of a processor, to pass a 3-d Secure authentication.
Integration
Registration of Web Sites and Applications
To accept payments in an application or on a web site with a direct integration:
1. Verify that all branding guidelines are complied with.
2. Fill out a registration form. Then a Google representative will contact you and informs you your further steps.
3. Be ready to send your application build (.apk) or a link to a web site with a payment page for a verification.
To accept payments on a web site using a widget
Any web site registration and verification are not required.
Acceptance of Payments via Google Pay
A payment scheme includes 3 stages:

  • Verification of a device compatibility. If a device is supported, it is necessary to show the Google Pay button to a buyer.
  • A payment authorization is a payment confirmation by a buyer.
  • Payment processing. After an authorization, Google generates a token which shall be sent to CloudPayments API.


Google Pay in Mobile Applications
Use Google Pay API to get a PaymentData and the payment with cryptogram in API to make a payment.
When creating a request for payment data, specify a payment type via a gateway:
Wallet-Constants. PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY
and add two parameters:
1. gateway: cloudpayments
2. gatewayMerchantId: Your Public ID from CloudPayments' My Account.
 

PaymentMethodTokenizationParameters params =
        PaymentMethodTokenizationParameters.newBuilder()
            .setPaymentMethodTokenizationType(
                WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY)
            .addParameter("gateway", "cloudpayments")
            .addParameter("gatewayMerchantId", "Ваш Public ID")
            .build();

Look also:

  • Example of using Google Pay API for a payment via CloudPayments.
  • Example of using Google Pay API from Google.


Google Pay on a Web Site
You can use two ways to accept Google Pay’s payments on your web site: using built-in widget features or a direct integration: a button can be added to your web site without any additional forms. In the 1st case, no additional integration is required. In the 2nd case your web site shall use HTTPS and support TLS 1.2. A web site’s domain shall be previously registered and confirmed in Google.
A direct integration assumes a use of a client (javascript) part and a server one. At a client you verify that a device is compatible and obtain payment data, and on a server you send a request for payment to API.
Sample js code:

//в примере используется библиотека jquery
var allowedPaymentMethods = ['CARD', 'TOKENIZED_CARD'];
var allowedCardNetworks = ['MASTERCARD', 'VISA']; 
var tokenizationParameters = {
    tokenizationType: 'PAYMENT_GATEWAY',
    parameters: {
        'gateway': 'cloudpayments',
        'gatewayMerchantId': 'pk_b9fa79f3d759c56a9b856d8ac59b1' //ваш public id
    }
}
function getGooglePaymentsClient() {
    return (new google.payments.api.PaymentsClient({ environment: 'PRODUCTION' }));
}

//обработчик загрузки Google Pay API
function onGooglePayLoaded() {
    var paymentsClient = getGooglePaymentsClient();
    //проверка устройства
    paymentsClient.isReadyToPay({ allowedPaymentMethods: allowedPaymentMethods })
        .then(function (response) {
            if (response.result) {
                $('#gpay-checkout').show(); //включение кнопки
                $('#gpay-checkout').click(onGooglePaymentButtonClicked);
            }
        });
}

//настройки
function getGooglePaymentDataConfiguration() {
    return {
        merchantId: '04349806409183181471', //выдается после регистрации в Google
        paymentMethodTokenizationParameters: tokenizationParameters,
        allowedPaymentMethods: allowedPaymentMethods,
        cardRequirements: {
            allowedCardNetworks: allowedCardNetworks
        }
    };
}

//информация о транзакции
function getGoogleTransactionInfo() {
    return {
        currencyCode: 'RUB',
        totalPriceStatus: 'FINAL',
        totalPrice: '10.00'
    };
}

//обработчик кнопки
function onGooglePaymentButtonClicked() {
    var paymentDataRequest = getGooglePaymentDataConfiguration();
    paymentDataRequest.transactionInfo = getGoogleTransactionInfo();

    var paymentsClient = getGooglePaymentsClient();
    paymentsClient.loadPaymentData(paymentDataRequest)
        .then(function (paymentData) {
            processPayment(paymentData);
        });
}            

//обработка платежа
function processPayment(paymentData) {
    var data = {
        cryptogram: JSON.stringify(paymentData.paymentMethodToken.token)
    };

    // отправьте запрос на ваш сервер, а далее запросите API CloudPayments
    // для проведения оплаты 
    $.post("/GooglePay/Pay", data).then(function (result) {
        if (result.Success) {
            //оплата успешно завершена
        } else {
            if (result.Model.PaReq) { 
                //требуется 3-d secure
            } else {
                //оплата отклонена
            }
        }
    });
}