Google Pay

Converge can integrate with Google Pay to process payments. Google Pay is available through the following Converge integration options:

  • Converge Hosted Payments Page (HPP)
  • Checkout.js
  • Buy Button

note

If 3DS is supported for your terminal, Converge will automatically enable 3DS for PAN_ONLY method.

Hosted Payments Pages

Google Pay needs to be enabled to display on the HPP at checkout. Refer to Set Up Google Pay for Your Payment PageLink opens new window for more details on how to enable Google Pay on the HPP.

Checkout.JS

To use Google Pay on the Web with Checkout.js, you must take the following steps:

  1. Include Converge Checkout.js and render Google Pay on the Web button on your page.

  2. Call initiateCheckoutJS to prepare for a session token (as shown in the example code below).

  3. Call ConvergeEmbeddedPayment.initGooglePay to initiate Google.

Example Checkout.js Integration

This is an example implementation of a Checkout.js payment form for Google Pay. This script will call for a session token generate a Google Pay button.

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Embedded Payment Demo</title>
    <script src="https://api.demo.convergepay.com/hosted-payments/Checkout.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script>
        function initiateCheckoutJS() {
            var tokenRequest = {
                ssl_amount: $("#ssl_amount").val()
            };
            $.post("checkoutjscurlrequestdevportal.php", tokenRequest, function (data) {
                document.getElementById('ssl_txn_auth_token').value = data;
                transactionToken = data;
            });
            return false;
        }
        function pay() {
            var environmentURL = $("#environment").val() + "/hosted-payments/";
            var script = document.createElement('script');
            script.src = environmentURL + "Checkout.js";
            script.onload = function () {
                var paymentData = {
                    ssl_txn_auth_token: $("#ssl_txn_auth_token").val()
                };
                var callback = {
                    onError: function (error) {
                        showResult("error", error);
                    },
                    onCancelled: function () {
                        showResult("cancelled", "");
                    },
                    onDeclined: function (response) {
                        showResult("declined", JSON.stringify(response, null, '\t'));
                        if (response.ssl_credit_surcharge_amount) {
                            console.log("Surcharge");
                            document.getElementById('sc_button').style.display = "block";
                        }
                    },
                    onApproval: function (response) {
                        showResult("approval", JSON.stringify(response, null, '\t'));
                    }
                };
                ConvergeEmbeddedPayment.initGooglePay('google-pay-button', paymentData, callback);
                return false;
            }
            document.head.appendChild(script);
            return false;
        }

        function showResult(status, msg, hash) {
            document.getElementById('txn_status').innerHTML = "<b>" + status + "</b>";
            document.getElementById('txn_response').innerHTML = msg + "</b>";
        }

        function confirmSurcharge() {
            var callback = {
                onError: function (error) {
                    showResult("error", error);
                },
                onDeclined: function (response) {
                    showResult("declined", JSON.stringify(response));
                },
                onApproval: function (response) {
                    showResult("approval", JSON.stringify(response));
                },
                onCancelled: function () {
                    showResult("cancelled", "");
                },
                onSurcharge: function (response) {
                    showResult("Surchange Approval", JSON.stringify(response));
                }
            };
            ConvergeEmbeddedPayment.creditSurchargeDecision(true, callback);
        }
    </script>

</head>

<body>
    Environment:
    <select id="environment" name="environment">
        <option value="https://demo.convergepay.com">DEMO</option>
    </select>
    <br><br>
    Transaction Token: <input id="ssl_txn_auth_token" type="text" name="ssl_txn_auth_token" value="" size="50"> <br>
    Amount: <input id="ssl_amount" type="text" name="ssl_amount" value="1.00"> <br>
    <button onclick="initiateCheckoutJS()">Initiate CheckoutJSs</button>
    <button onclick="pay()">Pay</button>
    <br>
    <button id="sc_button" style="display:none" onclick="return confirmSurcharge();">Confirm Surcharge</button>
    <br>
    <div id="google-pay-button"></div>
    <br>
    Transaction Status:<div id="txn_status"></div>
    <br>
    Transaction Response:<div id="txn_response"></div>
    <br>
    Transaction Hash Value:<div id="txn_hash"></div>

</body>
</html>

Create a serverside script to safely handle the information collected from the form.

<?php
// Set variables
$merchantID = "000000"; //Converge 6 or 7-Digit Account ID *Not the 10-Digit Elavon Merchant ID*
$merchantUserID = "webpage"; //Converge User ID *MUST FLAG AS HOSTED API USER IN CONVERGE UI*
$merchantPIN = "ENTERYOUR64PINCHARACTER"; //Converge PIN (64 CHAR A/N)

$url = "https://api.demo.convergepay.com/hosted-payments/transaction_token"; // URL to Converge demo session token server
//$url = "https://api.convergepay.com/hosted-payments/transaction_token"; // URL to Converge production session token server

// Read the following querystring variables
$firstname=$_POST['ssl_first_name']; //Post first name
$lastname=$_POST['ssl_last_name']; //Post last name
$amount= $_POST['ssl_amount']; //Post Tran Amount

$ch = curl_init();    // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch,CURLOPT_POST, true); // set POST method
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Set up the post fields. If you want to add custom fields, you would add them in Converge, and add the field name in the curlopt_postfields string.
curl_setopt($ch,CURLOPT_POSTFIELDS,
"ssl_merchant_id=$merchantID".
"&ssl_user_id=$merchantUserID".
"&ssl_pin=$merchantPIN".
"&ssl_transaction_type=ccsale".
"&ssl_first_name=$firstname".
"&ssl_last_name=$lastname".
"&ssl_get_token=Y".
"&ssl_add_token=Y".
"&ssl_amount=$amount"
);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
// curl_setopt($ch, CURLOPT_PROXY, "http://your.proxy.server:port"); // proxy server config

$result = curl_exec($ch); // run the curl process
curl_close($ch); // Close cURL

echo $result;  //shows the session token.
?>