OLD | NEW |
---|---|
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/ui/payments/payment_request_coordinator.h" | 5 #import "ios/chrome/browser/ui/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" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 // the name of the network directly. | 213 // the name of the network directly. |
214 std::string basic_card_type = | 214 std::string basic_card_type = |
215 autofill::data_util::GetPaymentRequestData(card.type()) | 215 autofill::data_util::GetPaymentRequestData(card.type()) |
216 .basic_card_payment_type; | 216 .basic_card_payment_type; |
217 paymentResponse.method_name = | 217 paymentResponse.method_name = |
218 _paymentRequest->basic_card_specified_networks().find(basic_card_type) != | 218 _paymentRequest->basic_card_specified_networks().find(basic_card_type) != |
219 _paymentRequest->basic_card_specified_networks().end() | 219 _paymentRequest->basic_card_specified_networks().end() |
220 ? base::ASCIIToUTF16("basic-card") | 220 ? base::ASCIIToUTF16("basic-card") |
221 : base::ASCIIToUTF16(basic_card_type); | 221 : base::ASCIIToUTF16(basic_card_type); |
222 | 222 |
223 // Get the billing address | |
224 autofill::AutofillProfile billing_address; | |
Mathieu
2017/04/25 19:27:42
Can you add a comment that if crbug.com/714768 is
sebsg
2017/04/25 19:35:23
Done.
| |
225 | |
226 // TODO(crbug.com/714768): Make sure the billing address is set and valid | |
227 // before getting here. | |
228 if (!card.billing_address_id().empty()) { | |
229 autofill::AutofillProfile* billing_address_ptr = | |
230 autofill::PersonalDataManager::GetProfileFromProfilesByGUID( | |
231 card.billing_address_id(), _paymentRequest->billing_profiles()); | |
232 if (billing_address_ptr) | |
233 billing_address = *billing_address_ptr; | |
234 } | |
235 | |
223 paymentResponse.details = GetBasicCardResponseFromAutofillCreditCard( | 236 paymentResponse.details = GetBasicCardResponseFromAutofillCreditCard( |
224 card, cvc, _paymentRequest->billing_profiles(), | 237 card, cvc, billing_address, |
225 GetApplicationContext()->GetApplicationLocale()); | 238 GetApplicationContext()->GetApplicationLocale()); |
226 | 239 |
227 if (_paymentRequest->request_shipping()) { | 240 if (_paymentRequest->request_shipping()) { |
228 autofill::AutofillProfile* shippingAddress = | 241 autofill::AutofillProfile* shippingAddress = |
229 _paymentRequest->selected_shipping_profile(); | 242 _paymentRequest->selected_shipping_profile(); |
230 // TODO(crbug.com/602666): User should get here only if they have selected | 243 // TODO(crbug.com/602666): User should get here only if they have selected |
231 // a shipping address. | 244 // a shipping address. |
232 DCHECK(shippingAddress); | 245 DCHECK(shippingAddress); |
233 paymentResponse.shipping_address = GetPaymentAddressFromAutofillProfile( | 246 paymentResponse.shipping_address = GetPaymentAddressFromAutofillProfile( |
234 *shippingAddress, GetApplicationContext()->GetApplicationLocale()); | 247 *shippingAddress, GetApplicationContext()->GetApplicationLocale()); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 - (void)paymentMethodSelectionCoordinatorDidReturn: | 492 - (void)paymentMethodSelectionCoordinatorDidReturn: |
480 (PaymentMethodSelectionCoordinator*)coordinator { | 493 (PaymentMethodSelectionCoordinator*)coordinator { |
481 // Clear the 'Updated' label on the payment summary item, if there is one. | 494 // Clear the 'Updated' label on the payment summary item, if there is one. |
482 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; | 495 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; |
483 | 496 |
484 [_methodSelectionCoordinator stop]; | 497 [_methodSelectionCoordinator stop]; |
485 _methodSelectionCoordinator = nil; | 498 _methodSelectionCoordinator = nil; |
486 } | 499 } |
487 | 500 |
488 @end | 501 @end |
OLD | NEW |