0

[Autofill] Pass extracted amount to InitBnplFlow

This passes the extracted amount from the Suggestion payload into the
InitBnplFlow call.

Bug: 356443046, b:401564124
Change-Id: I90dfa8193f24f74ba4b3aec30da326d5576ef1b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6330773
Commit-Queue: Nick Navarro <npnavarro@chromium.org>
Reviewed-by: Slobodan Pejic <slobodan@chromium.org>
Reviewed-by: Olivia Saul <jsaul@google.com>
Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1431048}
This commit is contained in:
Nick Navarro
2025-03-11 11:56:20 -07:00
committed by Chromium LUCI CQ
parent 65aace4795
commit 136323443a
2 changed files with 13 additions and 4 deletions

@@ -1377,12 +1377,15 @@ void AutofillExternalDelegate::DidAcceptPaymentsSuggestion(
GetWeakPtr()));
break;
case SuggestionType::kBnplEntry:
// TODO(crbug.com/401564124): Update checkout Amount.
CHECK(suggestion.GetPayload<Suggestion::PaymentsPayload>()
.extracted_amount_in_micros.has_value());
manager_->client()
.GetPaymentsAutofillClient()
->GetPaymentsBnplManager()
->InitBnplFlow(
/*final_checkout_amount=*/0,
/*final_checkout_amount=*/suggestion
.GetPayload<Suggestion::PaymentsPayload>()
.extracted_amount_in_micros.value(),
base::BindOnce(
[](base::WeakPtr<AutofillExternalDelegate> delegate,
const CreditCard& card) {

@@ -810,17 +810,23 @@ TEST_F(AutofillExternalDelegateTest, AcceptedBnplEntry_FormIsFilled) {
CreditCard card = test::GetVirtualCard();
card.set_issuer_id(payments::BnplManager::GetSupportedBnplIssuerIds()[0]);
const uint64_t expected_amount = 50'000'000;
EXPECT_CALL(
client().GetPaymentsAutofillClient()->CreateOrGetMockBnplManager(),
InitBnplFlow)
InitBnplFlow(expected_amount, _))
.WillOnce(RunOnceCallback<1>(card));
EXPECT_CALL(manager(),
FillOrPreviewCreditCardForm(
mojom::ActionPersistence::kFill, HasQueriedFormId(),
IsQueriedFieldId(), card, AutofillTriggerSource::kPopup));
Suggestion::PaymentsPayload payments_payload;
payments_payload.extracted_amount_in_micros = expected_amount;
external_delegate().DidAcceptSuggestion(
test::CreateAutofillSuggestion(SuggestionType::kBnplEntry), {});
test::CreateAutofillSuggestion(SuggestionType::kBnplEntry,
/*main_text_value=*/u"BNPL suggestion",
payments_payload),
{});
}
// Test that the Autofill popup is able to display warnings explaining why