Google Pay

This document will guide you on how to correctly integrate Google Pay via PowerBoard.

Google Pay

This document will guide you on how to correctly integrate Google Pay via PowerBoard.

googlepay icon

🚧

Before you begin

When sending requests to PowerBoard’s API, you must provide either a Public Key and/or Secret Key depending on your use case.

API keys are generated via PowerBoard’s Merchant Dashboard, in three easy steps:

  1. Login to the PowerBoard Merchant Dashboard.
  2. Click on the ‘My Company’ link and proceed to the ‘API and Security’ heading.
  3. On screen, you’ll see both Public and Secret Key required to send requests to PowerBoard’s API.

❗️

Third-Party Requirements

Your integration will utilise the following components:

  • PowerBoard Client-SDK ('Widget')
  • PowerBoard REST API

Integration Steps

Step 1) Create a PowerBoard 'Wallet' Token (API)

API Endpointhttps://api.preproduction.powerboard.commbank.com.au/v1/charges/wallet
HTTP Method
POST
Headersx-user-secret-key- POWERBOARD_SECRET_KEY - This is your PowerBoard API Secret Key.
Content-Type - application/jsonContent - Type will always be application/json.
Request Parametersamount - string - Total amount for your Google Pay transaction.
transactions.currency - string - Always set to 'AUD'.
reference - string - Reference for the transaction. This reference may assist to identify the transaction in your back-end systems. For example, a purchase order number or invoice number.
customer.first_name - string - Customer First Name.
customer.last_name - string - Customer Last Name.
customer.email - string - Customer email address.
customer.payment_source.gateway_id - string - Unique Gateway ID for your PowerBoard Card + Google Pay service.

PowerBoard will return a '201 Created' response with the following fields:

  {

                "amount": 145,
                "reference": "reference",
                "description": "description",
                "currency": "AUD",
                "customer": {
                    "email": "[email protected]",
                    "first_name": "Google Pay WalletButton",
                    "last_name": "Citizen",
                    "phone": "+5555555555",
                    "payment_source": {
                        "gateway_id": "YOUR GATEWAY ID",
                        "address_line1": "asd1",
                        "address_line2": "asd2",
                        "address_line3": "asd3",
                        "address_city": "city",
                        "address_state": "state",
                        "address_country": "US",
                        "address_postcode": "12345"
                    }
                }

            }

{
    "status": 201,
    "error": null,
    "resource": {
        "type": "charge",
        "data": {
            "token": "YOUR_WALLET_TOKEN",
            "charge": {
                "_id": "63fd93c3d8e7552c56047752",
                "amount": 1,
                "currency": "AUD",
                "reference": "2023-02-28T05:40:18.905Z",
                "company_id": "63cf32a154a870183bf2398a",
                "description": "2023-02-28T05:40:18.905Z",
                "type": "financial",
                "status": "wallet_initialized",
                "capture": true,
                "authorization": false,
                "one_off": true,
                "amount_surcharge": null,
                "amount_original": null,
                "created_at": "2023-02-28T05:40:19.545Z",
                "updated_at": "2023-02-28T05:40:19.545Z",
                "schedule": {
                    "stopped": false
                },
                "archived": false,
                "meta": {},
                "customer": {
                    "payment_source": {
                        "type": "wallet",
                        "wallet_type": null,
                        "gateway_id": "YOUR_GATEWAY_ID",
                        "gateway_name": "CommWeb",
                        "gateway_type": "MasterCard"
                    }
                },
                "transactions": [],
                "shipping": {},
                "items": []
            }
        }
    }
}

Step 2) Create and initialise the PowerBoard Widget

  • Embed PowerBoard's Client-SDK in your page.
  • Create a container for the PowerBoard widget.
  • Set the PowerBoard Widget environment to 'preproduction_cba'.
  • Configure cba.WalletButtons class:
    • amount_label
    • country
  • Callbacks
    • onUnavailable
      • No wallet buttons available.
    • onPaymentSuccessful
      • Payment was successful.
    • onPaymentError
      • The payment was not successful.
    • onPaymentInReview
      • The payment is in fraud review by the wallet service.
  • Initialise the Widget with the .load method.
<div id="widget-google-Pay">
  
<script src="https://widget.preproduction.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js"></script>
  
<script>
let button = new cba.WalletButtons("#widget-google-Pay", "YOUR_WALLET_TOKEN",
     {
        amount_label: "Payment Amount",
        country: "AU"
     }
    )
    button.setEnv('preproduction_cba');
    button.onUnavailable(() => console.log("No wallet buttons available"));    
    button.onPaymentSuccessful((data) => console.log('Payment Data', data));          
    button.onPaymentError((data) => console.log("The payment was not successful"));
    button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
    button.load();
}
</script>

After the payment is completed (successfully) the onPaymentSuccessful call-back will trigger.

If the payment was not successful, the onPaymentError call-back will trigger.

onPaymentSuccessful(data) example

{
    "event": "paymentSuccessful",
    "data": {
        "id": "640691b748533262f6508ef7",
        "amount": 1,
        "currency": "AUD",
        "status": "complete"
    }
}
Charge logs