Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* GooglePay
* Add optional `resultKey` parameter to `GooglePayLauncher` constructors, allowing a unique registration key per launcher instance
* Add optional `transactionId` property to `GooglePayRequest` to pass a merchant-defined transaction identifier to Google Pay's `TransactionInfo`
* ThreeDSecure
* Add optional `resultKey` parameter to `ThreeDSecureLauncher` constructors, allowing a unique registration key per launcher instance
* SEPADirectDebit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ class GooglePayClientTest {
totalPrice = "25.50",
totalPriceStatus = GooglePayTotalPriceStatus.TOTAL_PRICE_STATUS_ESTIMATED,
countryCode = "DE",
googleMerchantName = "Test Merchant"
googleMerchantName = "Test Merchant",
transactionId = "transaction-id-123"
)

val countDownLatch = CountDownLatch(1)
Expand All @@ -263,6 +264,7 @@ class GooglePayClientTest {
val transactionInfo = paymentDataRequestJson.getJSONObject("transactionInfo")
assertEquals("EUR", transactionInfo.getString("currencyCode"))
assertEquals("25.50", transactionInfo.getString("totalPrice"))
assertEquals("transaction-id-123", transactionInfo.getString("transactionId"))
assertEquals("ESTIMATED", transactionInfo.getString("totalPriceStatus"))
assertEquals("DE", transactionInfo.getString("countryCode"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class GooglePayRequestTest {
totalPriceLabel = "Total",
allowCreditCards = false,
displayItems = displayItems,
checkoutOption = GooglePayCheckoutOption.COMPLETE_IMMEDIATE_PURCHASE
checkoutOption = GooglePayCheckoutOption.COMPLETE_IMMEDIATE_PURCHASE,
transactionId = "transaction-id-123"
)
request.setEnvironment("production")

Expand Down Expand Up @@ -83,6 +84,7 @@ class GooglePayRequestTest {
assertEquals("Subtotal", parceled.displayItems[0].label)
assertEquals("Tax", parceled.displayItems[1].label)
assertEquals(GooglePayCheckoutOption.COMPLETE_IMMEDIATE_PURCHASE, parceled.checkoutOption)
assertEquals("transaction-id-123", parceled.transactionId)
assertEquals("PRODUCTION", parceled.getEnvironment())

parcel.recycle()
Expand Down Expand Up @@ -119,6 +121,7 @@ class GooglePayRequestTest {
assertTrue(parceled.allowCreditCards)
assertTrue(parceled.displayItems.isEmpty())
assertEquals(GooglePayCheckoutOption.DEFAULT, parceled.checkoutOption)
assertNull(parceled.transactionId)
assertNull(parceled.getEnvironment())

parcel.recycle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ import java.util.Locale
* @property displayItems Optional list of cart items shown in the payment sheet
* (e.g. subtotals, sales taxes, shipping charges, discounts etc.). If you pass non-empty list of display items
* be sure to also set the value for [totalPriceLabel].
* @property transactionId Optional. A unique ID that identifies a transaction attempt. Merchants
* may use an existing ID or generate a specific one for Google Pay transactions. This field is
* optional, but merchants are strongly encouraged to add it for the best troubleshooting
* experience with Google.
*/
@Suppress("TooManyFunctions")
@Parcelize
Expand All @@ -61,6 +65,7 @@ class GooglePayRequest @JvmOverloads constructor(
var allowCreditCards: Boolean = true,
var displayItems: MutableList<GooglePayDisplayItem> = ArrayList(),
var checkoutOption: GooglePayCheckoutOption? = GooglePayCheckoutOption.DEFAULT,
var transactionId: String? = null,
private var environment: String? = null,
private val allowedPaymentMethods: MutableMap<String, String> = HashMap(),
private val tokenizationSpecifications: MutableMap<String, String> = HashMap(),
Expand Down Expand Up @@ -155,6 +160,7 @@ class GooglePayRequest @JvmOverloads constructor(
}
transactionInfoJson.putOpt("totalPriceLabel", totalPriceLabel)
transactionInfoJson.putOpt("checkoutOption", checkoutOption?.stringValue)
transactionInfoJson.putOpt("transactionId", transactionId)

for ((key, value) in this.allowedPaymentMethods) {
try {
Expand Down
Loading