Google Pay

Google Pay™ lets your customers pay with the press of a button — using payment methods saved to their Google Account.

Customer payment data is end-to-end encrypted from Google’s servers to your payment processor.

Google Pay works with your existing payments processing stack and can be implemented with a few lines of code.

Web integration using Google Pay API

Please review following documentations before continuing:

Load required libraries

1
<script src="https://pay.google.com/gp/p/js/pay.js"></script>

Set tokenizationSpecification and card networks as follows:

1
2
3
4
5
6
7
8
9
10
const tokenizationSpecification = {
  type: 'PAYMENT_GATEWAY',
  parameters: {
    'gateway': 'paylane',
    'gatewayMerchantId': 'YOUR_PUBLIC_API_KEY'
  }
};

const allowedCardNetworks = ['MASTERCARD', 'VISA'];
const allowedCardAuthMethods = ['PAN_ONLY', 'CRYPTOGRAM_3DS'];
You can see your PUBLIC_API_KEY in Merchant Panel under Admin Console > Integration.

Web integration using PayLane JS Client

Load required libraries

1
2
<script src="https://pay.google.com/gp/p/js/pay.js"></script>
<script src="https://js.paylane.com/v1"></script>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// set up PayLane JS client
PayLane.setPublicApiKey('MY_PUBLIC_API_KEY');

// set up Google Pay with production Account
PayLane.googlePay.init({ environment: 'PRODUCTION',  googleMerchantId: 'ID FROM GOOGLE'});

// prepare basic transaction data
const TRANSACTION = {
  currencyCode: "USD",
  totalPrice: "1.00"
};

// check whether Google pay is available
PayLane.googlePay
  .isReadyToPay()
  .then(function(response) {
    if (response.result) {
      // proceed
      showGooglePayBtn();
    } else {
      console.warn("Google Pay is not available");
    }
  })
  .catch(function(err) {
    // handle errors here
    console.error(err);
  });

const showGooglePayBtn = function() {
  // create Google Pay button
  const button = PayLane.googlePay.createButton({
    onClick: onGooglePaymentButtonClicked
  });

  // append button
  document.getElementById('container').appendChild(button);
};

const onGooglePaymentButtonClicked = function() {
  PayLane.googlePay
    .loadPayment(TRANSACTION)
    .then(function(paymentData) {
      // extract and encode payment token
      const token = btoa(paymentData.paymentMethodData.tokenizationData.token);

      // pass required transaction data along with the `token` to your backend
      // application and perform transaction
    })
    .catch(function(err) {
      // handle errors here
      console.error(err);
    });
};

Perform transaction using PayLane Rest Client

Before you start calling any API methods regarding card operations, please make sure that you have properly initiated the PayLane Rest Client. It’s very easy, simply include a proper file and provide your user name and password.

1
2
include_once ('PayLaneRestClient.php');
$client = new PayLaneRestClient('your_login', 'your_password');