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

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

Issue 2803543005: [Payments] iOS: Support basic-card (Closed)
Patch Set: Created 3 years, 8 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"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 autofill::CreditCard* card = _paymentRequest->selected_credit_card(); 201 autofill::CreditCard* card = _paymentRequest->selected_credit_card();
202 _fullCardRequester = base::MakeUnique<FullCardRequester>( 202 _fullCardRequester = base::MakeUnique<FullCardRequester>(
203 self, _navigationController, _browserState); 203 self, _navigationController, _browserState);
204 _fullCardRequester->GetFullCard(card, _autofillManager); 204 _fullCardRequester->GetFullCard(card, _autofillManager);
205 } 205 }
206 206
207 - (void)fullCardRequestDidSucceedWithCard:(const autofill::CreditCard&)card 207 - (void)fullCardRequestDidSucceedWithCard:(const autofill::CreditCard&)card
208 CVC:(const base::string16&)cvc { 208 CVC:(const base::string16&)cvc {
209 web::PaymentResponse paymentResponse; 209 web::PaymentResponse paymentResponse;
210 210
211 // If the merchant specified the card network as part of the "basic-card"
212 // payment method, return "basic-card" as the method_name. Otherwise, return
213 // the name of the network directly.
214 std::string basic_card_type =
215 autofill::data_util::GetPaymentRequestData(card.type())
216 .basic_card_payment_type;
211 paymentResponse.method_name = 217 paymentResponse.method_name =
212 base::ASCIIToUTF16(autofill::data_util::GetPaymentRequestData(card.type()) 218 _paymentRequest->basic_card_specified_networks().count(basic_card_type)
Moe 2017/04/06 20:51:03 nit: find() demonstrates the intent more clearly.
Mathieu 2017/04/06 21:04:41 Done.
213 .basic_card_payment_type); 219 ? base::ASCIIToUTF16("basic-card")
220 : base::ASCIIToUTF16(basic_card_type);
214 221
215 paymentResponse.details = GetBasicCardResponseFromAutofillCreditCard( 222 paymentResponse.details = GetBasicCardResponseFromAutofillCreditCard(
216 card, cvc, _paymentRequest->billing_profiles(), 223 card, cvc, _paymentRequest->billing_profiles(),
217 GetApplicationContext()->GetApplicationLocale()); 224 GetApplicationContext()->GetApplicationLocale());
218 225
219 if (_paymentRequest->payment_options().request_shipping) { 226 if (_paymentRequest->payment_options().request_shipping) {
220 autofill::AutofillProfile* shippingAddress = 227 autofill::AutofillProfile* shippingAddress =
221 _paymentRequest->selected_shipping_profile(); 228 _paymentRequest->selected_shipping_profile();
222 // TODO(crbug.com/602666): User should get here only if they have selected 229 // TODO(crbug.com/602666): User should get here only if they have selected
223 // a shipping address. 230 // a shipping address.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 - (void)paymentMethodSelectionCoordinatorDidReturn: 473 - (void)paymentMethodSelectionCoordinatorDidReturn:
467 (PaymentMethodSelectionCoordinator*)coordinator { 474 (PaymentMethodSelectionCoordinator*)coordinator {
468 // Clear the 'Updated' label on the payment summary item, if there is one. 475 // Clear the 'Updated' label on the payment summary item, if there is one.
469 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; 476 [_viewController updatePaymentSummaryWithTotalValueChanged:NO];
470 477
471 [_methodSelectionCoordinator stop]; 478 [_methodSelectionCoordinator stop];
472 _methodSelectionCoordinator = nil; 479 _methodSelectionCoordinator = nil;
473 } 480 }
474 481
475 @end 482 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698