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 #include "components/payments/content/payment_request_state.h" | 5 #include "components/payments/content/payment_request_state.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "components/autofill/core/browser/autofill_data_util.h" | 9 #include "components/autofill/core/browser/autofill_data_util.h" |
10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void PaymentRequestState::RemoveObserver(Observer* observer) { | 56 void PaymentRequestState::RemoveObserver(Observer* observer) { |
57 observers_.RemoveObserver(observer); | 57 observers_.RemoveObserver(observer); |
58 } | 58 } |
59 | 59 |
60 void PaymentRequestState::OnInstrumentDetailsReady( | 60 void PaymentRequestState::OnInstrumentDetailsReady( |
61 const std::string& method_name, | 61 const std::string& method_name, |
62 const std::string& stringified_details) { | 62 const std::string& stringified_details) { |
63 // TODO(mathp): Fill other fields in the PaymentResponsePtr object. | 63 // TODO(mathp): Fill other fields in the PaymentResponsePtr object. |
64 mojom::PaymentResponsePtr payment_response = mojom::PaymentResponse::New(); | 64 mojom::PaymentResponsePtr payment_response = mojom::PaymentResponse::New(); |
65 | 65 |
66 payment_response->method_name = method_name; | 66 // Make sure that we return the method name that the merchant specified for |
| 67 // this instrument: cards can be either specified through their name (e.g., |
| 68 // "visa") or through basic-card's supportedNetworks. |
| 69 payment_response->method_name = |
| 70 spec_->IsMethodSupportedThroughBasicCard(method_name) |
| 71 ? kBasicCardMethodName |
| 72 : method_name; |
67 payment_response->stringified_details = stringified_details; | 73 payment_response->stringified_details = stringified_details; |
68 delegate_->OnPaymentResponseAvailable(std::move(payment_response)); | 74 delegate_->OnPaymentResponseAvailable(std::move(payment_response)); |
69 } | 75 } |
70 | 76 |
71 void PaymentRequestState::GeneratePaymentResponse() { | 77 void PaymentRequestState::GeneratePaymentResponse() { |
72 DCHECK(is_ready_to_pay()); | 78 DCHECK(is_ready_to_pay()); |
73 // Fetch the instrument details, will call back into | 79 // Fetch the instrument details, will call back into |
74 // PaymentRequest::OnInstrumentsDetailsReady. | 80 // PaymentRequest::OnInstrumentsDetailsReady. |
75 selected_instrument_->InvokePaymentApp(this); | 81 selected_instrument_->InvokePaymentApp(this); |
76 } | 82 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 spec_->details().shipping_options.rend(), | 239 spec_->details().shipping_options.rend(), |
234 [](const payments::mojom::PaymentShippingOptionPtr& element) { | 240 [](const payments::mojom::PaymentShippingOptionPtr& element) { |
235 return element->selected; | 241 return element->selected; |
236 }); | 242 }); |
237 if (selected_shipping_option_it != spec_->details().shipping_options.rend()) { | 243 if (selected_shipping_option_it != spec_->details().shipping_options.rend()) { |
238 selected_shipping_option_ = selected_shipping_option_it->get(); | 244 selected_shipping_option_ = selected_shipping_option_it->get(); |
239 } | 245 } |
240 } | 246 } |
241 | 247 |
242 } // namespace payments | 248 } // namespace payments |
OLD | NEW |