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

Side by Side Diff: ios/chrome/browser/payments/payment_request_coordinator.mm

Issue 2733953003: [Payments] Return a basic card response (Closed)
Patch Set: addressed comments from anthony Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/payments/payment_request_coordinator.h" 5 #import "ios/chrome/browser/payments/payment_request_coordinator.h"
6 6
7 #include <unordered_set> 7 #include <unordered_set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "components/autofill/core/browser/autofill_client.h" 14 #include "components/autofill/core/browser/autofill_client.h"
15 #include "components/autofill/core/browser/autofill_data_util.h" 15 #include "components/autofill/core/browser/autofill_data_util.h"
16 #include "components/autofill/core/browser/autofill_profile.h" 16 #include "components/autofill/core/browser/autofill_profile.h"
17 #include "components/autofill/core/browser/credit_card.h" 17 #include "components/autofill/core/browser/credit_card.h"
18 #include "components/autofill/core/browser/field_types.h" 18 #include "components/autofill/core/browser/field_types.h"
19 #include "components/autofill/core/browser/payments/full_card_request.h" 19 #include "components/autofill/core/browser/payments/full_card_request.h"
20 #include "components/autofill/core/browser/personal_data_manager.h" 20 #include "components/autofill/core/browser/personal_data_manager.h"
21 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h" 21 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h"
22 #include "components/payments/core/payment_address.h"
23 #include "components/payments/core/payment_request_data_util.h"
22 #include "components/strings/grit/components_strings.h" 24 #include "components/strings/grit/components_strings.h"
23 #include "ios/chrome/browser/application_context.h" 25 #include "ios/chrome/browser/application_context.h"
24 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 26 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
25 #include "ios/chrome/browser/payments/payment_request.h" 27 #include "ios/chrome/browser/payments/payment_request.h"
26 #include "ios/chrome/browser/payments/payment_request_util.h" 28 #include "ios/chrome/browser/payments/payment_request_util.h"
27 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h" 29 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h"
28 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
29 31
30 #if !defined(__has_feature) || !__has_feature(objc_arc) 32 #if !defined(__has_feature) || !__has_feature(objc_arc)
31 #error "This file requires ARC support." 33 #error "This file requires ARC support."
32 #endif 34 #endif
33 35
34 namespace { 36 namespace {
35 using ::payment_request_util::GetBasicCardResponseFromAutofillCreditCard; 37 using ::payments::data_util::GetBasicCardResponseFromAutofillCreditCard;
36 using ::payment_request_util::GetPaymentAddressFromAutofillProfile; 38 using ::payments::data_util::GetPaymentAddressFromAutofillProfile;
37 } // namespace 39 } // namespace
38 40
39 // The unmask prompt UI for Payment Request. 41 // The unmask prompt UI for Payment Request.
40 class PRCardUnmaskPromptViewBridge 42 class PRCardUnmaskPromptViewBridge
41 : public autofill::CardUnmaskPromptViewBridge { 43 : public autofill::CardUnmaskPromptViewBridge {
42 public: 44 public:
43 explicit PRCardUnmaskPromptViewBridge( 45 explicit PRCardUnmaskPromptViewBridge(
44 autofill::CardUnmaskPromptController* controller, 46 autofill::CardUnmaskPromptController* controller,
45 UIViewController* base_view_controller) 47 UIViewController* base_view_controller)
46 : autofill::CardUnmaskPromptViewBridge(controller), 48 : autofill::CardUnmaskPromptViewBridge(controller),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 190 }
189 191
190 - (void)fullCardRequestDidSucceedWithCard:(const autofill::CreditCard&)card 192 - (void)fullCardRequestDidSucceedWithCard:(const autofill::CreditCard&)card
191 CVC:(const base::string16&)cvc { 193 CVC:(const base::string16&)cvc {
192 web::PaymentResponse paymentResponse; 194 web::PaymentResponse paymentResponse;
193 195
194 paymentResponse.method_name = 196 paymentResponse.method_name =
195 base::ASCIIToUTF16(autofill::data_util::GetPaymentRequestData(card.type()) 197 base::ASCIIToUTF16(autofill::data_util::GetPaymentRequestData(card.type())
196 .basic_card_payment_type); 198 .basic_card_payment_type);
197 199
198 paymentResponse.details = 200 paymentResponse.details = GetBasicCardResponseFromAutofillCreditCard(
199 GetBasicCardResponseFromAutofillCreditCard(*_paymentRequest, card, cvc); 201 card, cvc, _paymentRequest->billing_profiles(),
202 GetApplicationContext()->GetApplicationLocale());
200 203
201 if (_paymentRequest->payment_options().request_shipping) { 204 if (_paymentRequest->payment_options().request_shipping) {
202 autofill::AutofillProfile* shippingAddress = 205 autofill::AutofillProfile* shippingAddress =
203 _paymentRequest->selected_shipping_profile(); 206 _paymentRequest->selected_shipping_profile();
204 // TODO(crbug.com/602666): User should get here only if they have selected 207 // TODO(crbug.com/602666): User should get here only if they have selected
205 // a shipping address. 208 // a shipping address.
206 DCHECK(shippingAddress); 209 DCHECK(shippingAddress);
207 paymentResponse.shipping_address = 210 paymentResponse.shipping_address = GetPaymentAddressFromAutofillProfile(
208 GetPaymentAddressFromAutofillProfile(*shippingAddress); 211 *shippingAddress, GetApplicationContext()->GetApplicationLocale());
209 212
210 web::PaymentShippingOption* shippingOption = 213 web::PaymentShippingOption* shippingOption =
211 _paymentRequest->selected_shipping_option(); 214 _paymentRequest->selected_shipping_option();
212 DCHECK(shippingOption); 215 DCHECK(shippingOption);
213 paymentResponse.shipping_option = shippingOption->id; 216 paymentResponse.shipping_option = shippingOption->id;
214 } 217 }
215 218
216 if (_paymentRequest->payment_options().request_payer_name) { 219 if (_paymentRequest->payment_options().request_payer_name) {
217 autofill::AutofillProfile* contactInfo = 220 autofill::AutofillProfile* contactInfo =
218 _paymentRequest->selected_contact_profile(); 221 _paymentRequest->selected_contact_profile();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 392 }
390 393
391 #pragma mark - ShippingAddressSelectionCoordinatorDelegate 394 #pragma mark - ShippingAddressSelectionCoordinatorDelegate
392 395
393 - (void)shippingAddressSelectionCoordinator: 396 - (void)shippingAddressSelectionCoordinator:
394 (ShippingAddressSelectionCoordinator*)coordinator 397 (ShippingAddressSelectionCoordinator*)coordinator
395 didSelectShippingAddress: 398 didSelectShippingAddress:
396 (autofill::AutofillProfile*)shippingAddress { 399 (autofill::AutofillProfile*)shippingAddress {
397 _pendingShippingAddress = shippingAddress; 400 _pendingShippingAddress = shippingAddress;
398 DCHECK(shippingAddress); 401 DCHECK(shippingAddress);
399 web::PaymentAddress address = 402 payments::PaymentAddress address = GetPaymentAddressFromAutofillProfile(
400 GetPaymentAddressFromAutofillProfile(*shippingAddress); 403 *shippingAddress, GetApplicationContext()->GetApplicationLocale());
401 [_delegate paymentRequestCoordinator:self didSelectShippingAddress:address]; 404 [_delegate paymentRequestCoordinator:self didSelectShippingAddress:address];
402 } 405 }
403 406
404 - (void)shippingAddressSelectionCoordinatorDidReturn: 407 - (void)shippingAddressSelectionCoordinatorDidReturn:
405 (ShippingAddressSelectionCoordinator*)coordinator { 408 (ShippingAddressSelectionCoordinator*)coordinator {
406 // Clear the 'Updated' label on the payment summary item, if there is one. 409 // Clear the 'Updated' label on the payment summary item, if there is one.
407 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; 410 [_viewController updatePaymentSummaryWithTotalValueChanged:NO];
408 411
409 [_shippingAddressSelectionCoordinator stop]; 412 [_shippingAddressSelectionCoordinator stop];
410 _shippingAddressSelectionCoordinator = nil; 413 _shippingAddressSelectionCoordinator = nil;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 - (void)paymentMethodSelectionCoordinatorDidReturn: 451 - (void)paymentMethodSelectionCoordinatorDidReturn:
449 (PaymentMethodSelectionCoordinator*)coordinator { 452 (PaymentMethodSelectionCoordinator*)coordinator {
450 // Clear the 'Updated' label on the payment summary item, if there is one. 453 // Clear the 'Updated' label on the payment summary item, if there is one.
451 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; 454 [_viewController updatePaymentSummaryWithTotalValueChanged:NO];
452 455
453 [_methodSelectionCoordinator stop]; 456 [_methodSelectionCoordinator stop];
454 _methodSelectionCoordinator = nil; 457 _methodSelectionCoordinator = nil;
455 } 458 }
456 459
457 @end 460 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698