Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: ios/chrome/browser/payments/payment_request_util.mm

Issue 2956453003: [Payment Request] Makes sure only complete credit cards can be selected (Closed)
Patch Set: Fixed unit test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/payments/payment_request_util.mm
diff --git a/ios/chrome/browser/payments/payment_request_util.mm b/ios/chrome/browser/payments/payment_request_util.mm
index 3b643adf7075932e797e1499d83db0b685fa8048..07595166e1f3500e4d6e0b96cf7e6166afdd5b0f 100644
--- a/ios/chrome/browser/payments/payment_request_util.mm
+++ b/ios/chrome/browser/payments/payment_request_util.mm
@@ -9,8 +9,10 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_profile.h"
+#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/personal_data_manager.h"
+#include "components/autofill/core/browser/validation.h"
#include "components/payments/core/payment_request_data_util.h"
#include "components/payments/core/strings_util.h"
#include "components/strings/grit/components_strings.h"
@@ -71,6 +73,26 @@ NSString* GetAddressNotificationLabelFromAutofillProfile(
return !label.empty() ? base::SysUTF16ToNSString(label) : nil;
}
+BOOL IsCreditCardCompleteForPayment(
+ const autofill::CreditCard& credit_card,
+ const std::vector<autofill::AutofillProfile*>& billing_profiles) {
+ // EXPIRED cards are considered valid for payment. The user will be prompted
+ // to enter the new expiration at the CVC step.
+ return autofill::GetCompletionStatusForCard(
+ credit_card, GetApplicationContext()->GetApplicationLocale(),
+ billing_profiles) <= autofill::CREDIT_CARD_EXPIRED;
+}
+
+NSString* GetPaymentMethodNotificationLabelFromCreditCard(
+ const autofill::CreditCard& credit_card,
+ const std::vector<autofill::AutofillProfile*>& billing_profiles) {
+ base::string16 label = autofill::GetCompletionMessageForCard(
+ autofill::GetCompletionStatusForCard(
+ credit_card, GetApplicationContext()->GetApplicationLocale(),
+ billing_profiles));
+ return !label.empty() ? base::SysUTF16ToNSString(label) : nil;
+}
+
NSString* GetShippingSectionTitle(payments::PaymentShippingType shipping_type) {
switch (shipping_type) {
case payments::PaymentShippingType::SHIPPING:

Powered by Google App Engine
This is Rietveld 408576698