Public
Google pay
Easy way to pay from Google.

Scheme of API server-server card payment
Receipt of payment data:

Payment service provider parameters:
const gateway = 'liqpay';

const gatewayMerchantId = 'public_key'; (Public key - store identifier. You can get the key in the  shop settings)
Available payment card networks:
const allowedCardNetworks = ["MASTERCARD", "VISA"];
Available authorization methods:
const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];
Billing and Shipping address parameters:
No any additional BillingAddress or ShippingAddress parameters are required:
Example code for displaying a button and receiving payment data for a website:
const baseRequest = {
  apiVersion: 2,
  apiVersionMinor: 0
};

const allowedCardNetworks = ["MASTERCARD", "VISA"];

const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];

const tokenizationSpecification = {
  type: 'PAYMENT_GATEWAY',
  parameters: {
    'gateway': 'liqpay',
    'gatewayMerchantId': 'your public key'
  }
};

const baseCardPaymentMethod = {
  type: 'CARD',
  parameters: {
    allowedAuthMethods: allowedCardAuthMethods,
    allowedCardNetworks: allowedCardNetworks
  }
};

const cardPaymentMethod = Object.assign(
  {},
  baseCardPaymentMethod,
  {
    tokenizationSpecification: tokenizationSpecification
  }
);

let paymentsClient = null;

function getGoogleIsReadyToPayRequest() {
  return Object.assign(
      {},
      baseRequest,
      {
        allowedPaymentMethods: [baseCardPaymentMethod]
      }
  );
}

function getGooglePaymentDataRequest() {
  const paymentDataRequest = Object.assign({}, baseRequest);
  paymentDataRequest.allowedPaymentMethods = [cardPaymentMethod];
  paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
  paymentDataRequest.merchantInfo = {
    merchantId: '12345678901234567890',    
    merchantName: 'Example Merchant'
  };
  return paymentDataRequest;
}

function getGooglePaymentsClient() {
  if ( paymentsClient === null ) {
    paymentsClient = new google.payments.api.PaymentsClient({environment: 'PRODUCTION'});
  }
  return paymentsClient;
}

function onGooglePayLoaded() {
  const paymentsClient = getGooglePaymentsClient();
  paymentsClient.isReadyToPay(getGoogleIsReadyToPayRequest())
      .then(function(response) {
        if (response.result) {
          addGooglePayButton();
        }
      })
      .catch(function(err) {
        console.error(err);
      });
}

function addGooglePayButton() {
  const paymentsClient = getGooglePaymentsClient();
  const button = paymentsClient.createButton({onClick: onGooglePaymentButtonClicked});
  document.getElementById('container').appendChild(button);
}

function getGoogleTransactionInfo() {
  return {
    countryCode: 'US',
    currencyCode: 'USD',
    totalPriceStatus: 'FINAL',
    // set to cart total
    totalPrice: '1.00'
  };
}

function prefetchGooglePaymentData() {
  const paymentDataRequest = getGooglePaymentDataRequest();
  paymentDataRequest.transactionInfo = {
    totalPriceStatus: 'NOT_CURRENTLY_KNOWN',
    currencyCode: 'USD'
  };
  const paymentsClient = getGooglePaymentsClient();
  paymentsClient.prefetchPaymentData(paymentDataRequest);
}

function onGooglePaymentButtonClicked() {
  const paymentDataRequest = getGooglePaymentDataRequest();
  paymentDataRequest.transactionInfo = getGoogleTransactionInfo();

  const paymentsClient = getGooglePaymentsClient();
  paymentsClient.loadPaymentData(paymentDataRequest)
      .then(function(paymentData) {
        processPayment(paymentData);
      })
      .catch(function(err) {
        console.error(err);
      });
}

function processPayment(paymentData) {
  const gpay_token_object = paymentData.paymentMethodData.tokenizationData.token;
  const gpay_token = btoa(gpay_token_object); // base64 encode 
  // send gpay_token to liqpay api
}
				
Payment made using received payment data:
Formation of a request to the API during self-integration:
Parameters for data formation
Parameter Required Type Description
version Required Number Version API. Current value - 3
public_key Required String Public key - the store identifier. You can get the key in the store settings
action Required String pay
paytype Required String gpay
amount Required Number Payment amount. For example: 5, 7.34
gpay_token Required String JSON string from token parameter (obtained from Google) encoded with base64 function
order_id Required String Unique purchase ID in your shop. Maximum length is 255 symbols.
currency Required String Payment currency. Possible values: USD, EUR, RUB, UAH
description Required String Payment description.
language Optional String Customer's language ru, uk, en
result_url Optional String URL of your shop where the buyer would be redirected after completion of the purchase. Maximum length 510 symbols.
server_url Optional String URL API in your store for notifications of payment status change (server->server). Maximum length is 510 symbols. Learn more
Response example
{
  "action": "pay",
  "payment_id": 165172,
  "status": "success",
  "version": 3,
  "type": "buy",
  "paytype": "gpay",
  "public_key": "i000000000",
  "acq_id": 414963,
  "order_id": "98R1U1OV1485849059893399",
  "liqpay_order_id": "NYMK3AE61501685438251925",
  "description": "description",
  "sender_phone": "380950000001",
  "sender_first_name": "first_name",
  "sender_last_name": "last_name",
  "sender_card_mask2": "473118*50",
  "sender_card_bank": "pb",
  "sender_card_type": "visa",
  "sender_card_country": 804,
  "dcc_allowed": [{
    "amount": 3.5984,
    "rate": 27.7905,
    "commission": 0.0,
    "currency": "USD"
  }],
  "ip": "8.8.8.8",
  "card_token": "CDRES215658546306B200061FCC53A86B",
  "amount": 100.0,
  "currency": "UAH",
  "sender_commission": 0.0,
  "receiver_commission": 0.0,
  "agent_commission": 0.0,
  "amount_debit": 100.0,
  "amount_credit": 100.0,
  "commission_debit": 0.0,
  "commission_credit": 0.0,
  "currency_debit": "UAH",
  "currency_credit": "UAH",
  "sender_bonus": 0.0,
  "amount_bonus": 0.0,
  "bonus_type": "bonusplus",
  "bonus_procent": 0.0,
  "authcode_debit": "388000",
  "authcode_credit": "329007",
  "rrn_debit": "000663747000",
  "rrn_credit": "000663747003",
  "mpi_eci": "7",
  "is_3ds": false,
  "create_date": 1501685446633,
  "end_date": 1501685446633,
  "transaction_id": 165172
}