Skip to content

Commit

Permalink
Add optional amountLabel for PI
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Aug 23, 2023
1 parent 58b18f1 commit c143196
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,19 @@ class GooglePayLauncher internal constructor(
*
* @param clientSecret the PaymentIntent's [client secret](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret)
*/
fun presentForPaymentIntent(clientSecret: String) {
fun presentForPaymentIntent(
clientSecret: String,
amountLabel: String? = null,
) {
check(isReady) {
"presentForPaymentIntent() may only be called when Google Pay is available on this device."
}

activityResultLauncher.launch(
GooglePayLauncherContract.PaymentIntentArgs(
clientSecret = clientSecret,
config = config
config = config,
amountLabel = amountLabel,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class GooglePayLauncherContract :
@Parcelize
data class PaymentIntentArgs(
override val clientSecret: String,
override val config: GooglePayLauncher.Config
override val config: GooglePayLauncher.Config,
internal val amountLabel: String? = null,
) : Args()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ internal class GooglePayLauncherViewModel(
createTransactionInfo(
stripeIntent = intent,
currencyCode = intent.currency.orEmpty(),
amountLabel = args.amountLabel,
)
}
}
Expand Down

0 comments on commit c143196

Please sign in to comment.