Android Only
The GooglePayButton
is a Composable function used to render a button that initiates a Google Pay payment. It can be used as an optional component if the merchant wants to control their own button UI.
Parameters
Parameter | Description |
---|---|
modifier |
The modifier to apply to this layout. |
radius |
The corner radius of the button. |
buttonType |
The type of button to display. |
billingAddress |
The billing address to use for the payment. |
Example Usage
Compose Multiplatform
GooglePayButton(
modifier = Modifier,
radius = 16.dp,
buttonType = GooglePayButtonType.Pay,
billingAddress = billingAddress
)
Android View
<com.accesspaysuite.mobilesdk.ui.googlepay.GooglePayButtonView
android:id="@+id/googlePayButton"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
val googlePayButton = findViewById<GooglePayButtonView>(R.id.googlePayButton)
googlePayButton.billingAddress = myBillingAddress
googlePayButton.radius = 24.dp
googlePayButton.buttonType = GooglePayButtonType.Pay
Using your own button
You are not limited in using our own Google Pay button in order to process the payment, you can use in fact any button or UI you like. However you will need to launch a specific function in order to do so.
Manually launch Google Pay Payment
Requirements
- The
PaymentResultCallback
must be set before starting a Google Pay payment - The
PaymentProcessor
must be initiated before starting a Google Pay payment - The Google Pay Payment Method must be an accepted payment method
Check the availability:
Compose
For setup you will require to use the following composable-scoped function in your UI screen. The function is available at import com.accesspaysuite.mobilesdk.modules.InitiateGooglePay
InitiateGooglePay()
Android Activity
For setup you will require to use the following function in your Activity root class. The same function is available for ComponentActivity
inherited Activities and Fragments.
...
import com.accesspaysuite.mobilesdk.modules.initiateGooglePay
class MainActivity : ComponentActivity() {
...
@Suppress("unused")
private val _initiateGooglePay = initiateGooglePay()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
}
}
Android Fragment
...
import com.accesspaysuite.mobilesdk.modules.initiateGooglePay
class FragmentGooglePay: Fragment() {
@Suppress("unused")
private val _initiateGooglePay = initiateGooglePay()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return ...
}
}
Usage
Using the Payment Processor class, run the following method:
processor.processGooglePayPayment(billingAddress)