This section explains how to integrate Google Pay using the Novalnet Flutter SDK.
Before integrating Google Pay, ensure the following:
The merchant must configure the following in their Google Pay Console:
Add the stable version of PAY plugin under dependencies in pubspec.yaml file.
Run flutter pub get to fetch and install the dependencies.
Note: Whenever you make changes or updates to the dependencies, run the flutter pub get command to apply and fetch the updated packages
Indentation Notes :
dependencies: must be at the root level (no spaces before it)
pay: must be indented with 2 spaces under dependencies
YAML is space-sensitive, so incorrect indentation will cause errors
After adding the dependency, import the Packages in your Google Pay integration file.
This configuration defines how Google Pay should process the payment request in your Flutter app. It includes supported payment methods, gateway details, transaction amount, currency, and merchant information shown to the user. The JSON is passed to the pay plugin to initialize and display the Google Pay sheet. Make sure to replace all placeholder values with your actual merchant and transaction details before use.
|
Field
|
Placeholder / Value
|
Description
|
environment |
ENVIRONMENT |
Defines the mode (TEST or PRODUCTION) |
type |
CARD (fixed) |
Payment method type (predefined, do not change) |
allowedAuthMethods |
["PAN_ONLY","CRYPTOGRAM_3DS"] (fixed) |
Supported authentication methods (predefined) |
allowedCardNetworks |
["VISA","MASTERCARD"] (configurable) |
Supported card networks |
tokenizationSpecification.type |
PAYMENT_GATEWAY (fixed) |
Defines how payment data is processed (via gateway) |
gateway |
GATEWAY |
Payment gateway provider name |
gatewayMerchantId |
YOUR_GATEWAY_MERCHANT_ID |
Merchant ID provided by the gateway |
totalPriceStatus |
FINAL (fixed) |
Indicates final transaction amount (do not change) |
totalPrice |
TOTAL_AMOUNT |
Payment amount (2 decimals, use dot) |
currencyCode |
CURRENCY |
ISO currency code (e.g., EUR, USD, INR) |
merchantName |
MERCHANT_NAME |
Name shown in Google Pay payment sheet |
|
Environment
|
Usage
|
|
Test
|
No real money, used during development
|
|
Production
|
Real payments
|
This step checks whether the device is fully ready to make a Google Pay payment before starting the payment flow. It initializes the payment configuration and uses the userCanPay method to verify support. If canPay returns false, it means Google Pay cannot be used on the device. This typically happens if Google Pay not set up, no supported card is added, or the device/region does not support Google Pay. It can also occur if there is a configuration issue (e.g., incorrect environment or merchant setup).
This step defines the payment amount and displays the Google Pay button to the user. When the user completes the payment, the response is returned via onPaymentResult and stored in resultData.
Result Data contains the payment response, including the signature, payment token, and encrypted payment data. Once received successfully, this data must be sent to Novalnet for processing and transaction booking.
After receiving the payment response from Google Pay, the token must be sent to Novalnet for decryption and transaction processing.
The SDK will handle token decryption and complete the transaction processing.
This example provides a complete end-to-end implementation of Google Pay integration using the Flutter pay plugin. It includes configuration setup, availability check, payment UI handling, and capturing the payment response. Developers can use this as a ready-to-use reference to integrate Google Pay quickly. The returned resultData should be sent to Novalnet for final payment processing.
The following example demonstrates how to initiate Google Pay when the button is pressed. This is a basic example, and you can handle the response and flow based on your application requirements: